webmock 3.5.1 → 3.11.2

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 +223 -0
  4. data/README.md +94 -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 +33 -15
  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 +51 -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 +10 -2
  48. metadata +53 -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: 6784322094783787fdf1a995a18c703ef70e0dccf59cbc8ad69cf086b11feb7b
4
+ data.tar.gz: e2e0fc45a8e44efdcfbfd777a733790b6d1762311f62762065e602c281daff09
5
5
  SHA512:
6
- metadata.gz: 724c7ae8d9ba016537b0e45968e9ae8d820458be36106a24eb7374ccc09cb3e06fb0df5968014443b4f94ba16349dad4643bf683cab17c4af1b32ae9c5b1112d
7
- data.tar.gz: 440171bbd565223139df3aec8581378497cfe359dc766c4b5e8dcf0b865a6c6adf759029d551b3ffac084d7b9683401baabd0b713930017563b7d79cb09320e8
6
+ metadata.gz: 277b355a34e07d6bf1c97692fe3c64c54518b16705fc9a6135b1b2000d0cd9e72256e88858e4b4c345cac9cda5d8edf2163f94e69ace05bbc6e75986eae0794d
7
+ data.tar.gz: ba7f43ee30745e58fa57d7030bce1bde7c334b719707642eadcce8963c0e52b88932913ed2a3115b59b6e3477830c87f9646961b7c5bdd95a95086ff733833c8
data/.travis.yml CHANGED
@@ -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
+
data/CHANGELOG.md CHANGED
@@ -1,5 +1,228 @@
1
1
  # Changelog
2
2
 
