Class: RSpec::Mocks::Matchers::Receive

### Home Classes Methods

### In Files

- lib/rspec/mocks/matchers/receive.rb

### Parent

Object

### Namespace

- CLASS RSpec::Mocks::Matchers::Receive::Customization

### Methods

- ::new
- #does_not_match?
- #matches?
- #setup_allowance
- #setup_any_instance_allowance
- #setup_any_instance_expectation
- #setup_any_instance_negative_expectation
- #setup_expectation
- #setup_negative_expectation

### Class/Module Index

Quicksearch

- RSpec
- RSpec::Mocks
- RSpec::Mocks::AllowanceTarget
- RSpec::Mocks::AmbiguousReturnError
- RSpec::Mocks::AndCallOriginalImplementation
- RSpec::Mocks::AndReturnImplementation
- RSpec::Mocks::AndYieldImplementation
- RSpec::Mocks::AnyInstance
- RSpec::Mocks::AnyInstance::Chain
- RSpec::Mocks::AnyInstance::Chain::Customizations
- RSpec::Mocks::AnyInstance::ExpectationChain
- RSpec::Mocks::AnyInstance::MessageChains
- RSpec::Mocks::AnyInstance::PositiveExpectationChain
- RSpec::Mocks::AnyInstance::Recorder
- RSpec::Mocks::AnyInstance::StubChain
- RSpec::Mocks::AnyInstance::StubChainChain
- RSpec::Mocks::AnyInstanceAllowanceTarget
- RSpec::Mocks::AnyInstanceExpectationTarget
- RSpec::Mocks::ArgumentListMatcher
- RSpec::Mocks::ArgumentMatchers
- RSpec::Mocks::ArgumentMatchers::AnyArgMatcher
- RSpec::Mocks::ArgumentMatchers::AnyArgsMatcher
- RSpec::Mocks::ArgumentMatchers::BooleanMatcher
- RSpec::Mocks::ArgumentMatchers::DuckTypeMatcher
- RSpec::Mocks::ArgumentMatchers::EqualityProxy
- RSpec::Mocks::ArgumentMatchers::HashExcludingMatcher
- RSpec::Mocks::ArgumentMatchers::HashIncludingMatcher
- RSpec::Mocks::ArgumentMatchers::InstanceOf
- RSpec::Mocks::ArgumentMatchers::KindOf
- RSpec::Mocks::ArgumentMatchers::MatcherMatcher
- RSpec::Mocks::ArgumentMatchers::NoArgsMatcher
- RSpec::Mocks::ArgumentMatchers::RegexpMatcher
- RSpec::Mocks::Configuration
- RSpec::Mocks::Constant
- RSpec::Mocks::ConstantMutator
- RSpec::Mocks::ConstantMutator::BaseMutator
- RSpec::Mocks::ConstantMutator::ConstantHider
- RSpec::Mocks::ConstantMutator::DefinedConstantReplacer
- RSpec::Mocks::ConstantMutator::UndefinedConstantSetter
- RSpec::Mocks::ConstantStubber
- RSpec::Mocks::Deprecation
- RSpec::Mocks::ErrorGenerator
- RSpec::Mocks::ExampleMethods
- RSpec::Mocks::ExampleMethods::ExpectHost
- RSpec::Mocks::ExpectationTarget
- RSpec::Mocks::Implementation
- RSpec::Mocks::InstanceExec
- RSpec::Mocks::InstanceMethodStasher
- RSpec::Mocks::Matchers
- RSpec::Mocks::Matchers::HaveReceived
- RSpec::Mocks::Matchers::Receive
- RSpec::Mocks::Matchers::Receive::Customization
- RSpec::Mocks::MessageExpectation
- RSpec::Mocks::MethodDouble
- RSpec::Mocks::MethodDouble::ProcWithBlock
- RSpec::Mocks::Mock
- RSpec::Mocks::MockExpectationError
- RSpec::Mocks::OrderGroup
- RSpec::Mocks::Proxy
- RSpec::Mocks::ProxyForNil
- RSpec::Mocks::RecursiveConstMethods
- RSpec::Mocks::Space
- RSpec::Mocks::StubChain
- RSpec::Mocks::Syntax
- RSpec::Mocks::TargetBase
- RSpec::Mocks::TestDouble
- RSpec::Mocks::Version
- Marshal

No matching classes.

# RSpec::Mocks::Matchers::Receive

### Public Class Methods

new(message, block) click to toggle source

    # File lib/rspec/mocks/matchers/receive.rb, line 5
    def initialize(message, block)
      @message                 = message
      @block                   = block
      @recorded_customizations = []

      # MRI, JRuby and RBX report the caller inconsistently; MRI
      # reports an extra "in `new'" line in the backtrace that the
      # others do not include. The safest way to find the right
      # line is to search for the first line BEFORE rspec/mocks/syntax.rb.
      @backtrace_line          = caller.find do |line|
        !line.split(':').first.end_with?('rspec/mocks/syntax.rb')
      end
    end

### Public Instance Methods

does_not_match?(subject, &block) click to toggle source
Alias for: setup_negative_expectation
matches?(subject, &block) click to toggle source
Alias for: setup_expectation
setup_allowance(subject, &block) click to toggle source

    # File lib/rspec/mocks/matchers/receive.rb, line 33
    def setup_allowance(subject, &block)
      setup_mock_proxy_method_substitute(subject, :add_stub, block)
    end

setup_any_instance_allowance(subject, &block) click to toggle source

    # File lib/rspec/mocks/matchers/receive.rb, line 45
    def setup_any_instance_allowance(subject, &block)
      setup_any_instance_method_substitute(subject, :stub, block)
    end

setup_any_instance_expectation(subject, &block) click to toggle source

    # File lib/rspec/mocks/matchers/receive.rb, line 37
    def setup_any_instance_expectation(subject, &block)
      setup_any_instance_method_substitute(subject, :should_receive, block)
    end

setup_any_instance_negative_expectation(subject, &block) click to toggle source

    # File lib/rspec/mocks/matchers/receive.rb, line 41
    def setup_any_instance_negative_expectation(subject, &block)
      setup_any_instance_method_substitute(subject, :should_not_receive, block)
    end

setup_expectation(subject, &block) click to toggle source

    # File lib/rspec/mocks/matchers/receive.rb, line 19
    def setup_expectation(subject, &block)
      setup_mock_proxy_method_substitute(subject, :add_message_expectation, block)
    end

Also aliased as: matches?
setup_negative_expectation(subject, &block) click to toggle source

    # File lib/rspec/mocks/matchers/receive.rb, line 24
    def setup_negative_expectation(subject, &block)
      # ensure `never` goes first for cases like `never.and_return(5)`,
      # where `and_return` is meant to raise an error
      @recorded_customizations.unshift Customization.new(:never, [], nil)

      setup_expectation(subject, &block)
    end

Also aliased as: does_not_match?

[Validate]

Generated with the Darkfish Rdoc Generator 2.