The recorder that will collect method calls and provides an interface for finding those recordings
Initializes a new instance of a method call recorder every time a method gets called in an isolated object this gets stored in the method call recorder
# File lib/caricature/method_call_recorder.rb, line 95
95: def initialize
96: @method_calls = {:instance => {}, :class => {} }
97: end
records a method call or increments the count of how many times this method was called.
# File lib/caricature/method_call_recorder.rb, line 100
100: def record_call(method_name, mode=:instance, *args, &block)
101: mn_sym = method_name.to_s.to_sym
102: method_calls[mode][mn_sym] ||= MethodCallRecording.new method_name
103: mc = method_calls[mode][mn_sym]
104: mc.count += 1
105: mc.add_argument_variation args, block
106: end
returns the number of different methods that has been recorderd
# File lib/caricature/method_call_recorder.rb, line 124
124: def size
125: @method_calls.size
126: end
returns whether the method was actually called with the specified constraints
# File lib/caricature/method_call_recorder.rb, line 109
109: def was_called?(method_name, mode=:instance, *args)
110: mc = method_calls[mode][method_name.to_s.to_sym]
111: if mc
112: return mc.find_argument_variations(args).first == args
113: else
114: return !!mc
115: end
116: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.