Module: EventStream::Assertions
- Defined in:
- lib/event_stream/test_helper.rb
Class Method Summary collapse
Instance Method Summary collapse
- #assert_event_matching(message = nil, &predicate) ⇒ Object
- #assert_event_published(event_name) ⇒ Object
- #find_published_event(&predicate) ⇒ Object
Class Method Details
.setup_test_subscription ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/event_stream/test_helper.rb', line 10 def self.setup_test_subscription TestEventStream.events = [] EventStream.subscribe(//) do |event| TestEventStream.events << event end end |
Instance Method Details
#assert_event_matching(message = nil, &predicate) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/event_stream/test_helper.rb', line 18 def assert_event_matching( = nil, &predicate) if TestEventStream.events.nil? raise "Call EventStream::TestHelper.setup prior to using event_stream test assertions!" end assert TestEventStream.events.any?(&predicate), "Event stream did not include a matching event: #{}" end |
#assert_event_published(event_name) ⇒ Object
26 27 28 |
# File 'lib/event_stream/test_helper.rb', line 26 def assert_event_published(event_name) assert_event_matching("No event with name #{event_name}") { |event| event.name == event_name } end |
#find_published_event(&predicate) ⇒ Object
30 31 32 |
# File 'lib/event_stream/test_helper.rb', line 30 def find_published_event(&predicate) TestEventStream.events.find(&predicate) end |