Sha256: 228bfeda3905c70eeb8a6630c4026c10b34f8a1afddad8083ba63568456641db
Contents?: true
Size: 1.2 KB
Versions: 8
Compression:
Stored size: 1.2 KB
Contents
# # DRY up strict event & data assertions. # # Example: # # expect { some_thing }.to publish_event(:some_event, actor: this_user, target: this_object) # RSpec::Matchers.define :publish_event do |name, data = {}| supports_block_expectations match do |block| defaults = {:actor => anything} allow(Reactor::Event).to receive(:publish) block.call expect(Reactor::Event).to have_received(:publish).with(name, a_hash_including(defaults.merge(data))).at_least(:once) end end # # DRY up multi-event assertions. Unfortunately can't test key-values with this at the moment. # # Example: # # expect { some_thing }.to publish_events(:some_event, :another_event) # RSpec::Matchers.define :publish_events do |*names| supports_block_expectations match do |block| defaults = {:actor => anything} allow(Reactor::Event).to receive(:publish) block.call names.each do |name| expect(Reactor::Event).to have_received(:publish).with(name, a_hash_including(defaults)).at_least(:once) end end end RSpec::Matchers.define :subscribe_to do |name, data = {}| supports_block_expectations match do block_arg.call if block_arg.present? Reactor::Event.publish(name, data) end end
Version data entries
8 entries across 8 versions & 1 rubygems