class RSpec::Matchers::BuiltIn::YieldSuccessiveArgs
Not intended to be instantiated directly.
Provides the implementation for ‘yield_successive_args`.
@api private
def description
- Private: -
def description "yield successive args(#{expected_arg_description})" end
def does_not_match?(block)
def does_not_match?(block) !matches?(block) && @probe.has_block? end
def expected_arg_description
def expected_arg_description @expected.map { |e| description_of e }.join(', ') end
def failure_message
- Private: -
def failure_message 'expected given block to yield successively with arguments, ' \ "but #{positive_failure_reason}" end
def failure_message_when_negated
- Private: -
def failure_message_when_negated 'expected given block not to yield successively with arguments, ' \ "but #{negative_failure_reason}" end
def initialize(*args)
def initialize(*args) @expected = args end
def matches?(block)
- Private: -
def matches?(block) @actual_formatted = [] @actual = [] args_matched_when_yielded = true yield_count = 0 @probe = YieldProbe.probe(block) do |*arg_array| arg_or_args = arg_array.size == 1 ? arg_array.first : arg_array @actual_formatted << RSpec::Support::ObjectFormatter.format(arg_or_args) @actual << arg_or_args args_matched_when_yielded &&= values_match?(@expected[yield_count], arg_or_args) yield_count += 1 end return false unless @probe.has_block? args_matched_when_yielded && yield_count == @expected.length end
def negative_failure_reason
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_formatted.join(", ")}]" end
def positive_failure_reason
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_formatted.join(", ")}]" end
def supports_block_expectations?
- Private: -
def supports_block_expectations? true end
def supports_value_expectations?
- Private: -
def supports_value_expectations? false end