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 + %w(ordered)

Instance Method Summary (collapse)

Constructor Details

- (HaveReceived) initialize(method_name, &block)

Returns a new instance of HaveReceived



10
11
12
13
14
15
# File 'lib/rspec/mocks/matchers/have_received.rb', line 10

def initialize(method_name, &block)
  @method_name = method_name
  @block = block
  @constraints = []
  @subject = nil
end

Instance Method Details

- (Object) description



43
44
45
# File 'lib/rspec/mocks/matchers/have_received.rb', line 43

def description
  expect.description
end

- (Boolean) does_not_match?(subject)

Returns:

  • (Boolean)


28
29
30
31
32
33
# File 'lib/rspec/mocks/matchers/have_received.rb', line 28

def does_not_match?(subject)
  @subject = subject
  ensure_count_unconstrained
  @expectation = expect.never
  expected_messages_received_in_order?
end

- (Object) failure_message



35
36
37
# File 'lib/rspec/mocks/matchers/have_received.rb', line 35

def failure_message
  generate_failure_message
end

- (Object) failure_message_when_negated



39
40
41
# File 'lib/rspec/mocks/matchers/have_received.rb', line 39

def failure_message_when_negated
  generate_failure_message
end

- (Boolean) matches?(subject, &block)

Returns:

  • (Boolean)


21
22
23
24
25
26
# File 'lib/rspec/mocks/matchers/have_received.rb', line 21

def matches?(subject, &block)
  @block ||= block
  @subject = subject
  @expectation = expect
  expected_messages_received_in_order?
end

- (Object) name



17
18
19
# File 'lib/rspec/mocks/matchers/have_received.rb', line 17

def name
  "have_received"
end