Sha256: b6d2ff9c52eb66543ef5168a88b075160bccf4976ce1f1870e3d0c6d38706fe0
Contents?: true
Size: 1.35 KB
Versions: 34
Compression:
Stored size: 1.35 KB
Contents
module Stream module Matchers class FireEvent def initialize(event_type, opts = {}) @event_type = event_type @opts = opts @method = :"fire_#{@event_type}_after_#{@opts[:on]}" end def matches?(subject) @subject = subject defines_callback_method? && setups_up_callback? end def defines_callback_method? if @subject.instance_methods.include?(@method.to_s) true else @missing = "#{@subject.name} does not respond to #{@method}" false end end def setups_up_callback? callback_chain_name = "after_#{@opts[:on]}_callback_chain" callback_chain = @subject.send(callback_chain_name) if callback_chain.any? {|chain| chain.method == @method } true else @missing = "does setup after #{@opts[:on]} callback for #{@method}" false end end def description "fire a #{@event_type} event" end def expectation expected = "#{@subject.name} to #{description}" end def failure_message "Expected #{expectation} (#{@missing})" end def negative_failure_message "Did not expect #{expectation}" end end def fire_event(event_type, opts) FireEvent.new(event_type, opts) end end end
Version data entries
34 entries across 34 versions & 1 rubygems