Object
# File lib/rspec/matchers/built_in/yield.rb, line 60 60: def self.assert_valid_expect_block!(block) 61: return if block.arity == 1 62: raise "Your expect block must accept an argument to be used with this " + 63: "matcher. Pass the argument as a block on to the method you are testing." 64: end
# File lib/rspec/matchers/built_in/yield.rb, line 51 51: def assert_used! 52: return if @used 53: raise "You must pass the argument yielded to your expect block on " + 54: "to the method-under-test as a block. It acts as a probe that " + 55: "allows the matcher to detect whether or not the method-under-test " + 56: "yields, and, if so, how many times, and what the yielded arguments " + 57: "are." 58: end
# File lib/rspec/matchers/built_in/yield.rb, line 30 30: def single_yield_args 31: yielded_args.first 32: end
# File lib/rspec/matchers/built_in/yield.rb, line 45 45: def successive_yield_args 46: yielded_args.map do |arg_array| 47: arg_array.size == 1 ? arg_array.first : arg_array 48: end 49: end
# File lib/rspec/matchers/built_in/yield.rb, line 20 20: def to_proc 21: @used = true 22: 23: probe = self 24: Proc.new do |*args| 25: probe.num_yields += 1 26: probe.yielded_args << args 27: end 28: end
# File lib/rspec/matchers/built_in/yield.rb, line 34 34: def yielded_once?(matcher_name) 35: case num_yields 36: when 1 then true 37: when 0 then false 38: else 39: raise "The #{matcher_name} matcher is not designed to be used with a " + 40: "method that yields multiple times. Use the yield_successive_args " + 41: "matcher for that case." 42: end 43: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.