Module: Houston::TestHelpers
- Defined in:
- lib/houston/test_helpers.rb
Instance Method Summary collapse
- #assert_not_triggered(event_name, message = nil) ⇒ Object
- #assert_triggered(event_name, message = nil) ⇒ Object
-
#with_exclusive_observation ⇒ Object
!warning: knows an awful lot about Houston::Observer’s implementation! Intended to keep Houston from firing the actual post_receive hooks.
Instance Method Details
#assert_not_triggered(event_name, message = nil) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/houston/test_helpers.rb', line 30 def assert_not_triggered(event_name, =nil) with_exclusive_observation do event_triggered = false Houston.observer.on event_name do event_triggered = true end yield refute event_triggered, ["The event \"#{event_name}\" was triggered", ].compact.join end end |
#assert_triggered(event_name, message = nil) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/houston/test_helpers.rb', line 16 def assert_triggered(event_name, =nil) with_exclusive_observation do event_triggered = false Houston.observer.on event_name do event_triggered = true end yield assert event_triggered, ["The event \"#{event_name}\" was not triggered", ].compact.join end end |
#with_exclusive_observation ⇒ Object
!warning: knows an awful lot about Houston::Observer’s implementation! Intended to keep Houston from firing the actual post_receive hooks
6 7 8 9 10 11 12 13 14 |
# File 'lib/houston/test_helpers.rb', line 6 def with_exclusive_observation previous_observers = Houston.observer.instance_variable_get(:@observers) begin Houston.observer.clear! yield ensure Houston.observer.instance_variable_set(:@observers, previous_observers) end end |