Class NotAMock::CallRecorder
In: lib/not_a_mock/call_recorder.rb
Parent: Object

The CallRecorder is a singleton that keeps track of all the call recording hooks installed, and keeps a central record of calls.

Methods

Included Modules

Singleton

Attributes

calls  [R]  An array of recorded calls in chronological order.

Each call is represented by a hash, in this format:

  { :object => example_object, :method => :example_method, :args => ["example argument"], :result => "example result" }

Public Class methods

[Source]

    # File lib/not_a_mock/call_recorder.rb, line 10
10:     def initialize
11:       @calls = []
12:       @tracked_methods = []
13:     end

Public Instance methods

Return an array of all the calls made to any method of object, in chronological order.

[Source]

    # File lib/not_a_mock/call_recorder.rb, line 22
22:     def calls_by_object(object)
23:       @calls.select {|call| call[:object] == object }
24:     end

Return an array of all the calls made to method of object, in chronological order.

[Source]

    # File lib/not_a_mock/call_recorder.rb, line 27
27:     def calls_by_object_and_method(object, method)
28:       @calls.select {|call| call[:object] == object && call[:method] == method }
29:     end

Remove all patches so that calls are no longer recorded, and clear the call log.

[Source]

    # File lib/not_a_mock/call_recorder.rb, line 60
60:     def reset
61:       untrack_all
62:       @calls = []
63:     end

Stop recording all calls.

[Source]

    # File lib/not_a_mock/call_recorder.rb, line 52
52:     def untrack_all
53:       @tracked_methods.each do |object, method|
54:         remove_hook(object, method) 
55:       end
56:       @tracked_methods = []
57:     end

[Validate]