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.
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 230 230: def for(context) 231: context.recorder ||= MethodCallRecorder.new 232: context.expectations ||= Expectations.new 233: new(context) 234: end
builds up the isolation class instance
# File lib/caricature/isolator.rb, line 192 192: def build_isolation(klass, inst=nil) 193: pxy = create_isolation_for klass 194: @isolation = pxy.new 195: @subject = inst 196: initialize_messenger 197: end
Creates the new class name for the isolation
# File lib/caricature/isolator.rb, line 205 205: def class_name(subj) 206: nm = subj.respond_to?(:class_eval) ? subj.demodulize : subj.class.demodulize 207: @class_name = "#{nm}#{UUIDTools::UUID.random_create.to_s.gsub /-/, ''}" 208: @class_name 209: end
Sets up the necessary instance variables for the isolation
# File lib/caricature/isolator.rb, line 212 212: def initialize_isolation(klass, context) 213: pxy = klass.new 214: pxy.instance_variable_set("@___context___", context) 215: pxy 216: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.