webmock 3.5.1 → 3.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +15 -12
  3. data/CHANGELOG.md +211 -0
  4. data/README.md +92 -26
  5. data/Rakefile +0 -2
  6. data/lib/webmock.rb +1 -0
  7. data/lib/webmock/http_lib_adapters/async_http_client_adapter.rb +214 -0
  8. data/lib/webmock/http_lib_adapters/curb_adapter.rb +10 -1
  9. data/lib/webmock/http_lib_adapters/em_http_request_adapter.rb +1 -1
  10. data/lib/webmock/http_lib_adapters/excon_adapter.rb +3 -0
  11. data/lib/webmock/http_lib_adapters/http_rb/client.rb +4 -1
  12. data/lib/webmock/http_lib_adapters/http_rb/response.rb +11 -1
  13. data/lib/webmock/http_lib_adapters/http_rb/streamer.rb +2 -2
  14. data/lib/webmock/http_lib_adapters/httpclient_adapter.rb +23 -6
  15. data/lib/webmock/http_lib_adapters/manticore_adapter.rb +25 -14
  16. data/lib/webmock/http_lib_adapters/net_http.rb +35 -17
  17. data/lib/webmock/http_lib_adapters/patron_adapter.rb +1 -1
  18. data/lib/webmock/request_body_diff.rb +1 -1
  19. data/lib/webmock/request_pattern.rb +76 -48
  20. data/lib/webmock/response.rb +11 -5
  21. data/lib/webmock/rspec.rb +2 -1
  22. data/lib/webmock/stub_registry.rb +26 -11
  23. data/lib/webmock/test_unit.rb +1 -3
  24. data/lib/webmock/util/query_mapper.rb +4 -2
  25. data/lib/webmock/util/uri.rb +8 -8
  26. data/lib/webmock/version.rb +1 -1
  27. data/lib/webmock/webmock.rb +10 -3
  28. data/spec/acceptance/async_http_client/async_http_client_spec.rb +353 -0
  29. data/spec/acceptance/async_http_client/async_http_client_spec_helper.rb +73 -0
  30. data/spec/acceptance/curb/curb_spec.rb +23 -5
  31. data/spec/acceptance/em_http_request/em_http_request_spec_helper.rb +1 -1
  32. data/spec/acceptance/excon/excon_spec_helper.rb +2 -0
  33. data/spec/acceptance/http_rb/http_rb_spec.rb +11 -0
  34. data/spec/acceptance/manticore/manticore_spec.rb +19 -0
  35. data/spec/acceptance/net_http/net_http_spec.rb +12 -0
  36. data/spec/acceptance/shared/callbacks.rb +2 -1
  37. data/spec/acceptance/shared/request_expectations.rb +7 -0
  38. data/spec/acceptance/shared/returning_declared_responses.rb +36 -15
  39. data/spec/acceptance/shared/stubbing_requests.rb +40 -0
  40. data/spec/support/webmock_server.rb +1 -0
  41. data/spec/unit/request_pattern_spec.rb +119 -3
  42. data/spec/unit/response_spec.rb +22 -18
  43. data/spec/unit/util/query_mapper_spec.rb +7 -0
  44. data/spec/unit/util/uri_spec.rb +74 -2
  45. data/spec/unit/webmock_spec.rb +54 -5
  46. data/test/test_webmock.rb +6 -0
  47. data/webmock.gemspec +9 -2
  48. metadata +39 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a1f4b12d21d9712fdf49cc29d9494285c36926b29eda702e3821caab05ba7a97
4
- data.tar.gz: 24a7edb6ce921ef9735043588ee89ab31b895f9e99bccf3c655d20f645b3cf55
3
+ metadata.gz: ee9c189319718f559e90e9e6d031d8dbdac98e9f0ae84c0c7e79d90bfc0dd493
4
+ data.tar.gz: cde291017ee8a2587c03e21d20317b96755ac15b94f1e4f287acc035c08ad904
5
5
  SHA512:
