Sha256: 19e18eba3ace3b019f70ca399a75ec9bf68f7cca0c26bc9ca254b116f3d6aaea
Contents?: true
Size: 1.03 KB
Versions: 9
Compression:
Stored size: 1.03 KB
Contents
# frozen_string_literal: true # rubocop:todo all require 'spec_helper' describe Mongo::Event::Publisher do describe '#publish' do let(:listeners) do Mongo::Event::Listeners.new end let(:klass) do Class.new do include Mongo::Event::Publisher def initialize(listeners) @event_listeners = listeners end end end let(:publisher) do klass.new(listeners) end let(:listener) do double('listener') end context 'when the event has listeners' do before do listeners.add_listener('test', listener) listeners.add_listener('test', listener) end it 'handles the event for each listener' do expect(listener).to receive(:handle).with('test').twice publisher.publish('test', 'test') end end context 'when the event has no listeners' do it 'does not handle anything' do expect(listener).to receive(:handle).never publisher.publish('test', 'test') end end end end
Version data entries
9 entries across 9 versions & 2 rubygems