Files

Caricature::Interception

Groups the methods for interception together this is a mix-in for the created isolations for classes

Public Class Methods

included(base) click to toggle source

mixes in the class methods of this module when it gets included in a class.

    # File lib/caricature/isolator.rb, line 65
65:     def self.included(base)
66:       base.extend ClassMethods
67:     end

Public Instance Methods

did_class_receive?(method_name, &block) click to toggle source

Verifies whether the specified class method has been called You can specify constraints in the block

The most complex configuration you can make currently is one that is constrained by arguments. This is likely to be extended in the future to allow for more complex verifications.

Example:

    an_isolation.did_class_receive?(:a_method) do |method_call|
      method_call.with(3, "a")
    end.should.be.successful

is equivalent to:

    an_isolation.did_class_receive?(:a_method).with(3, "a").should.be.successful

You will probably be using this method only when you’re interested in whether a method has been called during the course of the test you’re running.

     # File lib/caricature/isolator.rb, line 153
153:     def did_class_receive?(method_name, &block)
154:       self.class.did_receive?(method_name, &block)
155:     end
did_receive?(method_name, &block) click to toggle source

Verifies whether the specified method has been called You can specify constraints in the block

The most complex configuration you can make currently is one that is constrained by arguments. This is most likely to be extended in the future to allow for more complex verifications.

Example:

    an_isolation.did_receive?(:a_method) do |method_call|
      method_call.with(3, "a")
    end.should.be.successful

is equivalent to:

    an_isolation.did_receive?(:a_method).with(3, "a").should.be.successful

You will probably be using this method only when you’re interested in whether a method has been called during the course of the test you’re running.

     # File lib/caricature/isolator.rb, line 131
131:     def did_receive?(method_name, &block)
132:       isolation_context.verify method_name
133:     end
isolation_context() click to toggle source

the context of this isolation instance. this context takes care of responding to method calls etc.

    # File lib/caricature/isolator.rb, line 71
71:     def isolation_context
72:       self.class.isolation_context
73:     end
when_class_receives(method_name, &block) click to toggle source

Replaces the call to the class of the proxy with the one you create with this method. You can specify more specific criteria in the block to configure the expectation.

Example:

    an_isolation.when_class_receives(:a_method) do |method_call|
      method_call.with(3, "a").return(5)
    end

is equivalent to:

    an_isolation.when_class_receives(:a_method).with(3, "a").return(5)

You will most likely use this method when you want your stubs to return something else than nil when they get called during the run of the test they are defined in.

     # File lib/caricature/isolator.rb, line 109
109:     def when_class_receives(method_name, &block)
110:       self.class.when_receiving method_name, &block
111:     end
when_receiving(method_name, &block) click to toggle source

Replaces the call to the proxy with the one you create with this method. You can specify more specific criteria in the block to configure the expectation.

Example:

    an_isolation.when_receiving(:a_method) do |method_call|
      method_call.with(3, "a").return(5)
    end

is equivalent to:

    an_isolation.when_receiving(:a_method).with(3, "a").return(5)

You will most likely use this method when you want your stubs to return something else than nil when they get called during the run of the test they are defined in.

    # File lib/caricature/isolator.rb, line 90
90:     def when_receiving(method_name, &block)
91:       isolation_context.create_override method_name, &block
92:     end
with_subject(*args, &b) click to toggle source

Initializes the underlying subject It expects the constructor parameters if they are needed.

     # File lib/caricature/isolator.rb, line 159
159:     def with_subject(*args, &b)
160:       isolation_context.instance = self.class.superclass.new *args 
161:       yield self if block_given?
162:       self
163:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.