@api private Provides the implementation for `yield_control`. Not intended to be instantiated directly.
@api public Specifies the minimum number of times the method is expected to yield
# File lib/rspec/matchers/built_in/yield.rb, line 141 def at_least(number) set_expected_yields_count(:>=, number) self end
@api public Specifies the maximum number of times the method is expected to yield
# File lib/rspec/matchers/built_in/yield.rb, line 134 def at_most(number) set_expected_yields_count(:<=, number) self end
@private
# File lib/rspec/matchers/built_in/yield.rb, line 161 def does_not_match?(block) !matches?(block) && @probe.has_block? end
@api public Specifies that the method is expected to yield the given number of times.
# File lib/rspec/matchers/built_in/yield.rb, line 127 def exactly(number) set_expected_yields_count(:==, number) self end
@api private @return [String]
# File lib/rspec/matchers/built_in/yield.rb, line 167 def failure_message 'expected given block to yield control' + failure_reason end
@api private @return [String]
# File lib/rspec/matchers/built_in/yield.rb, line 173 def failure_message_when_negated 'expected given block not to yield control' + failure_reason end
@private
# File lib/rspec/matchers/built_in/yield.rb, line 153 def matches?(block) @probe = YieldProbe.probe(block) return false unless @probe.has_block? @probe.num_yields.__send__(@expectation_type, @expected_yields_count) end
@api public Specifies that the method is expected to yield once.
# File lib/rspec/matchers/built_in/yield.rb, line 106 def once exactly(1) self end
@private
# File lib/rspec/matchers/built_in/yield.rb, line 178 def supports_block_expectations? true end
@api public Specifies that the method is expected to yield thrice.
# File lib/rspec/matchers/built_in/yield.rb, line 120 def thrice exactly(3) self end
@api public No-op. Provides syntactic sugar.
# File lib/rspec/matchers/built_in/yield.rb, line 148 def times self end
@api public Specifies that the method is expected to yield twice.
# File lib/rspec/matchers/built_in/yield.rb, line 113 def twice exactly(2) self end
# File lib/rspec/matchers/built_in/yield.rb, line 100 def initialize at_least(:once) end