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

Inherits:
Object
  • Object
show all
Includes:
Customizations
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/any_instance/chain.rb

Direct Known Subclasses

ExpectationChain, StubChain

Defined Under Namespace

Modules: Customizations

Instance Method Summary collapse

Methods included from Customizations

#and_call_original, #and_raise, #and_return, #and_throw, #and_wrap_original, #and_yield, #at_least, #at_most, #exactly, #once, record, #thrice, #time, #times, #twice

Constructor Details

#initialize(recorder, *args, &block) ⇒ Chain

Returns a new instance of Chain.



7
8
9
10
11
12
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/any_instance/chain.rb', line 7

def initialize(recorder, *args, &block)
  @recorder          = recorder
  @expectation_args  = args
  @expectation_block = block
  @argument_list_matcher = ArgumentListMatcher::MATCH_ALL
end

Instance Method Details

#constrained_to_any_of?(*constraints) ⇒ Boolean

Returns:

  • (Boolean)


61
62
63
64
65
66
67
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/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!Object



75
76
77
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/any_instance/chain.rb', line 75

def expectation_fulfilled!
  @expectation_fulfilled = true
end

#matches_args?(*args) ⇒ Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/any_instance/chain.rb', line 70

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

#neverObject



79
80
81
82
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/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) ⇒ Object



53
54
55
56
57
58
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/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

#with(*args, &block) ⇒ Object



84
85
86
87
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/any_instance/chain.rb', line 84

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