Class: RSpec::Mocks::VerifyingMessageExpectation Private

Inherits:
MessageExpectation show all
Defined in:
lib/rspec/mocks/verifying_message_expecation.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.

A message expectation that knows about the real implementation of the message being expected, so that it can verify that any expectations have the valid arguments.

Instance Attribute Summary (collapse)

Attributes inherited from MessageExpectation

#argument_list_matcher, #implementation, #message, #orig_object

Instance Method Summary (collapse)

Methods inherited from MessageExpectation

#actual_received_count_matters?, #advise, #and_call_original, #and_raise, #and_return, #and_throw, #and_yield, #and_yield_receiver_to_implementation, #at_least, #at_most, #called_max_times?, #description, #ensure_expected_ordering_received!, #exactly, #expectation_count_type, #expected_args, #expected_messages_received?, #generate_error, #ignoring_args?, #increase_actual_received_count!, #invoke, #invoke_without_incrementing_received_count, #matches?, #matches_at_least_count?, #matches_at_most_count?, #matches_exact_count?, #matches_name_but_not_args, #negative?, #negative_expectation_for?, #never, #once, #ordered, #ordered?, #raise_out_of_order_error, #similar_messages, #times, #twice, #verify_messages_received, #yield_receiver_to_implementation_block?

Constructor Details

- (VerifyingMessageExpectation) initialize(*args)

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 VerifyingMessageExpectation



22
23
24
# File 'lib/rspec/mocks/verifying_message_expecation.rb', line 22

def initialize(*args)
  super
end

Instance Attribute Details

- (Object) method_reference

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.

A level of indirection is used here rather than just passing in the method itself, since method look up is expensive and we only want to do it if actually needed.

Conceptually the method reference makes more sense as a constructor argument since it should be immutable, but it is significantly more straight forward to build the object in pieces so for now it stays as an accessor.



20
21
22
# File 'lib/rspec/mocks/verifying_message_expecation.rb', line 20

def method_reference
  @method_reference
end

Instance Method Details

- (Object) with(*args, &block)

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.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/rspec/mocks/verifying_message_expecation.rb', line 27

def with(*args, &block)
  unless ArgumentMatchers::AnyArgsMatcher === args.first
    expected_args = if ArgumentMatchers::NoArgsMatcher === args.first
      []
    elsif args.length > 0
      args
    else
      # No arguments given, this will raise.
      super
    end

    validate_arguments!(expected_args)
  end
  super
end