class Wisper::RSpec::BroadcastMatcher::Matcher
Public Class Methods
new(event, *args)
click to toggle source
# File lib/wisper/rspec/matchers.rb, line 39 def initialize(event, *args) @event = event @args = args end
Public Instance Methods
actual()
click to toggle source
# File lib/wisper/rspec/matchers.rb, line 69 def actual broadcast_events_args end
broadcast_events_args()
click to toggle source
# File lib/wisper/rspec/matchers.rb, line 83 def broadcast_events_args @event_recorder.broadcast_events.map {|event| event.size == 1 ? [] : event[1..-1] } end
diffable?()
click to toggle source
# File lib/wisper/rspec/matchers.rb, line 73 def diffable? true end
expected()
click to toggle source
# File lib/wisper/rspec/matchers.rb, line 65 def expected [] << @args end
failure_message()
click to toggle source
# File lib/wisper/rspec/matchers.rb, line 58 def failure_message msg = "expected publisher to broadcast #{@event} event" msg += " with args: #{@args.inspect}" if @args.size > 0 msg << broadcast_events_list msg end
failure_message_when_negated()
click to toggle source
# File lib/wisper/rspec/matchers.rb, line 77 def failure_message_when_negated msg = "expected publisher not to broadcast #{@event} event" msg += " with args: #{@args.inspect}" if @args.size > 0 msg end
matches?(block)
click to toggle source
# File lib/wisper/rspec/matchers.rb, line 48 def matches?(block) @event_recorder = EventRecorder.new Wisper.subscribe(@event_recorder) do block.call end @event_recorder.broadcast?(@event, *@args) end
supports_block_expectations?()
click to toggle source
# File lib/wisper/rspec/matchers.rb, line 44 def supports_block_expectations? true end
Private Instance Methods
broadcast_events_list()
click to toggle source
# File lib/wisper/rspec/matchers.rb, line 87 def broadcast_events_list if @event_recorder.broadcast_events.any? " (actual events broadcast: #{event_names.join(', ')})" else " (no events broadcast)" end end
event_names()
click to toggle source
# File lib/wisper/rspec/matchers.rb, line 96 def event_names @event_recorder.broadcast_events.map do |event| event.size == 1 ? event[0] : "#{event[0]}(#{event[1..-1].join(", ")})" end end