Top Level Namespace
- Includes:
- System::Web, System::Web::Mvc, System::Web::Routing
Defined Under Namespace
Modules: Caricature, Spec, System Classes: Array, Class, Hash, Module, Object, Should, String
Instance Method Summary collapse
- #http_context_isolation(url = "") ⇒ Object
-
#isolate(subject, recorder = Caricature::MethodCallRecorder.new, expectations = Caricature::Expectations.new) ⇒ Object
(also: #mock, #stub)
convenience method for creating an isolation.
- #setup_request_url(request, url) ⇒ Object
Instance Method Details
#http_context_isolation(url = "") ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/caricature/clr/aspnet_mvc.rb', line 30 def http_context_isolation(url="") context = Caricature::Isolation.for(HttpContextBase) request = Caricature::Isolation.for(HttpRequestBase) response = Caricature::Isolation.for(HttpResponseBase) session = Caricature::Isolation.for(HttpSessionStateBase) server = Caricature::Isolation.for(HttpServerUtilityBase) context.when_receiving(:request).return(request) context.when_receiving(:response).return(response) context.when_receiving(:session).return(session) context.when_receiving(:server).return(server) setup_request_url(context.request, url) unless url.nil? or url.empty? context end |
#isolate(subject, recorder = Caricature::MethodCallRecorder.new, expectations = Caricature::Expectations.new) ⇒ Object Also known as: mock, stub
convenience method for creating an isolation. aliased as mock and stub for less surprises
19 20 21 |
# File 'lib/caricature.rb', line 19 def isolate(subject, recorder = Caricature::MethodCallRecorder.new, expectations = Caricature::Expectations.new) Caricature::Isolation.for(subject, recorder, expectations) end |
#setup_request_url(request, url) ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/caricature/clr/aspnet_mvc.rb', line 48 def setup_request_url(request, url) raise ArgumentError.new("url should not be nil") if url.nil? or url.empty? raise ArgumentError.new("we expect a url to start with '~/'.") unless url =~ /^~\// request.when_receiving(:query_string).return(url.to_s.to_qs_parameters) request.when_receiving(:app_relative_current_execution_file_path).return(url.to_s.to_url_filename) request.when_receiving(:path_info).return("") end |