Class: NotAMock::Matchers::CallMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/not_a_mock/matchers/call_matcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent = nil) ⇒ CallMatcher

Returns a new instance of CallMatcher.



5
6
7
# File 'lib/not_a_mock/matchers/call_matcher.rb', line 5

def initialize(parent = nil)
  @parent = parent
end

Instance Attribute Details

#callsObject (readonly)

Returns the value of attribute calls.



16
17
18
# File 'lib/not_a_mock/matchers/call_matcher.rb', line 16

def calls
  @calls
end

Instance Method Details

#and_returned(result) ⇒ Object



38
39
40
# File 'lib/not_a_mock/matchers/call_matcher.rb', line 38

def and_returned(result)
  ResultMatcher.new(result, self)
end

#exactly(n) ⇒ Object



42
43
44
# File 'lib/not_a_mock/matchers/call_matcher.rb', line 42

def exactly(n)
  TimesMatcher.new(n, self)
end

#failure_messageObject



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

def failure_message
  if parent_matched?
    parent_failure_message + failure_message_without_parents
  else
    parent_failure_message
  end
end

#matched?Boolean

Returns:

  • (Boolean)


14
# File 'lib/not_a_mock/matchers/call_matcher.rb', line 14

def matched?; @matched end

#matches?(object) ⇒ Boolean

Returns:

  • (Boolean)


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

def matches?(object)
  @object = object
  @matched = parent_matches? && matches_without_parents?
end

#negative_failure_messageObject



26
27
28
# File 'lib/not_a_mock/matchers/call_matcher.rb', line 26

def negative_failure_message
  failure_message
end

#onceObject



45
# File 'lib/not_a_mock/matchers/call_matcher.rb', line 45

def once;  exactly(1) end

#twiceObject



46
# File 'lib/not_a_mock/matchers/call_matcher.rb', line 46

def twice; exactly(2) end

#with(*args) ⇒ Object



30
31
32
# File 'lib/not_a_mock/matchers/call_matcher.rb', line 30

def with(*args)
  ArgsMatcher.new(args, self)
end

#without_argsObject



34
35
36
# File 'lib/not_a_mock/matchers/call_matcher.rb', line 34

def without_args
  ArgsMatcher.new([], self)
end