6
- metadata.gz: 724c7ae8d9ba016537b0e45968e9ae8d820458be36106a24eb7374ccc09cb3e06fb0df5968014443b4f94ba16349dad4643bf683cab17c4af1b32ae9c5b1112d
7
- data.tar.gz: 440171bbd565223139df3aec8581378497cfe359dc766c4b5e8dcf0b865a6c6adf759029d551b3ffac084d7b9683401baabd0b713930017563b7d79cb09320e8
6
+ metadata.gz: 54838a253c586b32dfaf604b8f4c8efff34bb81a888bda860ca6e9b58ff0a5430376852e0d17a84d8ee4e56a088031d75d3ddb3d00d803789e6eb013e5493d9a
7
+ data.tar.gz: 9ddee20d1741ad835224254caaa8bbeda8807dc71c246c4ea8c3be18f31c089658f8c7a3b2fdf14da1f9cda32fe7c7cbf9cb594445ba92d47fa549754dd9b27e
@@ -1,21 +1,24 @@
1
1
  before_install:
2
- - gem update --system
3
- - gem update bundler
2
+ - gem update --system -N
4
3
  rvm:
5
- - 2.3.8
6
- - 2.4.5
7
- - 2.5.3
8
- - 2.6.0
4
+ - 2.5.5
5
+ - 2.6.3
6
+ - 2.7.0
9
7
  - rbx-2
10
8
  - ruby-head
11
- - jruby-9.1.17.0
12
- - jruby-9.2.5.0
13
- - jruby-head
14
9
  matrix:
10
+ include:
11
+ - rvm: jruby-9.1.17.0
12
+ jdk: openjdk8
13
+ - rvm: jruby-9.2.11.1
14
+ jdk: openjdk11
15
+ - rvm: jruby-head
16
+ jdk: openjdk11
15
17
  allow_failures:
16
18
  - rvm: jruby-head
17
19
  - rvm: ruby-head
18
20
  - rvm: rbx-2
19
- # Send builds to container-based infrastructure
20
- # http://docs.travis-ci.com/user/workers/container-based-infrastructure/
21
- sudo: false
21
+ env:
22
+ global:
23
+ JRUBY_OPTS: "--debug"
24
+
@@ -1,5 +1,216 @@
1
1
  # Changelog
2
2
 
