Class: NotAMock::Matchers::MethodMatcher

Inherits:
CallMatcher show all
Defined in:
lib/not_a_mock/matchers/method_matcher.rb

Overview

Matcher for

object.should have_received(...)

Instance Attribute Summary

Attributes inherited from CallMatcher

#calls

Instance Method Summary collapse

Methods inherited from CallMatcher

#and_returned, #exactly, #failure_message, #matched?, #matches?, #negative_failure_message, #once, #twice, #with, #without_args

Constructor Details

#initialize(method, parent = nil) ⇒ MethodMatcher

Returns a new instance of MethodMatcher.



9
10
11
12
# File 'lib/not_a_mock/matchers/method_matcher.rb', line 9

def initialize(method, parent = nil)
  super parent
  @method = method
end

Instance Method Details

#failure_message_without_parentsObject



19
20
21
22
23
24
25
# File 'lib/not_a_mock/matchers/method_matcher.rb', line 19

def failure_message_without_parents
  if matched?
    " received #{@method}"
  else
    " didn't receive #{@method}"
  end
end

#matches_without_parents?Boolean

Returns:

  • (Boolean)


14
15
16
17
# File 'lib/not_a_mock/matchers/method_matcher.rb', line 14

def matches_without_parents?
  @calls = CallRecorder.instance.calls_by_object_and_method(@object, @method)
  !@calls.empty?
end