Sha256: c96020d1c89a12d7c2fd63ef81264dafc01ab642d7fc8301f2e6756136fa0cf0

Contents?: true

Size: 825 Bytes

Versions: 1

Compression:

Stored size: 825 Bytes

Contents

require 'spec_helper'

describe Wisper::GlobalListeners do
  let(:global_listener)  { double('listener') }
  let(:local_listener)   { double('listener') }
  let(:publisher)        { Object.new.extend(Wisper) }

  describe '.add_listener' do
    it 'adds given listener to every publisher' do
      Wisper::GlobalListeners.add_listener(global_listener)
      global_listener.should_receive(:it_happened)
      publisher.send(:broadcast, :it_happened)
    end

    it 'works along side local listeners' do
      # global listener
      Wisper::GlobalListeners.add_listener(global_listener)

      # local listener
      publisher.add_listener(local_listener)

      global_listener.should_receive(:it_happened)
      local_listener.should_receive(:it_happened)

      publisher.send(:broadcast, :it_happened)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wisper-1.0.1 spec/lib/global_subscribers_spec.rb