3
+ # 3.11.0
4
+
5
+ * Added support for `features` in http.rb adapter.
6
+
7
+ Thanks to [Carl (ce07c3)](https://github.com/ce07c3)
8
+
9
+ # 3.10.0
10
+
11
+ * Added option to global stubs to have lower priority than local stubs.
12
+
13
+ WebMock.globally_stub_request(:after_local_stubs) do
14
+ { body: "global stub body" }
15
+ end
16
+
17
+ stub_request(:get, "www.example.com").to_return(body: 'non-global stub body')
18
+
19
+ expect(http_request(:get, "http://www.example.com/").body).to eq("non-global stub body")
20
+
21
+ Thanks to [Marek Kasztelnik](https://github.com/mkasztelnik)
22
+
23
+ # 3.9.5
24
+
25
+ * Prevent overwriting `teardown` method in Test::Unit
26
+
27
+ Thanks to [Jesse Bowes](https://github.com/jessebs)
28
+
29
+ # 3.9.4
30
+
31
+ * More intuitive error message when stubbed response body was provided as Hash
32
+
33
+ Thanks to [Ben Koshy](https://github.com/BKSpurgeon)
34
+
35
+ # 3.9.3
36
+
37
+ * Make httpclient_adapter thread-safe
38
+
39
+ Thanks to [Adam Harwood](https://github.com/adam-harwood)
40
+
41
+ # 3.9.2
42
+
43
+ * Made global stubs thread-safe
44
+
45
+ Thanks to [Adam Harwood](https://github.com/adam-harwood)
46
+
47
+ # 3.9.1
48
+
49
+ * Fixed support for passing `URI` objects as second argument of `stub_request`
50
+
51
+ Thanks to [Ryan Kerr](https://github.com/leboshi)
52
+
53
+ ## 3.9.0
54
+
55
+ * Allow using a "callable" (like a proc) as URI pattern
56
+
57
+ stub_request(:any, ->(uri) { true })
58
+
59
+ Thanks to [John Hawthorn](https://github.com/jhawthorn)
60
+
61
+ * Added stubbed IO on stubbed socket in Net::HTTP adapter.
62
+
63
+ Thanks to [Thilo Rusche](https://github.com/trusche)
64
+
65
+ * When 'webmock/rspec' is required, reset WebMock after all after(:each/example) hooks
66
+
67
+ Thanks to [Andrew Stuntz](https://github.com/drews256)
68
+
69
+ * Fixed `net_connect_allowed?` when invoked with no arguments, when there were any allowed URIs passed to `disable_net_connect?`.
70
+
71
+ Thanks to [Lucas Uyezu](https://github.com/lucasuyezu)
72
+
73
+ * Fixed async-http adapter which caused Async::HTTP::Client or Async::HTTP::Internet to hang and never return a response.
74
+
75
+ Thanks to [Bruno Sutic](https://github.com/bruno-) and [Samuel Williams](https://github.com/ioquatix)
76
+
77
+ * Fixed warning when using async-http adapter
78
+
79
+ Thanks to [Bruno Sutic](https://github.com/bruno-)
80
+
81
+ * Dropped support for Ruby 2.3 - EOL date: 2019-03-31
82
+
83
+ * Dropped support for Ruby 2.4 - EOL date: 2020-03-31
84
+
85
+ * Handling matching of Addressable::Template patterns that have an ip address without port and patterns that have ip address and don’t have schema and path.
86
+
87
+ Thanks to [Rafael França](https://github.com/rafaelfranca) and [guppy0356](https://github.com/guppy0356)
88
+
89
+ ## 3.8.3
90
+
91
+ * Fixed problem introduced in version 3.4.2, which caused matching against Addressable::Template representing host part of the URI to raise an error.
92
+
93
+ Thanks to [Vesa Laakso](https://github.com/valscion)
94
+
95
+ ## 3.8.2
96
+
97
+ * Support correct encoding parameter for HTTP.rb 2.x and earlier
98
+
99
+ Thanks to [Alex Coomans](https://github.com/drcapulet)
100
+
101
+ ## 3.8.1
102
+
103
+ * Added support for mocking non-ASCII bodies when making requests with HTTP.rb
104
+
105
+ Thanks to [Patrik Ragnarsson](https://github.com/dentarg)
106
+
107
+ ## 3.8.0
108
+
109
+ * Fixed options handling when initialising Async::HTTP::Client
110
+
111
+ Thanks to [Samuel Williams](https://github.com/ioquatix)
112
+
113
+ * Ruby 2.7 support.
114
+
115
+ Thanks to [Ryan Davis](https://github.com/zenspider) and [Brandur](https://github.com/brandur)
116
+
117
+ ## 3.7.6
118
+
119
+ * Suppressed keyword argument warnings in Ruby 2.7 in async-http adapter.
120
+
121
+ Thanks to [Koichi ITO](https://github.com/koic)
122
+
123
+ ## 3.7.5
124
+
125
+ * Suppress Excon warning generated by extra key
126
+
127
+ Thanks to [Marco Costa](https://github.com/marcotc)
128
+
129
+ ## 3.7.4
130
+
131
+ * Resetting memoized response fields in Curb adapter.
132
+
133
+ Thanks to [Andrei Sidorov](https://github.com/heretge)
134
+
135
+ ## 3.7.3
136
+
137
+ * Fix for http.rb. Allow passing an output buffer to HTTP::Response::Body#readpartial
138
+
139
+ Thanks to [George Claghorn](https://github.com/georgeclaghorn)
140
+
141
+ * Fixed Manticore adapter to invoke Manticore failure handler on stubbed timeout
142
+
143
+ Thanks to [Alex Junger](https://github.com/alexJunger)
144
+
145
+ * Added project metadata to the gemspec
146
+
147
+ Thanks to [Orien Madgwick](https://github.com/orien)
148
+
149
+ ## 3.7.2
150
+
151
+ * Fixed handling of non UTF-8 encoded urls
152
+
153
+ Thanks to [Rafael França](https://github.com/rafaelfranca)
154
+
155
+ * Fixed "shadowing outer local variable" warning
156
+
157
+ Thanks to [y-yagi](https://github.com/y-yagi)
158
+
159
+ ## 3.7.1
160
+
161
+ * Fixed Async::HTTP::Client adapter code to not cause Ruby warning
162
+
163
+ Thanks to [y-yagi](https://github.com/y-yagi)
164
+
165
+ ## 3.7.0
166
+
167
+ * Support for Async::HTTP::Client
168
+
169
+ Thanks to [Andriy Yanko](https://github.com/ayanko)
170
+
171
+ ## 3.6.2
172
+
173
+ * Fixed Patron adapter to handle HTTP/2 status line.
174
+
175
+ Thanks to [Fábio D. Batista](https://github.com/fabiob)
176
+
177
+ ## 3.6.1
178
+
179
+ * Fixed issue with matching Addressable::Template without a period in the domain
180
+
181
+ Thanks to [Eike Send](https://github.com/eikes)
182
+
183
+ * Support for `write_timeout` in Net::HTTP
184
+
185
+ Thanks to [Claudio Poli](https://github.com/masterkain)
186
+
187
+ * Fixed issue with handling urls with ":80" or ":443" in the path.
188
+
189
+ Thanks to [Csaba Apagyi](https://github.com/thisismydesign) for reporting and to [Frederick Cheung](https://github.com/fcheung) for fixing the issue.
190
+
191
+ ## 3.6.0
192
+
193
+ * Compatibility with the latest version of hashdiff gem, with constant changed from HashDiff to Hashdiff
194
+
195
+ Thanks to [Jeff Felchner](https://github.com/jfelchner)
196
+
197
+ * Added a hint to the error message raised when `with` method is called without args or a block.
198
+
199
+ Thanks to [Adam Sokolnicki](https://github.com/asok)
200
+
201
+ * Resetting configured HTTP method in Curb adapter after each request
202
+
203
+ Thanks to [tiendo1011](https://github.com/tiendo1011)
204
+
205
+ * Added `WebMock.enable_net_connect!` as an alias for `WebMock.allow_net_connect!`
206
+ and `WebMock.disallow_net_connect!` as an alias for `WebMock.disable_net_connect!`
207
+
208
+ Thanks to [SoonKhen OwYong](https://github.com/owyongsk)
209
+
210
+ * Fixed handling of empty arrays as query params when using Faraday
211
+
212
+ Thanks to [Ryan Moret](https://github.com/rcmoret)
213
+
3
214
  ## 3.5.1
4
215
 
5
216
  * Disabling TracePoint defined in Net::BufferedIO in case of exception being raised.
data/README.md CHANGED
@@ -1,6 +1,11 @@
1
1
  WebMock
2
2
  =======
3
- [![Gem Version](https://badge.fury.io/rb/webmock.svg)](http://badge.fury.io/rb/webmock) [![Build Status](https://secure.travis-ci.org/bblimke/webmock.svg?branch=master)](http://travis-ci.org/bblimke/webmock) [![Dependency Status](https://gemnasium.com/bblimke/webmock.svg)](http://gemnasium.com/bblimke/webmock) [![Code Climate](https://codeclimate.com/github/bblimke/webmock/badges/gpa.svg)](https://codeclimate.com/github/bblimke/webmock) [![Mentioned in Awesome Ruby](https://awesome.re/mentioned-badge.svg)](https://github.com/markets/awesome-ruby) [![Inline docs](http://inch-ci.org/github/bblimke/webmock.svg?branch=master)](http://inch-ci.org/github/bblimke/webmock)
3
+ [![Gem Version](https://badge.fury.io/rb/webmock.svg)](http://badge.fury.io/rb/webmock)
4
+ [![Build Status](https://secure.travis-ci.org/bblimke/webmock.svg?branch=master)](http://travis-ci.org/bblimke/webmock)
5
+ [![Code Climate](https://codeclimate.com/github/bblimke/webmock/badges/gpa.svg)](https://codeclimate.com/github/bblimke/webmock)
6
+ [![Mentioned in Awesome Ruby](https://awesome.re/mentioned-badge.svg)](https://github.com/markets/awesome-ruby)
7
+ [![Inline docs](http://inch-ci.org/github/bblimke/webmock.svg?branch=master)](http://inch-ci.org/github/bblimke/webmock)
8
+ [![SemVer](https://api.dependabot.com/badges/compatibility_score?dependency-name=webmock&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score.html?dependency-name=webmock&package-manager=bundler&version-scheme=semver)
4
9
 
5
10
  Library for stubbing and setting expectations on HTTP requests in Ruby.
6
11
 
@@ -19,30 +24,42 @@ Features
19
24
  Supported HTTP libraries
20
25
  ------------------------
21
26
 
22
- * Net::HTTP and libraries based on Net::HTTP (i.e RightHttpConnection, REST Client, HTTParty)
23
- * HTTPClient
24
- * Patron
25
- * EM-HTTP-Request
27
+ * Async::HTTP::Client
26
28
  * Curb (currently only Curb::Easy)
27
- * Typhoeus (currently only Typhoeus::Hydra)
29
+ * EM-HTTP-Request
28
30
  * Excon
29
- * HTTP Gem
31
+ * HTTPClient
32
+ * [HTTP Gem (also known as http.rb)](https://github.com/httprb/http)
30
33
  * Manticore
34
+ * Net::HTTP and other libraries based on Net::HTTP, e.g.:
35
+ * HTTParty
36
+ * REST Client
37
+ * RightHttpConnection
38
+ * Patron
39
+ * Typhoeus (currently only Typhoeus::Hydra)
31
40
 
32
41
  Supported Ruby Interpreters
33
42
  ---------------------------
34
43
 
35
- * MRI 2.2
36
- * MRI 2.3
37
- * MRI 2.4
38
44
  * MRI 2.5
39
45
  * MRI 2.6
46
+ * MRI 2.7
40
47
  * JRuby
41
48
  * Rubinius
42
49
 
43
50
  ## Installation
44
51
 
52
+ ```bash
45
53
  gem install webmock
54
+ ```
55
+ or alternatively:
56
+
57
+ ```ruby
58
+ # add to your Gemfile
59
+ group :test do
60
+ gem "webmock"
61
+ end
62
+ ```
46
63
 
47
64
  ### or to install the latest development version from github master
48
65
 
@@ -54,36 +71,36 @@ Supported Ruby Interpreters
54
71
 
55
72
  WebMock 2.x has changed somewhat since version 1.x. Changes are listed in [CHANGELOG.md](CHANGELOG.md)
56
73
 
57
- ### Test::Unit
74
+ ### Cucumber
58
75
 
59
- Add the following code to `test/test_helper.rb`
76
+ Create a file `features/support/webmock.rb` with the following contents:
60
77
 
61
78
  ```ruby
62
- require 'webmock/test_unit'
79
+ require 'webmock/cucumber'
63
80
  ```
64
81
 
65
- ### RSpec
82
+ ### MiniTest
66
83
 
67
- Add the following code to `spec/spec_helper`:
84
+ Add the following code to `test/test_helper`:
68
85
 
69
86
  ```ruby
70
- require 'webmock/rspec'
87
+ require 'webmock/minitest'
71
88
  ```
72
89
 
73
- ### MiniTest
90
+ ### RSpec
74
91
 
75
- Add the following code to `test/test_helper`:
92
+ Add the following code to `spec/spec_helper`:
76
93
 
77
94
  ```ruby
78
- require 'webmock/minitest'
95
+ require 'webmock/rspec'
79
96
  ```
80
97
 
81
- ### Cucumber
98
+ ### Test::Unit
82
99
 
83
- Create a file `features/support/webmock.rb` with the following contents:
100
+ Add the following code to `test/test_helper.rb`
84
101
 
85
102
  ```ruby
86
- require 'webmock/cucumber'
103
+ require 'webmock/test_unit'
87
104
  ```
88
105
 
89
106
  ### Outside a test framework
@@ -97,13 +114,10 @@ include WebMock::API
97
114
  WebMock.enable!
98
115
  ```
99
116
 
100
- ## Examples
101
-
102
-
117
+ # Examples
103
118
 
104
119
  ## Stubbing
105
120
 
106
-
107
121
  ### Stubbed request based on uri only and with the default response
108
122
 
109
123
  ```ruby
@@ -236,6 +250,12 @@ stub_request(:any, /example/)
236
250
  Net::HTTP.get('www.example.com', '/') # ===> Success
237
251
  ```
238
252
 
253
+ ### Matching uris using lambda
254
+
255
+ ```ruby
256
+ stub_request(:any, ->(uri) { true })
257
+ ```
258
+
239
259
  ### Matching uris using RFC 6570 - Basic Example
240
260
 
241
261
  ```ruby
@@ -293,6 +313,12 @@ stub_request(:any, "www.example.com").
293
313
  Net::HTTP.get("www.example.com", '/') # ===> "abc"
294
314
  ```
295
315
 
316
+ Set appropriate Content-Type for HTTParty's `parsed_response`.
317
+
318
+ ```ruby
319
+ stub_request(:any, "www.example.com").to_return body: '{}', headers: {content_type: 'application/json'}
320
+ ```
321
+
296
322
  ### Response with body specified as IO object
297
323
 
298
324
  ```ruby
@@ -873,6 +899,10 @@ end
873
899
 
874
900
  Please submit them here [http://github.com/bblimke/webmock/issues](http://github.com/bblimke/webmock/issues)
875
901
 
902
+ ## Issue triage [![Open Source Helpers](https://www.codetriage.com/bblimke/webmock/badges/users.svg)](https://www.codetriage.com/bblimke/webmock)
903
+
904
+ You can contribute by triaging issues which may include reproducing bug reports or asking for vital information, such as version numbers or reproduction instructions. If you would like to start triaging issues, one easy way to get started is to [subscribe to webmock on CodeTriage](https://www.codetriage.com/bblimke/webmock).
905
+
876
906
  ## Suggestions
877
907
 
878
908
  If you have any suggestions on how to improve WebMock please send an email to the mailing list [groups.google.com/group/webmock-users](http://groups.google.com/group/webmock-users)
@@ -1086,6 +1116,42 @@ People who submitted patches and new features or suggested improvements. Many th
1086
1116
  * Geremia Taglialatela
1087
1117
  * Koichi Sasada
1088
1118
  * Yusuke Endoh
1119
+ * Grey Baker
1120
+ * SoonKhen OwYong
1121
+ * Pavel Valena
1122
+ * Adam Sokolnicki
1123
+ * Jeff Felchner
1124
+ * Eike Send
1125
+ * Claudio Poli
1126
+ * Csaba Apagyi
1127
+ * Frederick Cheung
1128
+ * Fábio D. Batista
1129
+ * Andriy Yanko
1130
+ * y-yagi
1131
+ * Rafael França
1132
+ * George Claghorn
1133
+ * Alex Junger
1134
+ * Orien Madgwick
1135
+ * Andrei Sidorov
1136
+ * Marco Costa
1137
+ * Ryan Davis
1138
+ * Brandur
1139
+ * Samuel Williams
1140
+ * Patrik Ragnarsson
1141
+ * Alex Coomans
1142
+ * Vesa Laakso
1143
+ * John Hawthorn
1144
+ * guppy0356
1145
+ * Thilo Rusche
1146
+ * Andrew Stuntz
1147
+ * Lucas Uyezu
1148
+ * Bruno Sutic
1149
+ * Ryan Kerr
1150
+ * Adam Harwood
1151
+ * Ben Koshy
1152
+ * Jesse Bowes
1153
+ * Marek Kasztelnik
1154
+ * ce07c3
1089
1155
 
1090
1156
  For a full list of contributors you can visit the
1091
1157
  [contributors](https://github.com/bblimke/webmock/contributors) page.