Parent

Caricature::MethodCallRecorder

The recorder that will collect method calls and provides an interface for finding those recordings

Attributes

method_calls[R]

gets the collection of method calls. This is a hash with the method name as key

Public Class Methods

new() click to toggle source

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 94
    def initialize
      @method_calls = {}
    end

Public Instance Methods

[](method_name) click to toggle source

indexer that gives you access to the recorded method by method name

# File lib/caricature/method_call_recorder.rb, line 118
    def [](method_name)
      method_calls[method_name.to_s.to_sym]
    end
record_call(method_name, *args, &block) click to toggle source

records a method call or increments the count of how many times this method was called.

# File lib/caricature/method_call_recorder.rb, line 99
    def record_call(method_name, *args, &block)
      mn_sym = method_name.to_s.to_sym
      method_calls[mn_sym] ||= MethodCallRecording.new method_name
      mc = method_calls[mn_sym]
      mc.count += 1
      mc.add_argument_variation args, block 
    end
size() click to toggle source

returns the number of different methods that has been recorderd

# File lib/caricature/method_call_recorder.rb, line 123
    def size
      @method_calls.size
    end
was_called?(method_name, *args) click to toggle source

returns whether the method was actually called with the specified constraints

# File lib/caricature/method_call_recorder.rb, line 108
    def was_called?(method_name, *args)
      mc = method_calls[method_name.to_s.to_sym]
      if mc    
        return mc.find_argument_variations(args).first == args        
      else
        return !!mc
      end
    end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.