Sha256: efd935031a2c2c93159aa487728097ab4e60f81d915c42dcfe5a2a1a39535dd5

Contents?: true

Size: 889 Bytes

Versions: 16

Compression:

Stored size: 889 Bytes

Contents

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

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

16 entries across 16 versions & 1 rubygems

Version Path
reactor-0.16.1 lib/reactor/testing/matchers.rb
reactor-0.16.0 lib/reactor/testing/matchers.rb
reactor-0.15.1 lib/reactor/testing/matchers.rb
reactor-0.15.0 lib/reactor/testing/matchers.rb
reactor-0.14.0 lib/reactor/testing/matchers.rb
reactor-0.13.0 lib/reactor/testing/matchers.rb
reactor-0.12.2 lib/reactor/testing/matchers.rb
reactor-0.12.1 lib/reactor/testing/matchers.rb
reactor-0.11.4 lib/reactor/testing/matchers.rb
reactor-0.11.2 lib/reactor/testing/matchers.rb
reactor-0.11.1 lib/reactor/testing/matchers.rb
reactor-0.11.0 lib/reactor/testing/matchers.rb
reactor-0.10.1 lib/reactor/testing/matchers.rb
reactor-0.10.0 lib/reactor/testing/matchers.rb
reactor-0.9.9 lib/reactor/testing/matchers.rb
reactor-0.9.8 lib/reactor/testing/matchers.rb