Created
February 8, 2010 17:06
-
-
Save awesome/298355 to your computer and use it in GitHub Desktop.
webrat via cucumber: missing query-string params in your controller?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # | |
| # I heard you like patches in yo controller dawg... | |
| # | |
| # DIRTY PATCH for | |
| # def get,post,put,delete | |
| # http://github.com/brynary/webrat/blob/38535d1e0ec3dab91b4c516dfd4c14ac7f6f81e4/lib/webrat/rails.rb | |
| # | |
| # | |
| # | |
| before_filter :test_helper | |
| def test_helper | |
| if RAILS_ENV == "test" | |
| m = /^[^\?]*\?(.*)/.match(request.request_uri) | |
| unless m.nil? or m[1].empty? | |
| params2 = ::Rack::Utils.parse_query(m[1]) | |
| params.merge!(params2) | |
| end | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # steps | |
| 21 When /^I send a "([^\"]*)" request to "([^\"]*)" with "([^\"]*)" content_type and the data:$/ do |verb, url, content_type, string| | |
| 22 case verb | |
| 23 when "GET": get(url, {"Content-type" => content_type}) | |
| # controller | |
| 6 page = (params[:page] || 1) | |
| 7 raise request.path.inspect + " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" | |
| # running tests | |
| "/api/v1/providers.xml" <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< (RuntimeError) | |
| ./app/controllers/api/v1/providers_controller.rb:7:in `index' | |
| ./features/step_definitions/api_shared.rb:23:in `/^I send a "([^\"]*)" request to "([^\"]*)" with "([^\"]*)" content_type and the data:$/' | |
| features/api/v1/xml_accounts_app.feature:41:in `When I send a "GET" request to "/api/v1/providers.xml?page=3" with "xml" content_type and the data:' | |
| # controller again | |
| 6 page = (params[:page] || 1) | |
| 7 raise params.inspect + " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" | |
| # running tests again | |
| {"format"=>"xml", "Content-type"=>"xml", "action"=>"index", "controller"=>"api/v1/providers"} <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< (RuntimeError) | |
| ./app/controllers/api/v1/providers_controller.rb:8:in `index' | |
| ./features/step_definitions/api_shared.rb:23:in `/^I send a "([^\"]*)" request to "([^\"]*)" with "([^\"]*)" content_type and the data:$/' | |
| features/api/v1/xml_accounts_app.feature:41:in `When I send a "GET" request to "/api/v1/providers.xml?page=3" with "xml" content_type and the data:' | |
| # controller again | |
| 6 page = (params[:page] || 1) | |
| 7 raise request.inspect + " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" | |
| # running tests again | |
| <ActionController::Request:0x2441ae0 @parameters={"format"=>"xml", "Content-type"=>"xml", "action"=>"index", "controller"=>"api/v1/providers"}, @env={"action_controller.rescue.request"=>#<ActionController::Request:0x2441ae0 ...>, "SERVER_NAME"=>"www.example.com", "rack.url_scheme"=>"http", "PATH_INFO"=>"/api/v1/providers.xml?page=3", "CONTENT_LENGTH"=>"0", "rack.input"=>#<Rack::Lint::InputWrapper:0x24467ac @input=#<StringIO:0x2455428>>, "rack.run_once"=>false, "action_controller.request.request_parameters"=>{}, "SCRIPT_NAME"=>"", "HTTP_HOST"=>"www.example.com", "rack.errors"=>#<Rack::Lint::ErrorWrapper:0x2445c58 @error=#<StringIO:0x2453a10>>, "REMOTE_ADDR"=>"127.0.0.1", "HTTPS"=>"off", "CONTENT_TYPE"=>"application/x-www-form-urlencoded", "rack.request.query_hash"=>{"Content-type"=>"xml"}, "rack.request.form_input"=>#<Rack::Lint::InputWrapper:0x24467ac @input=#<StringIO:0x2455428>>, "HTTP_COOKIE"=>"", "rack.version"=>[0, 1], "rack.multithread"=>false, "rack.request.form_vars"=>"", "action_controller.request.path_parameters"=>{"format"=>"xml", "action"=>"index", "controller"=>"api/v1/providers"}, "REQUEST_URI"=>"/api/v1/providers.xml?page=3", "rack.multiprocess"=>true, "SERVER_PORT"=>"80", "rack.request.query_string"=>"Content-type=xml", "rack.request.form_hash"=>{}, "action_controller.rescue.response"=>#<ActionController::Response:0x24415f4 @writer=#<Proc:0x024fa1e4@/Users/awesome/.rvm/gems/ruby-1.8.6-p399/gems/actionpack-2.3.5/lib/action_controller/response.rb:46>, @header={"Cache-Control"=>"no-cache"}, @session={:session_id=>"62ddb22450d7bb734facfca0a18dbfcf"}, @assigns=[], @redirected_to=nil, @body=["", []], @template=#<ActionView::Base:0x2440c58 @_current_render=nil, @assigns_added=nil, @_first_render=nil, @assigns={}, @helpers=#<ActionView::Base::ProxyModule:0x244085c>, @_rendered={:template=>nil, :partials=>{}}, @view_paths=["/Users/awesome/projects/tagnologies/tagid/app/views"], @controller=#<Api::V1::ProvidersController:0x24410a4 @_request=#<ActionController::Request:0x2441ae0 ...>, @url=#<ActionController::UrlRewriter:0x243ad94 @parameters={"format"=>"xml", "Content-type"=>"xml", "action"=>"index", "controller"=>"api/v1/providers"}, @request=#<ActionController::Request:0x2441ae0 ...>>, @performed_redirect=false, @_headers={"Cache-Control"=>"no-cache"}, @before_filter_chain_aborted=false, @action_name="index", @_response=#<ActionController::Response:0x24415f4 ...>, @_session={:session_id=>"62ddb22450d7bb734facfca0a18dbfcf"}, @performed_render=false, @real_format=nil, @template=#<ActionView::Base:0x2440c58 ...>, @_params={"format"=>"xml", "Content-type"=>"xml", "action"=>"index", "controller"=>"api/v1/providers"}, @request_origin="127.0.0.1 at 2010-02-07 08:17:49">>, @request=#<ActionController::Request:0x2441ae0 ...>, @block=nil, @status=200>, "rack.session.options"=>{:httponly=>true, :path=>"/", :id=>"62ddb22450d7bb734facfca0a18dbfcf", :expire_after=>nil, :domain=>nil, :key=>"_session_id"}, "QUERY_STRING"=>"Content-type=xml", "action_controller.request.query_parameters"=>{"Content-type"=>"xml"}, "rack.session"=>{:session_id=>"62ddb22450d7bb734facfca0a18dbfcf"}, "HTTP_ACCEPT"=>"text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5", "REQUEST_METHOD"=>"GET"}, @content_type=#<Mime::Type:0x1ab9270 @synonyms=[], @symbol=:url_encoded_form, @string="application/x-www-form-urlencoded">, @request_method=:get> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< (RuntimeError) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment