From a544d7aa372a080b77940571a3a169496045670e Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Tue, 7 Dec 2004 11:10:46 +0000 Subject: Added all the HTTP methods as alternatives to the generic "process" for functional testing #276 [Tobias Luetke] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@58 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/lib/action_controller/test_process.rb | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'actionpack/lib') diff --git a/actionpack/lib/action_controller/test_process.rb b/actionpack/lib/action_controller/test_process.rb index 41386ee7d0..41fc2f209b 100644 --- a/actionpack/lib/action_controller/test_process.rb +++ b/actionpack/lib/action_controller/test_process.rb @@ -190,10 +190,23 @@ end class Test::Unit::TestCase #:nodoc: private # execute the request and set/volley the response - def process(action, parameters = nil, session = nil) + def get(action, parameters = nil, session = nil) + @request.env['REQUEST_METHOD'] ||= "GET" @request.action = action.to_s @request.parameters.update(parameters) unless parameters.nil? @request.session = ActionController::TestSession.new(session) unless session.nil? @controller.process(@request, @response) end + + # execute the request simulating a specific http method and set/volley the response + %w( post put delete head ).each do |method| + class_eval <<-EOV + def #{method}(action, parameters = nil, session = nil) + @request.env['REQUEST_METHOD'] ||= "#{method.upcase}" + get(action, parameters, session) + end +EOV + end + + alias :process :get end \ No newline at end of file -- cgit v1.2.3