Class: Test::Unit::TestCase
- Inherits:
-
Object
- Object
- Test::Unit::TestCase
- Includes:
- Nitro
- Defined in:
- lib/nitro/test/testcase.rb
Constant Summary
Constants included from Nitro
Nitro::ConsoleAdapter, Nitro::ElementCompiler, Nitro::LibPath, Nitro::Run, Nitro::Version
Constants included from Glue
Instance Method Summary collapse
-
#process(options = {}) ⇒ Object
Send a request to the controller.
- #reset_context ⇒ Object
Methods included from Nitro
Instance Method Details
#process(options = {}) ⇒ Object
Send a request to the controller. Alternatively you can use the request method helpers (get, post, …)
Options
:uri, :method, :headers/:env, :params, :session
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/nitro/test/testcase.rb', line 29 def process( = {}) unless .is_a? Hash = { :uri => .to_s } end uri = [:uri] uri = "/#{uri}" unless uri =~ /^\// reset_context unless @context context = @context if @last_response_cookies @last_response_cookies.each do || context..merge! .name => .value end end context.params = [:params] || {} context.headers = [:headers] || [:env] || {} context.headers['REQUEST_URI'] = uri context.headers['REQUEST_METHOD'] = [:method].to_s.upcase context.headers['REMOTE_ADDR'] ||= '127.0.0.1' if ((:get == [:method]) and ([:params])) context.headers['QUERY_STRING'] = [:params].collect {|k,v| "#{k}=#{v}"}.join('&') end context..merge! [:cookies] if [:cookies] context.session.merge! [:session] if [:session] context.render(context.path) @last_response_cookies = context. return context.body end |