Permalink
Browse files

Merge pull request #6 from robgleeson/master

Encode the query key & value using URI.encode_www_form_component.
  • Loading branch information...
2 parents eb5e508 + d9883c1 commit 8c8d898cbb301755d42fd565230d3064bd812129 @bernd committed Feb 29, 2012
Showing with 9 additions and 2 deletions.
  1. +4 −2 lib/webmachine/test/session.rb
  2. +5 −0 spec/webmachine/test/session_spec.rb
@@ -71,8 +71,10 @@ def do_request(method, uri, options)
def add_query_params(uri, params)
if params
- q = params.map {|k, v| "#{k}=#{v}" }.join('&')
- q = URI.escape(q)
+ q = params.map do |k, v|
+ k, v = URI.encode_www_form_component(k), URI.encode_www_form_component(v)
+ "#{k}=#{v}"
+ end.join('&')
uri.query = uri.query ? [uri.query, q].join('&') : q
end
@@ -72,6 +72,11 @@
}.to_not raise_error(URI::InvalidComponentError)
end
+ it "encodes the query key and value." do
+ send verb, '/', :params => { "foo=" => "bar=" }
+ request.uri.query.should == "foo%3D=bar%3D"
+ end
+
it "returns the Webmachine::Request object" do
send(verb, '/').should be_a(Webmachine::Response)
end

0 comments on commit 8c8d898

Please sign in to comment.