Class: Wisper::RSpec::BroadcastMatcher::Matcher

Inherits:
Object
  • Object
show all
Defined in:
lib/wisper/rspec/matchers.rb

Instance Method Summary collapse

Constructor Details

#initialize(event) ⇒ Matcher

Returns a new instance of Matcher.



25
26
27
# File 'lib/wisper/rspec/matchers.rb', line 25

def initialize(event)
  @event = event
end

Instance Method Details

#failure_messageObject



43
44
45
# File 'lib/wisper/rspec/matchers.rb', line 43

def failure_message
  "expected publisher to broadcast #{@event} event"
end

#failure_message_when_negatedObject



47
48
49
# File 'lib/wisper/rspec/matchers.rb', line 47

def failure_message_when_negated
  "expected publisher not to broadcast #{@event} event"
end

#matches?(block) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
36
37
38
39
40
41
# File 'lib/wisper/rspec/matchers.rb', line 33

def matches?(block)
  event_recorder = EventRecorder.new

  Wisper.subscribe(event_recorder) do
    block.call
  end

  event_recorder.broadcast?(@event)
end

#supports_block_expectations?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/wisper/rspec/matchers.rb', line 29

def supports_block_expectations?
  true
end