returns whether this object is a clr_type. if it has a CLR type in one of its ancestors
# File lib/caricature/core_ext/object.rb, line 5 5: def clr_type? 6: self.class.clr_type? 7: end
defines a class method on an object
# File lib/caricature/core_ext/object.rb, line 15 15: def define_cmethod(name, &blk) 16: ( 17: class << self; 18: self; 19: end).instance_eval { define_method name, &blk } 20: end
# File lib/caricature/clr/aspnet_mvc.rb, line 30 30: def http_context_isolation(url="") 31: 32: context = Caricature::Isolation.for(HttpContextBase) 33: request = Caricature::Isolation.for(HttpRequestBase) 34: response = Caricature::Isolation.for(HttpResponseBase) 35: session = Caricature::Isolation.for(HttpSessionStateBase) 36: server = Caricature::Isolation.for(HttpServerUtilityBase) 37: 38: context.when_receiving(:request).return(request) 39: context.when_receiving(:response).return(response) 40: context.when_receiving(:session).return(session) 41: context.when_receiving(:server).return(server) 42: 43: setup_request_url(context.request, url) unless url.nil? or url.empty? 44: 45: context 46: end
# File lib/caricature/core_ext/object.rb, line 22 22: def isolate(name=nil, recorder = Caricature::MethodCallRecorder.new, expectations = Caricature::Expectations.new, &block) 23: iso = Caricature::Isolation.for(self, recorder, expectations) 24: return iso unless name 25: if block 26: if block.arity > 0 27: @expectation = iso.when_receiving(name, &block) 28: else 29: @expectation = iso.when_receiving(name) 30: instance_eval &block 31: end 32: end 33: iso 34: end
convenience method for creating an isolation. aliased as mock and stub for less surprises
# File lib/caricature.rb, line 21 21: def isolation_for(subject, recorder = Caricature::MethodCallRecorder.new, expectations = Caricature::Expectations.new) 22: Caricature::Isolation.for(subject, recorder, expectations) 23: end
Sets up arguments for the block that is being passed into the isolated method call
# File lib/caricature/core_ext/object.rb, line 55 55: def pass_block(*ags, &b) 56: @expectation.pass_block(*ags, &b) 57: self 58: end
tell the expectation it needs to raise an error with the specified arguments
# File lib/caricature/core_ext/object.rb, line 61 61: def raise_error(*args) 62: @expectation.raise(*args) 63: self 64: end
tell the expectation it needs to return this value or the value returned by the block you provide to this method.
# File lib/caricature/core_ext/object.rb, line 49 49: def returns(value=nil, &b) 50: @expectation.return(value, &b) 51: self 52: end
# File lib/caricature/clr/aspnet_mvc.rb, line 48 48: def setup_request_url(request, url) 49: raise ArgumentError.new("url should not be nil") if url.nil? or url.empty? 50: raise ArgumentError.new("we expect a url to start with '~/'.") unless url =~ /^~\// 51: 52: request.when_receiving(:query_string).return(url.to_s.to_qs_parameters) 53: request.when_receiving(:app_relative_current_execution_file_path).return(url.to_s.to_url_filename) 54: request.when_receiving(:path_info).return("") 55: end
tell the expectation it needs to call the super after the expecation execution
# File lib/caricature/core_ext/object.rb, line 73 73: def super_after(&b) 74: @expectation.super_after &b 75: self 76: end
tell the expectation it needs to call the super before the expectation exectution
# File lib/caricature/core_ext/object.rb, line 67 67: def super_before(&b) 68: @expectation.super_before(&b) 69: self 70: end
returns the clr type of this object if any
# File lib/caricature/core_ext/object.rb, line 10 10: def to_clr_type 11: self.class.to_clr_type 12: end
tell the expectation which arguments it needs to respond to there is a magic argument here any which configures the expectation to respond to any arguments
# File lib/caricature/core_ext/object.rb, line 42 42: def with(*ags, &b) 43: @expectation.with(*ags, &b) 44: self 45: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.