3
+ # 3.11.2
4
+
5
+ * Fix for Manticore streaming mode
6
+
7
+ Thanks to [Oleksiy Kovyrin](https://github.com/kovyrin)
8
+
9
+ # 3.11.1
10
+
11
+ * Compatibility with async-http 0.54+
12
+
13
+ Thanks to [Jun Jiang](https://github.com/jasl)
14
+
15
+ # 3.11.0
16
+
17
+ * Added support for `features` in http.rb adapter.
18
+
19
+ Thanks to [Carl (ce07c3)](https://github.com/ce07c3)
20
+
21
+ # 3.10.0
22
+
23
+ * Added option to global stubs to have lower priority than local stubs.
24
+
25
+ WebMock.globally_stub_request(:after_local_stubs) do
26
+ { body: "global stub body" }
27
+ end
28
+
29
+ stub_request(:get, "www.example.com").to_return(body: 'non-global stub body')
30
+
31
+ expect(http_request(:get, "http://www.example.com/").body).to eq("non-global stub body")
32
+
33
+ Thanks to [Marek Kasztelnik](https://github.com/mkasztelnik)
34
+
35
+ # 3.9.5
36
+
37
+ * Prevent overwriting `teardown` method in Test::Unit
38
+
39
+ Thanks to [Jesse Bowes](https://github.com/jessebs)
40
+
41
+ # 3.9.4
42
+
43
+ * More intuitive error message when stubbed response body was provided as Hash
44
+
45
+ Thanks to [Ben Koshy](https://github.com/BKSpurgeon)
46
+
47
+ # 3.9.3
48
+
49
+ * Make httpclient_adapter thread-safe
50
+
51
+ Thanks to [Adam Harwood](https://github.com/adam-harwood)
52
+
53
+ # 3.9.2
54
+
55
+ * Made global stubs thread-safe
56
+
57
+ Thanks to [Adam Harwood](https://github.com/adam-harwood)
58
+
59
+ # 3.9.1
60
+
61
+ * Fixed support for passing `URI` objects as second argument of `stub_request`
62
+
63
+ Thanks to [Ryan Kerr](https://github.com/leboshi)
64
+
65
+ ## 3.9.0
66
+
67
+ * Allow using a "callable" (like a proc) as URI pattern
68
+
69
+ stub_request(:any, ->(uri) { true })
70
+
71
+ Thanks to [John Hawthorn](https://github.com/jhawthorn)
72
+
73
+ * Added stubbed IO on stubbed socket in Net::HTTP adapter.
74
+
75
+ Thanks to [Thilo Rusche](https://github.com/trusche)
76
+
77
+ * When 'webmock/rspec' is required, reset WebMock after all after(:each/example) hooks
78
+
79
+ Thanks to [Andrew Stuntz](https://github.com/drews256)
80
+
81
+ * Fixed `net_connect_allowed?` when invoked with no arguments, when there were any allowed URIs passed to `disable_net_connect?`.
82
+
83
+ Thanks to [Lucas Uyezu](https://github.com/lucasuyezu)
84
+
85
+ * Fixed async-http adapter which caused Async::HTTP::Client or Async::HTTP::Internet to hang and never return a response.
86
+
87
+ Thanks to [Bruno Sutic](https://github.com/bruno-) and [Samuel Williams](https://github.com/ioquatix)
88
+
89
+ * Fixed warning when using async-http adapter
90
+
91
+ Thanks to [Bruno Sutic](https://github.com/bruno-)
92
+
93
+ * Dropped support for Ruby 2.3 - EOL date: 2019-03-31
94
+
95
+ * Dropped support for Ruby 2.4 - EOL date: 2020-03-31
96
+
97
+ * 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.
98
+
99
+ Thanks to [Rafael França](https://github.com/rafaelfranca) and [guppy0356](https://github.com/guppy0356)
100
+
101
+ ## 3.8.3
102
+
103
+ * Fixed problem introduced in version 3.4.2, which caused matching against Addressable::Template representing host part of the URI to raise an error.
104
+
105
+ Thanks to [Vesa Laakso](https://github.com/valscion)
106
+
107
+ ## 3.8.2
108
+
109
+ * Support correct encoding parameter for HTTP.rb 2.x and earlier
110
+
111
+ Thanks to [Alex Coomans](https://github.com/drcapulet)
112
+
113
+ ## 3.8.1
114
+
115
+ * Added support for mocking non-ASCII bodies when making requests with HTTP.rb
116
+
117
+ Thanks to [Patrik Ragnarsson](https://github.com/dentarg)
118
+
119
+ ## 3.8.0
120
+
121
+ * Fixed options handling when initialising Async::HTTP::Client
122
+
123
+ Thanks to [Samuel Williams](https://github.com/ioquatix)
124
+
125
+ * Ruby 2.7 support.
126
+
127
+ Thanks to [Ryan Davis](https://github.com/zenspider) and [Brandur](https://github.com/brandur)
128
+
129
+ ## 3.7.6
130
+
131
+ * Suppressed keyword argument warnings in Ruby 2.7 in async-http adapter.
132
+
133
+ Thanks to [Koichi ITO](https://github.com/koic)
134
+
135
+ ## 3.7.5
136
+
137
+ * Suppress Excon warning generated by extra key
138
+
139
+ Thanks to [Marco Costa](https://github.com/marcotc)
140
+
141
+ ## 3.7.4
142
+
143
+ * Resetting memoized response fields in Curb adapter.
144
+
145
+ Thanks to [Andrei Sidorov](https://github.com/heretge)
146
+
147
+ ## 3.7.3
148
+
149
+ * Fix for http.rb. Allow passing an output buffer to HTTP::Response::Body#readpartial
150
+
151
+ Thanks to [George Claghorn](https://github.com/georgeclaghorn)
152
+
153
+ * Fixed Manticore adapter to invoke Manticore failure handler on stubbed timeout
154
+
155
+ Thanks to [Alex Junger](https://github.com/alexJunger)
156
+
157
+ * Added project metadata to the gemspec
158
+
159
+ Thanks to [Orien Madgwick](https://github.com/orien)
160
+
161
+ ## 3.7.2
162
+
163
+ * Fixed handling of non UTF-8 encoded urls
164
+
165
+ Thanks to [Rafael França](https://github.com/rafaelfranca)
166
+
167
+ * Fixed "shadowing outer local variable" warning
168
+
169
+ Thanks to [y-yagi](https://github.com/y-yagi)
170
+
171
+ ## 3.7.1
172
+
173
+ * Fixed Async::HTTP::Client adapter code to not cause Ruby warning
174
+
175
+ Thanks to [y-yagi](https://github.com/y-yagi)
176
+
177
+ ## 3.7.0
178
+
179
+ * Support for Async::HTTP::Client
180
+
181
+ Thanks to [Andriy Yanko](https://github.com/ayanko)
182
+
183
+ ## 3.6.2
184
+
185
+ * Fixed Patron adapter to handle HTTP/2 status line.
186
+
187
+ Thanks to [Fábio D. Batista](https://github.com/fabiob)
188
+
189
+ ## 3.6.1
190
+
191
+ * Fixed issue with matching Addressable::Template without a period in the domain
192
+
193
+ Thanks to [Eike Send](https://github.com/eikes)
194
+
195
+ * Support for `write_timeout` in Net::HTTP
196
+
197
+ Thanks to [Claudio Poli](https://github.com/masterkain)
198
+
199
+ * Fixed issue with handling urls with ":80" or ":443" in the path.
200
+
201
+ Thanks to [Csaba Apagyi](https://github.com/thisismydesign) for reporting and to [Frederick Cheung](https://github.com/fcheung) for fixing the issue.
202
+
203
+ ## 3.6.0
204
+
205
+ * Compatibility with the latest version of hashdiff gem, with constant changed from HashDiff to Hashdiff
206
+
207
+ Thanks to [Jeff Felchner](https://github.com/jfelchner)
208
+
209
+ * Added a hint to the error message raised when `with` method is called without args or a block.
210
+
211
+ Thanks to [Adam Sokolnicki](https://github.com/asok)
212
+
213
+ * Resetting configured HTTP method in Curb adapter after each request
214
+
215
+ Thanks to [tiendo1011](https://github.com/tiendo1011)
216
+
217
+ * Added `WebMock.enable_net_connect!` as an alias for `WebMock.allow_net_connect!`
218
+ and `WebMock.disallow_net_connect!` as an alias for `WebMock.disable_net_connect!`
219
+
220
+ Thanks to [SoonKhen OwYong](https://github.com/owyongsk)
221
+
222
+ * Fixed handling of empty arrays as query params when using Faraday
223
+
224
+ Thanks to [Ryan Moret](https://github.com/rcmoret)
225
+
3
226
  ## 3.5.1
4
227
 
5
228
  * 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,44 @@ 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
1155
+ * Jun Jiang
1156
+ * Oleksiy Kovyrin
1089
1157
 
1090
1158
  For a full list of contributors you can visit the
1091
1159
  [contributors](https://github.com/bblimke/webmock/contributors) page.