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

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/mocks/matchers/receive.rb

Defined Under Namespace

Classes: Customization

Instance Method Summary (collapse)

Constructor Details

- (Receive) initialize(message, block)

A new instance of Receive

5
6
7
8
9
10
# File 'lib/rspec/mocks/matchers/receive.rb', line 5
def initialize(message, block)
  @message                 = message
  @block                   = block
  @recorded_customizations = []
  @backtrace_line          = CallerFilter.first_non_rspec_line
end

Instance Method Details

- (Object) setup_allowance(subject)

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

- (Object) setup_any_instance_allowance(subject)

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

- (Object) setup_any_instance_expectation(subject)

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

- (Object) setup_any_instance_negative_expectation(subject)

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

- (Object) setup_expectation(subject) Also known as: matches?

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

- (Object) setup_negative_expectation(subject) Also known as: does_not_match?

17
18
19
20
21
22
23
# File 'lib/rspec/mocks/matchers/receive.rb', line 17
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