webmock 1.10.0 → 1.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +10 -0
- data/lib/webmock/request_pattern.rb +1 -1
- data/lib/webmock/request_stub.rb +1 -1
- data/lib/webmock/stub_registry.rb +1 -1
- data/lib/webmock/util/query_mapper.rb +1 -0
- data/lib/webmock/version.rb +1 -1
- data/spec/acceptance/shared/returning_declared_responses.rb +8 -0
- data/spec/acceptance/shared/stubbing_requests.rb +11 -3
- data/spec/unit/stub_registry_spec.rb +9 -1
- metadata +4 -4
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 1.10.1
|
4
|
+
|
5
|
+
* '+' in request body is still treated as a space. This fixes a bug introduced in previous version.
|
6
|
+
|
7
|
+
Thanks to [Erik Michaels-Ober](https://github.com/sferik) for reporting this problem.
|
8
|
+
|
9
|
+
* Fixed issue: response body declared as Proc was not evaluated again on subsequent requests.
|
10
|
+
|
11
|
+
Thanks to [Rick Fletcher](https://github.com/rfletcher) for reporting this issue.
|
12
|
+
|
3
13
|
## 1.10.0
|
4
14
|
|
5
15
|
* '+' in query params is not treated as space anymore and is encoded as %2B
|
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, :form_url_encoded => true)
|
85
85
|
else
|
86
86
|
signature.body
|
87
87
|
end
|
@@ -66,6 +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!(/\+/, " ") if options[:form_url_encoded]
|
69
70
|
value = Addressable::URI.unencode_component(value)
|
70
71
|
end
|
71
72
|
if options[:notation] == :flat
|
data/lib/webmock/version.rb
CHANGED
@@ -117,6 +117,13 @@ shared_context "declared responses" do |*adapter_info|
|
|
117
117
|
it "should return evaluated response headers" do
|
118
118
|
stub_request(:post, "www.example.com").to_return(:headers => lambda { |request| request.headers })
|
119
119
|
http_request(:post, "http://www.example.com/", :body => "abc", :headers => {'A' => 'B'}).headers['A'].should == 'B'
|
120
|
+
http_request(:post, "http://www.example.com/", :body => "abc", :headers => {'A' => 'C'}).headers['A'].should == 'C'
|
121
|
+
end
|
122
|
+
|
123
|
+
it "should evaluate response body for each request" do
|
124
|
+
stub_request(:post, "www.example.com").to_return(:body => lambda { |request| request.body })
|
125
|
+
http_request(:post, "http://www.example.com/", :body => "echo").body.should == "echo"
|
126
|
+
http_request(:post, "http://www.example.com/", :body => "foxtrot").body.should == "foxtrot"
|
120
127
|
end
|
121
128
|
end
|
122
129
|
|
@@ -132,6 +139,7 @@ shared_context "declared responses" do |*adapter_info|
|
|
132
139
|
{:body => request.body}
|
133
140
|
})
|
134
141
|
http_request(:post, "http://www.example.com/", :body => "echo").body.should == "echo"
|
142
|
+
http_request(:post, "http://www.example.com/", :body => "foxtrot").body.should == "foxtrot"
|
135
143
|
end
|
136
144
|
|
137
145
|
it "should return evaluated response headers" do
|
@@ -105,20 +105,20 @@ shared_examples_for "stubbing requests" do |*adapter_info|
|
|
105
105
|
describe "when body is declared as a hash" do
|
106
106
|
before(:each) do
|
107
107
|
stub_request(:post, "www.example.com").
|
108
|
-
with(:body => {:a => '1', :b => 'five', 'c' => {'d' => ['e', 'f']} })
|
108
|
+
with(:body => {:a => '1', :b => 'five x', 'c' => {'d' => ['e', 'f']} })
|
109
109
|
end
|
110
110
|
|
111
111
|
describe "for request with url encoded body" do
|
112
112
|
it "should match request if hash matches body" do
|
113
113
|
http_request(
|
114
114
|
:post, "http://www.example.com/",
|
115
|
-
:body => 'a=1&c[d][]=e&c[d][]=f&b=five').status.should == "200"
|
115
|
+
:body => 'a=1&c[d][]=e&c[d][]=f&b=five+x').status.should == "200"
|
116
116
|
end
|
117
117
|
|
118
118
|
it "should match request if hash matches body in different order of params" do
|
119
119
|
http_request(
|
120
120
|
:post, "http://www.example.com/",
|
121
|
-
:body => 'a=1&c[d][]=e&b=five&c[d][]=f').status.should == "200"
|
121
|
+
:body => 'a=1&c[d][]=e&b=five+x&c[d][]=f').status.should == "200"
|
122
122
|
end
|
123
123
|
|
124
124
|
it "should not match if hash doesn't match url encoded body" do
|
@@ -152,6 +152,14 @@ shared_examples_for "stubbing requests" do |*adapter_info|
|
|
152
152
|
:post, "http://www.example.com/", :headers => {'Content-Type' => 'application/json'},
|
153
153
|
:body => "{\"foo\":\"2010-01-01\"}").status.should == "200"
|
154
154
|
end
|
155
|
+
|
156
|
+
it "should match if any of the strings have spaces" do
|
157
|
+
WebMock.reset!
|
158
|
+
stub_request(:post, "www.example.com").with(:body => {"foo" => "a b c"})
|
159
|
+
http_request(
|
160
|
+
:post, "http://www.example.com/", :headers => {'Content-Type' => 'application/json'},
|
161
|
+
:body => "{\"foo\":\"a b c\"}").status.should == "200"
|
162
|
+
end
|
155
163
|
end
|
156
164
|
|
157
165
|
describe "for request with xml body and content type is set to xml" do
|
@@ -64,7 +64,15 @@ describe WebMock::StubRegistry do
|
|
64
64
|
response1.should == WebMock::Response.new(:body => "get")
|
65
65
|
end
|
66
66
|
|
67
|
-
it "should report clone of
|
67
|
+
it "should report clone of the response" do
|
68
|
+
@request_stub.to_return(:body => lambda{|r| r.method.to_s})
|
69
|
+
WebMock::StubRegistry.instance.register_request_stub(@request_stub)
|
70
|
+
response1 = WebMock::StubRegistry.instance.response_for_request(@request_signature)
|
71
|
+
response2 = WebMock::StubRegistry.instance.response_for_request(@request_signature)
|
72
|
+
response1.should_not be(response2)
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should report clone of the dynamic response" do
|
68
76
|
@request_stub.to_return {|request| {:body => request.method.to_s} }
|
69
77
|
WebMock::StubRegistry.instance.register_request_stub(@request_stub)
|
70
78
|
response1 = WebMock::StubRegistry.instance.response_for_request(@request_signature)
|
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: 61
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 10
|
9
|
-
-
|
10
|
-
version: 1.10.
|
9
|
+
- 1
|
10
|
+
version: 1.10.1
|
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-
|
18
|
+
date: 2013-03-01 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: addressable
|