159cad1f4cb1ced2f88922f45db7193d4b1e9f0f
[sinatra.git] / lib / sinatra / test / methods.rb
blob159cad1f4cb1ced2f88922f45db7193d4b1e9f0f
1 module Sinatra
2   
3   module Test
4     
5     module Methods
6   
7       def get_it(path, params = {})
8         @request = Rack::MockRequest.new(Sinatra.application)
9         @response = @request.get(path, :input => params.to_params)
10       end
12       def post_it(path, params = {})
13         @request = Rack::MockRequest.new(Sinatra.application)
14         @response = @request.post(path, :input => params.to_params)
15       end
17       def put_it(path, params = {})
18         @request = Rack::MockRequest.new(Sinatra.application)
19         @response = @request.put(path, :input => params.to_params)
20       end
22       def delete_it(path, params = {})
23         @request = Rack::MockRequest.new(Sinatra.application)
24         @response = @request.delete(path, :input => params.to_params)
25       end
26       
27       def follow!
28         get_it(@response.location)
29       end
31       def method_missing(name, *args)
32         @response.send(name, *args)
33       end
34       
35     end
37   end
38   
39 end