webmock 1.10.1 → 1.10.2

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.
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.10.2
4
+
5
+ * '+' in request path is treated as plus, but in query params always as a space.
6
+
3
7
  ## 1.10.1
4
8
 
5
9
  * '+' in request body is still treated as a space. This fixes a bug introduced in previous version.
@@ -31,7 +31,7 @@ if defined?(Excon)
31
31
  string << key.to_s << '&'
32
32
  else
33
33
  for value in [*values]
34
- string << key.to_s << '=' << URI.escape(value.to_s) << '&'
34
+ string << key.to_s << '=' << CGI.escape(value.to_s) << '&'
35
35
  end
36
36
  end
37
37
  end
@@ -201,7 +201,7 @@ module WebMock
201
201
  when :xml then
202
202
  Crack::XML.parse(body)
203
203
  else
204
- WebMock::Util::QueryMapper.query_to_values(body, :form_url_encoded => true)
204
+ WebMock::Util::QueryMapper.query_to_values(body)
205
205
  end
206
206
  end
207
207
 
@@ -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, :form_url_encoded => true)
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!(/\+/, " ") if options[:form_url_encoded]
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]
@@ -1,3 +1,3 @@
1
1
  module WebMock
2
- VERSION = '1.10.1' unless defined?(::WebMock::VERSION)
2
+ VERSION = '1.10.2' unless defined?(::WebMock::VERSION)
3
3
  end
@@ -56,6 +56,5 @@ require File.expand_path(File.dirname(__FILE__) + '/test_helper')
56
56
  assert_requested(@stub_http)
57
57
  end
58
58
  end
59
-
60
59
  end
61
60
 
@@ -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/?#{NOT_ESCAPED_PARAMS}").to_return(:body => "abc")
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/?#{NOT_ESCAPED_PARAMS}").body.should == "abc"
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/?#{NOT_ESCAPED_PARAMS}")
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\/\?x=ab%20c&z='Stop!'%20said%20Fred%2Bm/m
24
- e.message.should match /stub_request\(:get, "http:\/\/www\.example\.com\/hello\/\?x=ab%20c&z='Stop!'%20said%20Fred%2Bm"\)/m
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%2Bm"
14
- NOT_ESCAPED_PARAMS = "z='Stop!' said Fred+m&x=ab c"
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|
@@ -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+d",
51
- "www.example.com/my%20path/?a=my%20param&b=c%2Bd",
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%2Bd",
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%2Bd",
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%2Bd",
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: 61
4
+ hash: 59
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 10
9
- - 1
10
- version: 1.10.1
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-01 00:00:00 Z
18
+ date: 2013-03-04 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: addressable