123456789_123456789_123456789_123456789_123456789_

Class: RSpec::Mocks::Matchers::ReceiveMessageChain Private

Do not use. This class is for internal use only.
Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
self, Matcher
Inherits: Object
Defined in: rspec-mocks/lib/rspec/mocks/matchers/receive_message_chain.rb

Class Method Summary

Instance Method Summary

Instance Method Details

#description

[ GitHub ]

  
# File 'rspec-mocks/lib/rspec/mocks/matchers/receive_message_chain.rb', line 27

def description
  "receive message chain #{formatted_chain}"
end

#does_not_match?(*_args)

[ GitHub ]

  
# File 'rspec-mocks/lib/rspec/mocks/matchers/receive_message_chain.rb', line 60

alias does_not_match? setup_negative_expectation

#formatted_chain (private)

[ GitHub ]

  
# File 'rspec-mocks/lib/rspec/mocks/matchers/receive_message_chain.rb', line 70

def formatted_chain
  @formatted_chain ||= @chain.map do |part|
    if Hash === part
      part.keys.first.to_s
    else
      part.to_s
    end
  end.join(".")
end

#matcher_name

[ GitHub ]

  
# File 'rspec-mocks/lib/rspec/mocks/matchers/receive_message_chain.rb', line 23

def matcher_name
  "receive_message_chain"
end

#matches?(subject, &block)

Alias for #setup_expectation.

[ GitHub ]

  
# File 'rspec-mocks/lib/rspec/mocks/matchers/receive_message_chain.rb', line 59

alias matches? setup_expectation

#replay_customizations(chain) (private)

[ GitHub ]

  
# File 'rspec-mocks/lib/rspec/mocks/matchers/receive_message_chain.rb', line 64

def replay_customizations(chain)
  @recorded_customizations.each do |customization|
    customization.playback_onto(chain)
  end
end

#setup_allowance(subject, &block)

[ GitHub ]

  
# File 'rspec-mocks/lib/rspec/mocks/matchers/receive_message_chain.rb', line 31

def setup_allowance(subject, &block)
  chain = StubChain.stub_chain_on(subject, *@chain, &(@block || block))
  replay_customizations(chain)
end

#setup_any_instance_allowance(subject, &block)

[ GitHub ]

  
# File 'rspec-mocks/lib/rspec/mocks/matchers/receive_message_chain.rb', line 36

def setup_any_instance_allowance(subject, &block)
  proxy = ::RSpec::Mocks.space.any_instance_proxy_for(subject)
  chain = proxy.stub_chain(*@chain, &(@block || block))
  replay_customizations(chain)
end

#setup_any_instance_expectation(subject, &block)

[ GitHub ]

  
# File 'rspec-mocks/lib/rspec/mocks/matchers/receive_message_chain.rb', line 42

def setup_any_instance_expectation(subject, &block)
  proxy = ::RSpec::Mocks.space.any_instance_proxy_for(subject)
  chain = proxy.expect_chain(*@chain, &(@block || block))
  replay_customizations(chain)
end

#setup_expectation(subject, &block) Also known as: #matches?

[ GitHub ]

  
# File 'rspec-mocks/lib/rspec/mocks/matchers/receive_message_chain.rb', line 48

def setup_expectation(subject, &block)
  chain = ExpectChain.expect_chain_on(subject, *@chain, &(@block || block))
  replay_customizations(chain)
end

#setup_negative_expectation(*_args) Also known as: #does_not_match?

[ GitHub ]

  
# File 'rspec-mocks/lib/rspec/mocks/matchers/receive_message_chain.rb', line 53

def setup_negative_expectation(*_args)
  raise NegationUnsupportedError,
        "`expect(...).not_to receive_message_chain` is not supported " \
        "since it doesn't really make sense. What would it even mean?"
end