Parent

Files

Caricature::Messenger

A base class to encapsulate method invocation

Attributes

recorder[RW]

contains the recorder for recording method calls

instance[R]

the real instance of the isolated subject used to forward calls in partial mocks

expectations[R]

the expecations that have been set for the isolation

Public Class Methods

new(expectations, instance=nil) click to toggle source

creates a new instance of this messaging strategy

    # File lib/caricature/messenger.rb, line 17
17:     def initialize(expectations, instance=nil)
18:       @instance, @expectations = instance, expectations
19:     end

Public Instance Methods

deliver(method_name, return_type, *args, &b) click to toggle source

deliver the message to the receiving isolation

    # File lib/caricature/messenger.rb, line 22
22:     def deliver(method_name, return_type, *args, &b)
23:       
24:       internal_deliver(:instance, method_name, return_type, *args, &b)
25:     end
deliver_to_class(method_name, return_type, *args, &b) click to toggle source

deliver the message to class of the receiving isolation

    # File lib/caricature/messenger.rb, line 28
28:     def deliver_to_class(method_name, return_type, *args, &b)
29:       internal_deliver(:class, method_name, return_type, *args, &b)
30:     end

Protected Instance Methods

internal_deliver(mode, method_name, return_type, *args, &b) click to toggle source

template method for looking up the expectation and/or returning a value

    # File lib/caricature/messenger.rb, line 35
35:       def internal_deliver(mode, method_name, return_type, *args, &b)
36:         raise NotImplementedError.new("Override in an implementing class")
37:       end

Private Instance Methods

record_call(method_name, mode, expectation, *args, &b) click to toggle source
    # File lib/caricature/messenger.rb, line 40
40:     def record_call(method_name, mode, expectation, *args, &b)
41:       recorder.record_call method_name, mode, expectation, *args, &b if recorder
42:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.