@api private Provides the implementation for `yield_successive_args`. Not intended to be instantiated directly.
# File lib/rspec/matchers/built_in/yield.rb, line 336 def initialize(*args) @expected = args end
@private
# File lib/rspec/matchers/built_in/yield.rb, line 363 def description desc = "yield successive args" desc << "(#{expected_arg_description})" desc end
# File lib/rspec/matchers/built_in/yield.rb, line 348 def does_not_match?(block) !matches?(block) && @probe.has_block? end
@private
# File lib/rspec/matchers/built_in/yield.rb, line 353 def failure_message "expected given block to yield successively with arguments, but #{positive_failure_reason}" end
@private
# File lib/rspec/matchers/built_in/yield.rb, line 358 def failure_message_when_negated "expected given block not to yield successively with arguments, but #{negative_failure_reason}" end
@private
# File lib/rspec/matchers/built_in/yield.rb, line 341 def matches?(block) @probe = YieldProbe.probe(block) return false unless @probe.has_block? @actual = @probe.successive_yield_args args_match? end
@private
# File lib/rspec/matchers/built_in/yield.rb, line 370 def supports_block_expectations? true end
# File lib/rspec/matchers/built_in/yield.rb, line 376 def args_match? values_match?(@expected, @actual) end
# File lib/rspec/matchers/built_in/yield.rb, line 380 def expected_arg_description @expected.map { |e| description_of e }.join(", ") end
# File lib/rspec/matchers/built_in/yield.rb, line 392 def negative_failure_reason return "was not a block" unless @probe.has_block? "yielded with expected arguments" + "\nexpected not: #{surface_descriptions_in(@expected).inspect}" + "\n got: #{@actual.inspect}" end
# File lib/rspec/matchers/built_in/yield.rb, line 384 def positive_failure_reason return "was not a block" unless @probe.has_block? "yielded with unexpected arguments" + "\nexpected: #{surface_descriptions_in(@expected).inspect}" + "\n got: #{@actual.inspect}" end