Parent

Caricature::Isolator

A base class for Isolator objects to stick with the Isolation nomenclature the strategies for creating isolations are called isolators. An isolator functions as a barrier between the code in your test and the underlying type/instance. It allows you to take control over the value that is returned from a specific method, if you want to pass the method call along to the underlying instance etc. It also contains the ability to verify if a method was called, with which arguments etc.

Attributes

isolation[R]

holds the isolation created by this isolator

subject[R]

holds the subject of this isolator

descriptor[R]

holds the descriptor for this type of object

Public Class Methods

for(context) click to toggle source

Creates the actual proxy object for the subject and initializes it with a recorder and expectations This is the actual isolation that will be used to in your tests. It implements all the methods of the subject so as long as you’re in Ruby and just need to isolate out some classes defined in a statically compiled language it should get you all the way there for public instance methods at this point. when you’re going to isolation for usage within a statically compiled language type then you’re bound to most of their rules. So you need to either isolate interfaces or mark the methods you want to isolate as virtual in your implementing classes.

# File lib/caricature/isolator.rb, line 219
      def for(context)
        context.recorder ||= MethodCallRecorder.new
        context.expectations ||= Expectations.new
        new(context)
      end
new(context) click to toggle source

creates a new instance of an isolator

# File lib/caricature/isolator.rb, line 177
    def initialize(context)
      @context = context
    end

Public Instance Methods

build_isolation(klass, inst=nil) click to toggle source

builds up the isolation class instance

# File lib/caricature/isolator.rb, line 182
    def build_isolation(klass, inst=nil)
      pxy = create_isolation_for klass
      @isolation = pxy.new
      @subject = inst
      initialize_messenger
    end
class_name(subj) click to toggle source

Creates the new class name for the isolation

# File lib/caricature/isolator.rb, line 195
    def class_name(subj)
      nm = subj.respond_to?(:class_eval) ? subj.demodulize : subj.class.demodulize
      @class_name = "#{nm}#{System::Guid.new_guid.to_string('n')}"
      @class_name
    end
initialize_isolation(klass, context) click to toggle source

Sets up the necessary instance variables for the isolation

# File lib/caricature/isolator.rb, line 202
    def initialize_isolation(klass, context)
      pxy = klass.new
      pxy.instance_variable_set("@___context___", context)
      pxy
    end
initialize_messenger() click to toggle source

initializes the messaging strategy for the isolator

# File lib/caricature/isolator.rb, line 190
    def initialize_messenger
      raise NotImplementedError
    end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.