Sha256: a3e1b4e4c0acfe7bfc761cbefcfee7d54997a10378cff816f162325452f03445

Contents?: true

Size: 1.43 KB

Versions: 1

Compression:

Stored size: 1.43 KB

Contents

require 'test_helper'
require 'integrity/notifier/test'
require 'integrity/notifier/prowl'

class IntegrityProwlTest < Test::Unit::TestCase
  include Integrity::Notifier::Test

  context 'A prowl notifier' do
    setup do
      setup_database
    end

    should 'register itself' do
      assert_equal  Integrity::Notifier::Prowl,
                    Integrity::Notifier.available['Prowl']
    end

    context 'with valid API keys' do
      should 'add one prowl message with one key' do
        config = { :api_keys => 'an_api_key' }
        flexmock(::Prowl).should_receive(:add).once

        notifier = Integrity::Notifier::Prowl
        notifier.notify_of_build(Integrity::Build.gen(:successful), config)
      end

      should 'add n prowl message with n keys' do
        [5, 10, 25, 50].each do |to|
          keys = (0...to).map{ |n| "api_key_#{n}" }
          config = { :api_keys => keys.join(',') }
          flexmock(::Prowl).should_receive(:add).times(keys.length)

          notifier = Integrity::Notifier::Prowl
          notifier.notify_of_build(Integrity::Build.gen(:successful), config)
        end
      end
    end

    should 'not notify prowl if no key is provided' do
      [nil, ''].each do |key|
        config = { :api_keys => key }
        flexmock(::Prowl).should_receive(:add).times(0)

        notifier = Integrity::Notifier::Prowl
        notifier.notify_of_build(Integrity::Build.gen(:successful), config)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bdotdub-integrity-prowl-0.2.1 test/integrity_prowl_test.rb