Class: Wisper::RSpec::BroadcastMatcher::Matcher
- Inherits:
-
Object
- Object
- Wisper::RSpec::BroadcastMatcher::Matcher
- Defined in:
- lib/wisper/rspec/matchers.rb
Instance Method Summary collapse
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(event, *args) ⇒ Matcher
constructor
A new instance of Matcher.
- #matches?(block) ⇒ Boolean
- #supports_block_expectations? ⇒ Boolean
Constructor Details
#initialize(event, *args) ⇒ Matcher
Returns a new instance of Matcher.
29 30 31 32 |
# File 'lib/wisper/rspec/matchers.rb', line 29 def initialize(event, *args) @event = event @args = args end |
Instance Method Details
#failure_message ⇒ Object
48 49 50 51 52 |
# File 'lib/wisper/rspec/matchers.rb', line 48 def msg = "expected publisher to broadcast #{@event} event" msg += " with args: #{@args.inspect}" if @args.size > 0 msg end |
#failure_message_when_negated ⇒ Object
54 55 56 57 58 |
# File 'lib/wisper/rspec/matchers.rb', line 54 def msg = "expected publisher not to broadcast #{@event} event" msg += " with args: #{@args.inspect}" if @args.size > 0 msg end |
#matches?(block) ⇒ Boolean
38 39 40 41 42 43 44 45 46 |
# File 'lib/wisper/rspec/matchers.rb', line 38 def matches?(block) event_recorder = EventRecorder.new Wisper.subscribe(event_recorder) do block.call end event_recorder.broadcast?(@event, *@args) end |
#supports_block_expectations? ⇒ Boolean
34 35 36 |
# File 'lib/wisper/rspec/matchers.rb', line 34 def supports_block_expectations? true end |