Class: RSpec::Matchers::BuiltIn::YieldSuccessiveArgs Private

Inherits:
BaseMatcher show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-expectations-3.12.2/lib/rspec/matchers/built_in/yield.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Provides the implementation for ‘yield_successive_args`. Not intended to be instantiated directly.

Constant Summary

Constants inherited from BaseMatcher

BaseMatcher::UNDEFINED

Instance Attribute Summary

Attributes inherited from BaseMatcher

#actual, #expected, #matcher_name, #rescued_exception

Instance Method Summary collapse

Methods inherited from BaseMatcher

#actual_formatted, #diffable?, #expected_formatted, #expects_call_stack_jump?, #match_unless_raises, matcher_name

Methods included from BaseMatcher::DefaultFailureMessages

has_default_failure_messages?

Methods included from BaseMatcher::HashFormatting

improve_hash_formatting

Methods included from Composable

#===, #and, #description_of, #or, should_enumerate?, surface_descriptions_in, unreadable_io?, #values_match?

Constructor Details

#initialize(*args) ⇒ YieldSuccessiveArgs

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of YieldSuccessiveArgs.



297
298
299
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-expectations-3.12.2/lib/rspec/matchers/built_in/yield.rb', line 297

def initialize(*args)
  @expected = args
end

Instance Method Details

#descriptionObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



337
338
339
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-expectations-3.12.2/lib/rspec/matchers/built_in/yield.rb', line 337

def description
  "yield successive args(#{expected_arg_description})"
end

#does_not_match?(block) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


320
321
322
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-expectations-3.12.2/lib/rspec/matchers/built_in/yield.rb', line 320

def does_not_match?(block)
  !matches?(block) && @probe.has_block?
end

#failure_messageObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



325
326
327
328
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-expectations-3.12.2/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

#failure_message_when_negatedObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



331
332
333
334
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-expectations-3.12.2/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

#matches?(block) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-expectations-3.12.2/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

#supports_block_expectations?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


342
343
344
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-expectations-3.12.2/lib/rspec/matchers/built_in/yield.rb', line 342

def supports_block_expectations?
  true
end

#supports_value_expectations?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


347
348
349
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-expectations-3.12.2/lib/rspec/matchers/built_in/yield.rb', line 347

def supports_value_expectations?
  false
end