123456789_123456789_123456789_123456789_123456789_

Class: RSpec::Mocks::AnyInstance::Chain Private

Do not use. This class is for internal use only.
Relationships & Source Files
Namespace Children
Modules:
Extension / Inclusion / Inheritance Descendants
Subclasses:
RSpec::Mocks::AnyInstance::ExpectChainChain, RSpec::Mocks::AnyInstance::ExpectationChain, RSpec::Mocks::AnyInstance::PositiveExpectationChain, RSpec::Mocks::AnyInstance::StubChain, RSpec::Mocks::AnyInstance::StubChainChain
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
Inherits: Object
Defined in: rspec-mocks/lib/rspec/mocks/any_instance/chain.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Customizations - Included

#and_call_original

Records the ‘and_call_original` message for playback against an instance that invokes a method stubbed or mocked using any_instance.

#and_raise

Records the ‘and_raise` message for playback against an instance that invokes a method stubbed or mocked using any_instance.

#and_return

Records the ‘and_return` message for playback against an instance that invokes a method stubbed or mocked using any_instance.

#and_throw

Records the ‘and_throw` message for playback against an instance that invokes a method stubbed or mocked using any_instance.

#and_wrap_original

Records the ‘and_wrap_original` message for playback against an instance that invokes a method stubbed or mocked using any_instance.

#and_yield

Records the ‘and_yield` message for playback against an instance that invokes a method stubbed or mocked using any_instance.

#at_least

Records the ‘at_least` message for playback against an instance that invokes a method stubbed or mocked using any_instance.

#at_most

Records the ‘at_most` message for playback against an instance that invokes a method stubbed or mocked using any_instance.

#exactly

Records the ‘exactly` message for playback against an instance that invokes a method stubbed or mocked using any_instance.

#never

Records the ‘never` message for playback against an instance that invokes a method stubbed or mocked using any_instance.

#once

Records the ‘once` message for playback against an instance that invokes a method stubbed or mocked using any_instance.

#thrice

Records the ‘thrice` message for playback against an instance that invokes a method stubbed or mocked using any_instance.

#time

Records the ‘time` message for playback against an instance that invokes a method stubbed or mocked using any_instance.

#times

Records the ‘times` message for playback against an instance that invokes a method stubbed or mocked using any_instance.

#twice

Records the ‘twice` message for playback against an instance that invokes a method stubbed or mocked using any_instance.

#with

Records the ‘with` message for playback against an instance that invokes a method stubbed or mocked using any_instance.

Instance Attribute Details

#negated?Boolean (readonly, private)

[ GitHub ]

  
# File 'rspec-mocks/lib/rspec/mocks/any_instance/chain.rb', line 91

def negated?
  messages.any? { |(message, *_), _| message == :never }
end

Instance Method Details

#constrained_to_any_of?(*constraints) ⇒ Boolean

[ GitHub ]

  
# File 'rspec-mocks/lib/rspec/mocks/any_instance/chain.rb', line 61

def constrained_to_any_of?(*constraints)
  constraints.any? do |constraint|
    messages.any? do |message|
      message.first.first == constraint
    end
  end
end

#expectation_fulfilled!

[ GitHub ]

  
# File 'rspec-mocks/lib/rspec/mocks/any_instance/chain.rb', line 75

def expectation_fulfilled!
  @expectation_fulfilled = true
end

#last_message (private)

[ GitHub ]

  
# File 'rspec-mocks/lib/rspec/mocks/any_instance/chain.rb', line 99

def last_message
  messages.last.first.first unless messages.empty?
end

#matches_args?(*args) ⇒ Boolean

[ GitHub ]

  
# File 'rspec-mocks/lib/rspec/mocks/any_instance/chain.rb', line 70

def matches_args?(*args)
  @argument_list_matcher.args_match?(*args)
end

#messages (private)

[ GitHub ]

  
# File 'rspec-mocks/lib/rspec/mocks/any_instance/chain.rb', line 95

def messages
  @messages ||= []
end

#never

[ GitHub ]

  
# File 'rspec-mocks/lib/rspec/mocks/any_instance/chain.rb', line 79

def never
  AnyInstance.error_generator.raise_double_negation_error("expect_any_instance_of(MyClass)") if negated?
  super
end

#playback!(instance)

[ GitHub ]

  
# File 'rspec-mocks/lib/rspec/mocks/any_instance/chain.rb', line 53

def playback!(instance)
  message_expectation = create_message_expectation_on(instance)
  messages.inject(message_expectation) do |object, message|
    object.__send__(*message.first, &message.last)
  end
end

#record(rspec_method_name, *args, &block) (private)

[ GitHub ]

  
# File 'rspec-mocks/lib/rspec/mocks/any_instance/chain.rb', line 103

def record(rspec_method_name, *args, &block)
  verify_invocation_order(rspec_method_name, *args, &block)
  messages << [args.unshift(rspec_method_name), block]
  self
end

#with(*args, &block)

[ GitHub ]

  
# File 'rspec-mocks/lib/rspec/mocks/any_instance/chain.rb', line 84

def with(*args, &block)
  @argument_list_matcher = ArgumentListMatcher.new(*args)
  super
end