webmock 1.14.0 → 1.15.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +6 -0
- data/Gemfile +0 -2
- data/README.md +7 -5
- data/lib/webmock/http_lib_adapters/excon_adapter.rb +14 -4
- data/lib/webmock/version.rb +1 -1
- metadata +4 -5
- data/Guardfile +0 -24
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -136,7 +136,7 @@ end # ===> Success
|
|
136
136
|
### Matching request body against a hash. Body can be URL-Encoded, JSON or XML.
|
137
137
|
|
138
138
|
```ruby
|
139
|
-
|
139
|
+
stub_request(:post, "www.example.com").
|
140
140
|
with(:body => {:data => {:a => '1', :b => 'five'}})
|
141
141
|
|
142
142
|
RestClient.post('www.example.com', "data[a]=1&data[b]=five",
|
@@ -152,7 +152,7 @@ RestClient.post('www.example.com', '<data a="1" b="five" />',
|
|
152
152
|
### Matching request body against partial hash.
|
153
153
|
|
154
154
|
```ruby
|
155
|
-
|
155
|
+
stub_request(:post, "www.example.com").
|
156
156
|
with(:body => hash_including({:data => {:a => '1', :b => 'five'}}))
|
157
157
|
|
158
158
|
RestClient.post('www.example.com', "data[a]=1&data[b]=five&x=1",
|
@@ -176,7 +176,7 @@ end # ===> Success
|
|
176
176
|
### Matching multiple headers with the same name
|
177
177
|
|
178
178
|
```ruby
|
179
|
-
|
179
|
+
stub_request(:get, 'www.example.com').with(:headers => {'Accept' => ['image/jpeg', 'image/png'] })
|
180
180
|
|
181
181
|
req = Net::HTTP::Get.new("/")
|
182
182
|
req['Accept'] = ['image/png']
|
@@ -214,7 +214,7 @@ Net::HTTP.get('www.example.com', '/') # ===> Success
|
|
214
214
|
### Matching query params using hash
|
215
215
|
|
216
216
|
```ruby
|
217
|
-
|
217
|
+
stub_request(:get, "www.example.com").with(:query => {"a" => ["b", "c"]})
|
218
218
|
|
219
219
|
RestClient.get("http://www.example.com/?a[]=b&a[]=c") # ===> Success
|
220
220
|
```
|
@@ -222,7 +222,7 @@ RestClient.get("http://www.example.com/?a[]=b&a[]=c") # ===> Success
|
|
222
222
|
### Matching partial query params using hash
|
223
223
|
|
224
224
|
```ruby
|
225
|
-
|
225
|
+
stub_request(:get, "www.example.com").with(:query => hash_including({"a" => ["b", "c"]}))
|
226
226
|
|
227
227
|
RestClient.get("http://www.example.com/?a[]=b&a[]=c&x=1") # ===> Success
|
228
228
|
```
|
@@ -860,6 +860,8 @@ People who submitted patches and new features or suggested improvements. Many th
|
|
860
860
|
* Matthew Horan
|
861
861
|
* Dmitry Gutov
|
862
862
|
* Florian Dütsch
|
863
|
+
* Manuel Meurer
|
864
|
+
* Brian D. Burns
|
863
865
|
|
864
866
|
For a full list of contributors you can visit the
|
865
867
|
[contributors](https://github.com/bblimke/webmock/contributors) page.
|
@@ -5,7 +5,7 @@ rescue LoadError
|
|
5
5
|
end
|
6
6
|
|
7
7
|
if defined?(Excon)
|
8
|
-
WebMock::VersionChecker.new('Excon', Excon::VERSION, '0.
|
8
|
+
WebMock::VersionChecker.new('Excon', Excon::VERSION, '0.27.5').check_version!
|
9
9
|
|
10
10
|
module WebMock
|
11
11
|
module HttpLibAdapters
|
@@ -54,7 +54,7 @@ if defined?(Excon)
|
|
54
54
|
response
|
55
55
|
elsif WebMock.net_connect_allowed?(mock_request.uri)
|
56
56
|
conn = new_excon_connection(params)
|
57
|
-
real_response = conn.request(
|
57
|
+
real_response = conn.request(request_params_from(params.merge(:mock => false)))
|
58
58
|
|
59
59
|
ExconAdapter.perform_callbacks(mock_request, ExconAdapter.mock_response(real_response), :real_request => true)
|
60
60
|
|
@@ -68,15 +68,25 @@ if defined?(Excon)
|
|
68
68
|
# Ensure the connection is constructed with the exact same args
|
69
69
|
# that the orginal connection was constructed with.
|
70
70
|
args = params.fetch(:__construction_args)
|
71
|
-
::Excon::Connection.new(
|
71
|
+
::Excon::Connection.new(connection_params_from args.merge(:mock => false))
|
72
72
|
end
|
73
73
|
|
74
|
-
def self.
|
74
|
+
def self.connection_params_from(hash)
|
75
75
|
hash = hash.dup
|
76
76
|
PARAMS_TO_DELETE.each { |key| hash.delete(key) }
|
77
77
|
hash
|
78
78
|
end
|
79
79
|
|
80
|
+
def self.request_params_from(hash)
|
81
|
+
hash = hash.dup
|
82
|
+
if Excon::VERSION >= '0.27.5'
|
83
|
+
request_keys = Excon::Utils.valid_request_keys(hash)
|
84
|
+
hash.reject! {|key,_| !request_keys.include?(key) }
|
85
|
+
end
|
86
|
+
PARAMS_TO_DELETE.each { |key| hash.delete(key) }
|
87
|
+
hash
|
88
|
+
end
|
89
|
+
|
80
90
|
def self.to_query(hash)
|
81
91
|
string = ""
|
82
92
|
for key, values in hash
|
data/lib/webmock/version.rb
CHANGED
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: 43
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
8
|
+
- 15
|
9
9
|
- 0
|
10
|
-
version: 1.
|
10
|
+
version: 1.15.0
|
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-10-
|
18
|
+
date: 2013-10-15 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: addressable
|
@@ -208,7 +208,6 @@ files:
|
|
208
208
|
- .travis.yml
|
209
209
|
- CHANGELOG.md
|
210
210
|
- Gemfile
|
211
|
-
- Guardfile
|
212
211
|
- LICENSE
|
213
212
|
- README.md
|
214
213
|
- Rakefile
|
data/Guardfile
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
# A sample Guardfile
|
2
|
-
# More info at https://github.com/guard/guard#readme
|
3
|
-
|
4
|
-
# rubies = %w[
|
5
|
-
# 1.8.6
|
6
|
-
# 1.8.7
|
7
|
-
# 1.9.2
|
8
|
-
# ree
|
9
|
-
# jruby
|
10
|
-
# ].map { |ruby| "#{ruby}@webmock" }
|
11
|
-
|
12
|
-
rspec_options = {
|
13
|
-
# :rvm => rubies,
|
14
|
-
:all_on_start => false,
|
15
|
-
:notification => false,
|
16
|
-
:cli => '--color',
|
17
|
-
:version => 2
|
18
|
-
}
|
19
|
-
|
20
|
-
guard 'rspec', rspec_options do
|
21
|
-
watch(%r{^spec/.+_spec\.rb})
|
22
|
-
watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
23
|
-
watch('spec/spec_helper.rb') { "spec" }
|
24
|
-
end
|