class RSpec::Matchers::BuiltIn::YieldSuccessiveArgs
@api private Provides the implementation for ‘yield_successive_args`. Not intended to be instantiated directly.
Public Class Methods
# File rspec-expectations/lib/rspec/matchers/built_in/yield.rb, line 297 def initialize(*args) @expected = args end
Public Instance Methods
@private
# File rspec-expectations/lib/rspec/matchers/built_in/yield.rb, line 337 def description "yield successive args(#{expected_arg_description})" end
# File rspec-expectations/lib/rspec/matchers/built_in/yield.rb, line 320 def does_not_match?(block) !matches?(block) && @probe.has_block? end
@private
# File rspec-expectations/lib/rspec/matchers/built_in/yield.rb, line 325 def failure_message 'expected given block to yield successively with arguments, ' \ "but #{positive_failure_reason}" end
@private
# File rspec-expectations/lib/rspec/matchers/built_in/yield.rb, line 331 def failure_message_when_negated 'expected given block not to yield successively with arguments, ' \ "but #{negative_failure_reason}" end
@private
# File rspec-expectations/lib/rspec/matchers/built_in/yield.rb, line 302 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
@private
# File rspec-expectations/lib/rspec/matchers/built_in/yield.rb, line 342 def supports_block_expectations? true end
@private
# File rspec-expectations/lib/rspec/matchers/built_in/yield.rb, line 347 def supports_value_expectations? false end