webmock 1.10.1 → 1.10.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +4 -0
- data/lib/webmock/http_lib_adapters/excon_adapter.rb +1 -1
- data/lib/webmock/request_pattern.rb +1 -1
- data/lib/webmock/request_stub.rb +1 -1
- data/lib/webmock/util/query_mapper.rb +1 -2
- data/lib/webmock/version.rb +1 -1
- data/minitest/webmock_spec.rb +0 -1
- data/spec/acceptance/shared/stubbing_requests.rb +14 -11
- data/spec/acceptance/webmock_shared.rb +2 -2
- data/spec/unit/util/uri_spec.rb +8 -8
- metadata +4 -4
data/CHANGELOG.md
CHANGED
data/lib/webmock/request_stub.rb
CHANGED
@@ -81,7 +81,7 @@ module WebMock
|
|
81
81
|
|
82
82
|
if signature.body.to_s != ''
|
83
83
|
body = if signature.url_encoded?
|
84
|
-
WebMock::Util::QueryMapper.query_to_values(signature.body
|
84
|
+
WebMock::Util::QueryMapper.query_to_values(signature.body)
|
85
85
|
else
|
86
86
|
signature.body
|
87
87
|
end
|
@@ -66,8 +66,7 @@ module WebMock::Util
|
|
66
66
|
value = true if value.nil?
|
67
67
|
key = Addressable::URI.unencode_component(key)
|
68
68
|
if value != true
|
69
|
-
value.gsub
|
70
|
-
value = Addressable::URI.unencode_component(value)
|
69
|
+
value = Addressable::URI.unencode_component(value.gsub(/\+/, " "))
|
71
70
|
end
|
72
71
|
if options[:notation] == :flat
|
73
72
|
if accumulator[key]
|
data/lib/webmock/version.rb
CHANGED
data/minitest/webmock_spec.rb
CHANGED
@@ -2,13 +2,13 @@ shared_examples_for "stubbing requests" do |*adapter_info|
|
|
2
2
|
describe "when requests are stubbed" do
|
3
3
|
describe "based on uri" do
|
4
4
|
it "should return stubbed response even if request have escaped parameters" do
|
5
|
-
stub_request(:get, "www.example.com/hello
|
6
|
-
http_request(:get, "http://www.example.com/hello/?#{ESCAPED_PARAMS}").body.should == "abc"
|
5
|
+
stub_request(:get, "www.example.com/hello+/?#{NOT_ESCAPED_PARAMS}").to_return(:body => "abc")
|
6
|
+
http_request(:get, "http://www.example.com/hello%2B/?#{ESCAPED_PARAMS}").body.should == "abc"
|
7
7
|
end
|
8
8
|
|
9
9
|
it "should return stubbed response even if request has non escaped params" do
|
10
|
-
stub_request(:get, "www.example.com/hello/?#{ESCAPED_PARAMS}").to_return(:body => "abc")
|
11
|
-
http_request(:get, "http://www.example.com/hello
|
10
|
+
stub_request(:get, "www.example.com/hello%2B/?#{ESCAPED_PARAMS}").to_return(:body => "abc")
|
11
|
+
http_request(:get, "http://www.example.com/hello+/?#{NOT_ESCAPED_PARAMS}").body.should == "abc"
|
12
12
|
end
|
13
13
|
|
14
14
|
it "should return stubbed response even if stub uri is declared as regexp and request params are escaped" do
|
@@ -18,18 +18,21 @@ shared_examples_for "stubbing requests" do |*adapter_info|
|
|
18
18
|
|
19
19
|
it "should raise error specifying stubbing instructions with escaped characters in params if there is no matching stub" do
|
20
20
|
begin
|
21
|
-
http_request(:get, "http://www.example.com/hello
|
21
|
+
http_request(:get, "http://www.example.com/hello+/?#{NOT_ESCAPED_PARAMS}")
|
22
22
|
rescue WebMock::NetConnectNotAllowedError => e
|
23
|
-
e.message.should match /Unregistered request: GET http:\/\/www\.example\.com\/hello
|
24
|
-
e.message.should match /stub_request\(:get, "http:\/\/www\.example\.com\/hello
|
23
|
+
e.message.should match /Unregistered request: GET http:\/\/www\.example\.com\/hello\+\/\?x=ab%20c&z='Stop!'%20said%20Fred%20m/m
|
24
|
+
e.message.should match /stub_request\(:get, "http:\/\/www\.example\.com\/hello\+\/\?x=ab%20c&z='Stop!'%20said%20Fred%20m"\)/m
|
25
25
|
end
|
26
|
+
|
27
|
+
stub_request(:get, "http://www.example.com/hello+/?x=ab%20c&z='Stop!'%20said%20Fred%20m")
|
28
|
+
http_request(:get, "http://www.example.com/hello+/?#{NOT_ESCAPED_PARAMS}")
|
26
29
|
end
|
27
30
|
end
|
28
31
|
|
29
32
|
describe "based on query params" do
|
30
33
|
it "should return stubbed response when stub declares query params as a hash" do
|
31
|
-
stub_request(:get, "www.example.com").with(:query => {"a" => ["b", "c"]}).to_return(:body => "abc")
|
32
|
-
http_request(:get, "http://www.example.com/?a[]=b&a[]=c").body.should == "abc"
|
34
|
+
stub_request(:get, "www.example.com").with(:query => {"a" => ["b x", "c d"]}).to_return(:body => "abc")
|
35
|
+
http_request(:get, "http://www.example.com/?a[]=b+x&a[]=c%20d").body.should == "abc"
|
33
36
|
end
|
34
37
|
|
35
38
|
it "should return stubbed response when stub declares query params as a hash" do
|
@@ -135,13 +138,13 @@ shared_examples_for "stubbing requests" do |*adapter_info|
|
|
135
138
|
it "should match if hash matches body" do
|
136
139
|
http_request(
|
137
140
|
:post, "http://www.example.com/", :headers => {'Content-Type' => 'application/json'},
|
138
|
-
:body => "{\"a\":\"1\",\"c\":{\"d\":[\"e\",\"f\"]},\"b\":\"five\"}").status.should == "200"
|
141
|
+
:body => "{\"a\":\"1\",\"c\":{\"d\":[\"e\",\"f\"]},\"b\":\"five x\"}").status.should == "200"
|
139
142
|
end
|
140
143
|
|
141
144
|
it "should match if hash matches body in different form" do
|
142
145
|
http_request(
|
143
146
|
:post, "http://www.example.com/", :headers => {'Content-Type' => 'application/json'},
|
144
|
-
:body => "{\"a\":\"1\",\"b\":\"five\",\"c\":{\"d\":[\"e\",\"f\"]}}").status.should == "200"
|
147
|
+
:body => "{\"a\":\"1\",\"b\":\"five x\",\"c\":{\"d\":[\"e\",\"f\"]}}").status.should == "200"
|
145
148
|
end
|
146
149
|
|
147
150
|
it "should match if hash contains date string" do #Crack creates date object
|
@@ -10,8 +10,8 @@ require 'acceptance/shared/complex_cross_concern_behaviors'
|
|
10
10
|
|
11
11
|
unless defined? SAMPLE_HEADERS
|
12
12
|
SAMPLE_HEADERS = { "Content-Length" => "8888", "Accept" => "application/json" }
|
13
|
-
ESCAPED_PARAMS = "x=ab%20c&z=%27Stop%21%27%20said%20Fred%
|
14
|
-
NOT_ESCAPED_PARAMS = "z='Stop!' said Fred
|
13
|
+
ESCAPED_PARAMS = "x=ab%20c&z=%27Stop%21%27%20said%20Fred%20m"
|
14
|
+
NOT_ESCAPED_PARAMS = "z='Stop!' said Fred m&x=ab c"
|
15
15
|
end
|
16
16
|
|
17
17
|
shared_examples "with WebMock" do |*adapter_info|
|
data/spec/unit/util/uri_spec.rb
CHANGED
@@ -47,14 +47,14 @@ URIS_WITH_AUTH =
|
|
47
47
|
|
48
48
|
URIS_WITH_PATH_AND_PARAMS =
|
49
49
|
[
|
50
|
-
"www.example.com/my path/?a=my param&b=c
|
51
|
-
"www.example.com/my%20path/?a=my%20param&b=c%
|
52
|
-
"www.example.com:80/my path/?a=my param&b=c
|
53
|
-
"www.example.com:80/my%20path/?a=my%20param&b=c%
|
54
|
-
"http://www.example.com/my path/?a=my param&b=c
|
55
|
-
"http://www.example.com/my%20path/?a=my%20param&b=c%
|
56
|
-
"http://www.example.com:80/my path/?a=my param&b=c
|
57
|
-
"http://www.example.com:80/my%20path/?a=my%20param&b=c%
|
50
|
+
"www.example.com/my path/?a=my param&b=c d",
|
51
|
+
"www.example.com/my%20path/?a=my%20param&b=c%20d",
|
52
|
+
"www.example.com:80/my path/?a=my param&b=c d",
|
53
|
+
"www.example.com:80/my%20path/?a=my%20param&b=c%20d",
|
54
|
+
"http://www.example.com/my path/?a=my param&b=c d",
|
55
|
+
"http://www.example.com/my%20path/?a=my%20param&b=c%20d",
|
56
|
+
"http://www.example.com:80/my path/?a=my param&b=c d",
|
57
|
+
"http://www.example.com:80/my%20path/?a=my%20param&b=c%20d",
|
58
58
|
].sort
|
59
59
|
|
60
60
|
URIS_WITH_DIFFERENT_PORT =
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webmock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 59
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 10
|
9
|
-
-
|
10
|
-
version: 1.10.
|
9
|
+
- 2
|
10
|
+
version: 1.10.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Bartosz Blimke
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2013-03-
|
18
|
+
date: 2013-03-04 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: addressable
|