Class: RSpec::Mocks::Matchers::HaveReceived

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

Constant Summary

COUNT_CONSTRAINTS =
%w(exactly at_least at_most times once twice)
ARGS_CONSTRAINTS =
%w(with)
CONSTRAINTS =
COUNT_CONSTRAINTS + ARGS_CONSTRAINTS

Instance Method Summary (collapse)

Constructor Details

- (HaveReceived) initialize(method_name)

A new instance of HaveReceived

9
10
11
12
13
# File 'lib/rspec/mocks/matchers/have_received.rb', line 9
def initialize(method_name)
  @method_name = method_name
  @constraints = []
  @subject = nil
end

Instance Method Details

- (Object) description

36
37
38
# File 'lib/rspec/mocks/matchers/have_received.rb', line 36
def description
  expect.description
end

- (Boolean) does_not_match?(subject)

Returns:

  • (Boolean)
21
22
23
24
25
26
# File 'lib/rspec/mocks/matchers/have_received.rb', line 21
def does_not_match?(subject)
  @subject = subject
  ensure_count_unconstrained
  @expectation = expect.never
  expected_messages_received?
end

- (Object) failure_message

28
29
30
# File 'lib/rspec/mocks/matchers/have_received.rb', line 28
def failure_message
  generate_failure_message
end

- (Boolean) matches?(subject)

Returns:

  • (Boolean)
15
16
17
18
19
# File 'lib/rspec/mocks/matchers/have_received.rb', line 15
def matches?(subject)
  @subject = subject
  @expectation = expect
  expected_messages_received?
end

- (Object) negative_failure_message

32
33
34
# File 'lib/rspec/mocks/matchers/have_received.rb', line 32
def negative_failure_message
  generate_failure_message
end