pauldix-typhoeus 0.0.18 → 0.0.19
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/typhoeus/easy.rb +4 -1
- data/lib/typhoeus.rb +1 -1
- data/spec/typhoeus/easy_spec.rb +17 -1
- metadata +1 -1
data/lib/typhoeus/easy.rb
CHANGED
@@ -103,6 +103,9 @@ module Typhoeus
|
|
103
103
|
value = params[k]
|
104
104
|
if value.is_a? Hash
|
105
105
|
value.keys.collect {|sk| CGI.escape("#{k}[#{sk}]") + "=" + CGI.escape(value[sk].to_s)}
|
106
|
+
elsif value.is_a? Array
|
107
|
+
key = CGI.escape(k.to_s)
|
108
|
+
value.collect { |v| "#{key}=#{CGI.escape(v.to_s)}" }.join('&')
|
106
109
|
else
|
107
110
|
"#{CGI.escape(k.to_s)}=#{CGI.escape(params[k].to_s)}"
|
108
111
|
end
|
@@ -202,4 +205,4 @@ module Typhoeus
|
|
202
205
|
version
|
203
206
|
end
|
204
207
|
end
|
205
|
-
end
|
208
|
+
end
|
data/lib/typhoeus.rb
CHANGED
data/spec/typhoeus/easy_spec.rb
CHANGED
@@ -47,6 +47,22 @@ describe Typhoeus::Easy do
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
+
describe "params=" do
|
51
|
+
it "should handle arrays of params" do
|
52
|
+
easy = Typhoeus::Easy.new
|
53
|
+
easy.url = "http://localhost:3002/index.html"
|
54
|
+
easy.method = :get
|
55
|
+
easy.request_body = "this is a body!"
|
56
|
+
easy.params = {
|
57
|
+
:foo => 'bar',
|
58
|
+
:username => ['dbalatero', 'dbalatero2']
|
59
|
+
}
|
60
|
+
|
61
|
+
easy.url.should =~ /\?.*username=dbalatero&username=dbalatero2/
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
|
50
66
|
describe "put" do
|
51
67
|
it "should perform a put" do
|
52
68
|
easy = Typhoeus::Easy.new
|
@@ -119,4 +135,4 @@ describe Typhoeus::Easy do
|
|
119
135
|
easy.response_body.should include("this is a body!")
|
120
136
|
end
|
121
137
|
end
|
122
|
-
end
|
138
|
+
end
|