webmock 1.20.4 → 1.21.0
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/.travis.yml +1 -0
- data/CHANGELOG.md +16 -0
- data/README.md +76 -37
- data/lib/webmock.rb +1 -1
- data/lib/webmock/http_lib_adapters/curb_adapter.rb +1 -1
- data/lib/webmock/http_lib_adapters/{http_gem → http_rb}/client.rb +1 -1
- data/lib/webmock/http_lib_adapters/{http_gem → http_rb}/request.rb +0 -0
- data/lib/webmock/http_lib_adapters/{http_gem → http_rb}/response.rb +2 -2
- data/lib/webmock/http_lib_adapters/http_rb/streamer.rb +25 -0
- data/lib/webmock/http_lib_adapters/{http_gem → http_rb}/webmock.rb +1 -1
- data/lib/webmock/http_lib_adapters/http_rb_adapter.rb +37 -0
- data/lib/webmock/request_pattern.rb +1 -1
- data/lib/webmock/request_stub.rb +3 -0
- data/lib/webmock/version.rb +1 -1
- data/spec/acceptance/{http_gem/http_gem_spec.rb → http_rb/http_rb_spec.rb} +3 -3
- data/spec/acceptance/{http_gem/http_gem_spec_helper.rb → http_rb/http_rb_spec_helper.rb} +2 -2
- data/webmock.gemspec +4 -2
- metadata +20 -20
- data/lib/webmock/http_lib_adapters/http_gem/streamer.rb +0 -13
- data/lib/webmock/http_lib_adapters/http_gem_adapter.rb +0 -38
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,21 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 1.21.0
|
4
|
+
|
5
|
+
* Support for http.rb >= 0.8.0
|
6
|
+
|
7
|
+
Thanks to [Zachary Anker](https://github.com/zanker), [Aleksey V. Zapparov](https://github.com/ixti)
|
8
|
+
|
9
|
+
* Support for http.rb 0.7.0
|
10
|
+
|
11
|
+
Thanks to [Mattias Putman](https://github.com/challengee)
|
12
|
+
|
13
|
+
* Added support for RSpec3-like `and_return`, `and_raise`, `and_timeout` sytnax.
|
14
|
+
|
15
|
+
Thanks to [Franky Wahl](https://github.com/frankywahl)
|
16
|
+
|
17
|
+
* Restricted Curb support up to version 0.8.6. WebMock specs fail with Curb 0.8.7.
|
18
|
+
|
3
19
|
## 1.20.4
|
4
20
|
|
5
21
|
* Fixed support for `hash_including` matcher in RSpec 3
|
data/README.md
CHANGED
@@ -36,11 +36,12 @@ Supported Ruby Interpreters
|
|
36
36
|
* MRI 1.9.3
|
37
37
|
* MRI 2.0.0
|
38
38
|
* MRI 2.1
|
39
|
+
* MRI 2.2
|
39
40
|
* REE 1.8.7
|
40
41
|
* JRuby
|
41
42
|
* Rubinius
|
42
43
|
|
43
|
-
##Installation
|
44
|
+
## Installation
|
44
45
|
|
45
46
|
gem install webmock
|
46
47
|
|
@@ -109,7 +110,8 @@ Net::HTTP.get("www.example.com", "/") # ===> Success
|
|
109
110
|
### Stubbing requests based on method, uri, body and headers
|
110
111
|
|
111
112
|
```ruby
|
112
|
-
stub_request(:post, "www.example.com").
|
113
|
+
stub_request(:post, "www.example.com").
|
114
|
+
with(:body => "abc", :headers => { 'Content-Length' => 3 })
|
113
115
|
|
114
116
|
uri = URI.parse("http://www.example.com/")
|
115
117
|
req = Net::HTTP::Post.new(uri.path)
|
@@ -124,7 +126,8 @@ end # ===> Success
|
|
124
126
|
|
125
127
|
```ruby
|
126
128
|
stub_request(:post, "www.example.com").
|
127
|
-
with(:body => /^.*world$/, :headers => {"Content-Type" => /image\/.+/}).
|
129
|
+
with(:body => /^.*world$/, :headers => {"Content-Type" => /image\/.+/}).
|
130
|
+
to_return(:body => "abc")
|
128
131
|
|
129
132
|
uri = URI.parse('http://www.example.com/')
|
130
133
|
req = Net::HTTP::Post.new(uri.path)
|
@@ -164,7 +167,8 @@ RestClient.post('www.example.com', "data[a]=1&data[b]=five&x=1",
|
|
164
167
|
### Matching custom request headers
|
165
168
|
|
166
169
|
```ruby
|
167
|
-
stub_request(:any, "www.example.com").
|
170
|
+
stub_request(:any, "www.example.com").
|
171
|
+
with(:headers=>{ 'Header-Name' => 'Header-Value' })
|
168
172
|
|
169
173
|
uri = URI.parse('http://www.example.com/')
|
170
174
|
req = Net::HTTP::Post.new(uri.path)
|
@@ -178,7 +182,8 @@ end # ===> Success
|
|
178
182
|
### Matching multiple headers with the same name
|
179
183
|
|
180
184
|
```ruby
|
181
|
-
stub_request(:get, 'www.example.com').
|
185
|
+
stub_request(:get, 'www.example.com').
|
186
|
+
with(:headers => {'Accept' => ['image/jpeg', 'image/png'] })
|
182
187
|
|
183
188
|
req = Net::HTTP::Get.new("/")
|
184
189
|
req['Accept'] = ['image/png']
|
@@ -198,11 +203,11 @@ RestClient.post('www.example.com', 'abc') # ===> Success
|
|
198
203
|
```ruby
|
199
204
|
stub_request(:get, "user:pass@www.example.com")
|
200
205
|
|
201
|
-
Net::HTTP.start('www.example.com')
|
206
|
+
Net::HTTP.start('www.example.com') do |http|
|
202
207
|
req = Net::HTTP::Get.new('/')
|
203
208
|
req.basic_auth 'user', 'pass'
|
204
209
|
http.request(req)
|
205
|
-
|
210
|
+
end # ===> Success
|
206
211
|
```
|
207
212
|
|
208
213
|
### Matching uris using regular expressions
|
@@ -225,10 +230,12 @@ Net::HTTP.get('www.example.com', '/webmock/') # ===> Success
|
|
225
230
|
### Matching uris using RFC 6570 - Advanced Example
|
226
231
|
|
227
232
|
```ruby
|
228
|
-
uri_template =
|
233
|
+
uri_template =
|
234
|
+
Addressable::Template.new "www.example.com/thing/{id}.json{?x,y,z}{&other*}"
|
229
235
|
stub_request(:any, uri_template)
|
230
236
|
|
231
|
-
Net::HTTP.get('www.example.com',
|
237
|
+
Net::HTTP.get('www.example.com',
|
238
|
+
'/thing/5.json?x=1&y=2&z=3&anyParam=4') # ===> Success
|
232
239
|
```
|
233
240
|
|
234
241
|
### Matching query params using hash
|
@@ -242,7 +249,8 @@ RestClient.get("http://www.example.com/?a[]=b&a[]=c") # ===> Success
|
|
242
249
|
### Matching partial query params using hash
|
243
250
|
|
244
251
|
```ruby
|
245
|
-
stub_request(:get, "www.example.com").
|
252
|
+
stub_request(:get, "www.example.com").
|
253
|
+
with(:query => hash_including({"a" => ["b", "c"]}))
|
246
254
|
|
247
255
|
RestClient.get("http://www.example.com/?a[]=b&a[]=c&x=1") # ===> Success
|
248
256
|
```
|
@@ -251,7 +259,8 @@ RestClient.get("http://www.example.com/?a[]=b&a[]=c&x=1") # ===> Success
|
|
251
259
|
|
252
260
|
```ruby
|
253
261
|
stub_request(:any, "www.example.com").
|
254
|
-
to_return(:body => "abc", :status => 200,
|
262
|
+
to_return(:body => "abc", :status => 200,
|
263
|
+
:headers => { 'Content-Length' => 3 })
|
255
264
|
|
256
265
|
Net::HTTP.get("www.example.com", '/') # ===> "abc"
|
257
266
|
```
|
@@ -270,10 +279,12 @@ Net::HTTP.get('www.example.com', '/') # ===> "abc\n"
|
|
270
279
|
### Response with custom status message
|
271
280
|
|
272
281
|
```ruby
|
273
|
-
stub_request(:any, "www.example.com").
|
282
|
+
stub_request(:any, "www.example.com").
|
283
|
+
to_return(:status => [500, "Internal Server Error"])
|
274
284
|
|
275
285
|
req = Net::HTTP::Get.new("/")
|
276
|
-
Net::HTTP.start("www.example.com") {|http| http.request(req)}.
|
286
|
+
Net::HTTP.start("www.example.com") { |http| http.request(req) }.
|
287
|
+
message # ===> "Internal Server Error"
|
277
288
|
```
|
278
289
|
|
279
290
|
### Replaying raw responses recorded with `curl -is`
|
@@ -380,7 +391,8 @@ RestClient.post('www.example.net', 'abc') # ===> RestClient::RequestTimeout
|
|
380
391
|
### Multiple responses for repeated requests
|
381
392
|
|
382
393
|
```ruby
|
383
|
-
stub_request(:get, "www.example.com").
|
394
|
+
stub_request(:get, "www.example.com").
|
395
|
+
to_return({:body => "abc"}, {:body => "def"})
|
384
396
|
Net::HTTP.get('www.example.com', '/') # ===> "abc\n"
|
385
397
|
Net::HTTP.get('www.example.com', '/') # ===> "def\n"
|
386
398
|
|
@@ -504,11 +516,13 @@ res = Net::HTTP.start(uri.host, uri.port) do |http|
|
|
504
516
|
end
|
505
517
|
|
506
518
|
assert_requested :post, "http://www.example.com",
|
507
|
-
:headers => {'Content-Length' => 3}, :body => "abc",
|
519
|
+
:headers => {'Content-Length' => 3}, :body => "abc",
|
520
|
+
:times => 1 # ===> Success
|
508
521
|
|
509
522
|
assert_not_requested :get, "http://www.something.com" # ===> Success
|
510
523
|
|
511
|
-
assert_requested(:post, "http://www.example.com",
|
524
|
+
assert_requested(:post, "http://www.example.com",
|
525
|
+
:times => 1) { |req| req.body == "abc" }
|
512
526
|
```
|
513
527
|
|
514
528
|
### Expecting real (not stubbed) requests
|
@@ -535,7 +549,7 @@ assert_not_requested(stub_post)
|
|
535
549
|
|
536
550
|
|
537
551
|
### Setting expectations in RSpec on `WebMock` module
|
538
|
-
This style is borrowed from [fakeweb-matcher](http://github.com/
|
552
|
+
This style is borrowed from [fakeweb-matcher](http://github.com/pat/fakeweb-matcher)
|
539
553
|
|
540
554
|
```ruby
|
541
555
|
require 'webmock/rspec'
|
@@ -545,30 +559,35 @@ expect(WebMock).to have_requested(:get, "www.example.com").
|
|
545
559
|
|
546
560
|
expect(WebMock).not_to have_requested(:get, "www.something.com")
|
547
561
|
|
548
|
-
expect(WebMock).to have_requested(:post, "www.example.com").
|
562
|
+
expect(WebMock).to have_requested(:post, "www.example.com").
|
563
|
+
with { |req| req.body == "abc" }
|
549
564
|
# Note that the block with `do ... end` instead of curly brackets won't work!
|
550
565
|
# Why? See this comment https://github.com/bblimke/webmock/issues/174#issuecomment-34908908
|
551
566
|
|
552
|
-
expect(WebMock).to have_requested(:get, "www.example.com").
|
567
|
+
expect(WebMock).to have_requested(:get, "www.example.com").
|
568
|
+
with(:query => {"a" => ["b", "c"]})
|
553
569
|
|
554
570
|
expect(WebMock).to have_requested(:get, "www.example.com").
|
555
571
|
with(:query => hash_including({"a" => ["b", "c"]}))
|
556
572
|
|
557
573
|
expect(WebMock).to have_requested(:get, "www.example.com").
|
558
|
-
with(:body => {"a" => ["b", "c"]},
|
574
|
+
with(:body => {"a" => ["b", "c"]},
|
575
|
+
:headers => {'Content-Type' => 'application/json'})
|
559
576
|
```
|
560
577
|
|
561
578
|
### Setting expectations in RSpec with `a_request`
|
562
579
|
|
563
580
|
```ruby
|
564
581
|
expect(a_request(:post, "www.example.com").
|
565
|
-
with(:body => "abc", :headers => {'Content-Length' => 3})).
|
582
|
+
with(:body => "abc", :headers => {'Content-Length' => 3})).
|
583
|
+
to have_been_made.once
|
566
584
|
|
567
585
|
expect(a_request(:post, "www.something.com")).to have_been_made.times(3)
|
568
586
|
|
569
587
|
expect(a_request(:post, "www.something.com")).to have_been_made.at_least_once
|
570
588
|
|
571
|
-
expect(a_request(:post, "www.something.com")).
|
589
|
+
expect(a_request(:post, "www.something.com")).
|
590
|
+
to have_been_made.at_least_times(3)
|
572
591
|
|
573
592
|
expect(a_request(:post, "www.something.com")).to have_been_made.at_most_twice
|
574
593
|
|
@@ -576,15 +595,18 @@ expect(a_request(:post, "www.something.com")).to have_been_made.at_most_times(3)
|
|
576
595
|
|
577
596
|
expect(a_request(:any, "www.example.com")).not_to have_been_made
|
578
597
|
|
579
|
-
expect(a_request(:post, "www.example.com").with { |req| req.body == "abc" }).
|
598
|
+
expect(a_request(:post, "www.example.com").with { |req| req.body == "abc" }).
|
599
|
+
to have_been_made
|
580
600
|
|
581
|
-
expect(a_request(:get, "www.example.com").with(:query => {"a" => ["b", "c"]})).
|
601
|
+
expect(a_request(:get, "www.example.com").with(:query => {"a" => ["b", "c"]})).
|
602
|
+
to have_been_made
|
582
603
|
|
583
604
|
expect(a_request(:get, "www.example.com").
|
584
605
|
with(:query => hash_including({"a" => ["b", "c"]}))).to have_been_made
|
585
606
|
|
586
607
|
expect(a_request(:post, "www.example.com").
|
587
|
-
with(:body => {"a" => ["b", "c"]},
|
608
|
+
with(:body => {"a" => ["b", "c"]},
|
609
|
+
:headers => {'Content-Type' => 'application/json'})).to have_been_made
|
588
610
|
```
|
589
611
|
|
590
612
|
### Setting expectations in RSpec on the stub
|
@@ -614,21 +636,28 @@ assert_not_requested :get, "www.example.com" # ===> Success
|
|
614
636
|
## Disabling and enabling WebMock or only some http client adapters
|
615
637
|
|
616
638
|
```ruby
|
617
|
-
|
618
|
-
WebMock.disable!
|
619
|
-
|
620
|
-
|
639
|
+
# Disable WebMock (all adapters)
|
640
|
+
WebMock.disable!
|
641
|
+
|
642
|
+
# Disable WebMock for all libs except Net::HTTP
|
643
|
+
WebMock.disable!(:except => [:net_http])
|
644
|
+
|
645
|
+
# Enable WebMock (all adapters)
|
646
|
+
WebMock.enable!
|
647
|
+
|
648
|
+
# Enable WebMock for all libs except Patron
|
649
|
+
WebMock.enable!(:except => [:patron])
|
621
650
|
```
|
622
651
|
|
623
652
|
## Matching requests
|
624
653
|
|
625
654
|
An executed request matches stubbed request if it passes following criteria:
|
626
655
|
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
656
|
+
- When request URI matches stubbed request URI string, Regexp pattern or RFC 6570 URI Template
|
657
|
+
- And request method is the same as stubbed request method or stubbed request method is :any
|
658
|
+
- And request body is the same as stubbed request body or stubbed request body is not specified
|
659
|
+
- And request headers match stubbed request headers, or stubbed request headers match a subset of request headers, or stubbed request headers are not specified
|
660
|
+
- And request matches provided block or block is not provided
|
632
661
|
|
633
662
|
## Precedence of stubs
|
634
663
|
|
@@ -694,7 +723,7 @@ or these
|
|
694
723
|
|
695
724
|
If you provide Regexp to match URI, WebMock will try to match it against every valid form of the same url.
|
696
725
|
|
697
|
-
I.e `/.*my
|
726
|
+
I.e `/.*my path.*/` will match `www.example.com/my%20path` because it is equivalent of `www.example.com/my path`
|
698
727
|
|
699
728
|
## Matching with URI Templates
|
700
729
|
|
@@ -728,7 +757,7 @@ To record your application's real HTTP interactions and replay them later in tes
|
|
728
757
|
|
729
758
|
## Request callbacks
|
730
759
|
|
731
|
-
####WebMock can invoke callbacks stubbed or real requests:
|
760
|
+
#### WebMock can invoke callbacks stubbed or real requests:
|
732
761
|
|
733
762
|
```ruby
|
734
763
|
WebMock.after_request do |request_signature, response|
|
@@ -739,7 +768,8 @@ end
|
|
739
768
|
#### invoke callbacks for real requests only and except requests made with Patron
|
740
769
|
|
741
770
|
```ruby
|
742
|
-
WebMock.after_request(:except => [:patron],
|
771
|
+
WebMock.after_request(:except => [:patron],
|
772
|
+
:real_requests_only => true) do |req_signature, response|
|
743
773
|
puts "Request #{req_signature} was made and #{response} was returned"
|
744
774
|
end
|
745
775
|
```
|
@@ -934,6 +964,15 @@ People who submitted patches and new features or suggested improvements. Many th
|
|
934
964
|
* Dan Buettner
|
935
965
|
* Sven Riedel
|
936
966
|
* Mark Lorenz
|
967
|
+
* Dávid Kovács
|
968
|
+
* fishermand46
|
969
|
+
* Franky Wahl
|
970
|
+
* ChaYoung You
|
971
|
+
* Simon Russell
|
972
|
+
* Steve Mitchell
|
973
|
+
* Mattias Putman
|
974
|
+
* Zachary Anker
|
975
|
+
|
937
976
|
|
938
977
|
For a full list of contributors you can visit the
|
939
978
|
[contributors](https://github.com/bblimke/webmock/contributors) page.
|
data/lib/webmock.rb
CHANGED
@@ -40,7 +40,7 @@ require 'webmock/api'
|
|
40
40
|
require 'webmock/http_lib_adapters/http_lib_adapter_registry'
|
41
41
|
require 'webmock/http_lib_adapters/http_lib_adapter'
|
42
42
|
require 'webmock/http_lib_adapters/net_http'
|
43
|
-
require 'webmock/http_lib_adapters/
|
43
|
+
require 'webmock/http_lib_adapters/http_rb_adapter'
|
44
44
|
require 'webmock/http_lib_adapters/httpclient_adapter'
|
45
45
|
require 'webmock/http_lib_adapters/patron_adapter'
|
46
46
|
require 'webmock/http_lib_adapters/curb_adapter'
|
File without changes
|
@@ -3,7 +3,7 @@ module HTTP
|
|
3
3
|
def to_webmock
|
4
4
|
webmock_response = ::WebMock::Response.new
|
5
5
|
|
6
|
-
webmock_response.status = [status, reason]
|
6
|
+
webmock_response.status = [status.to_i, reason]
|
7
7
|
webmock_response.body = body.to_s
|
8
8
|
webmock_response.headers = headers.to_h
|
9
9
|
|
@@ -11,7 +11,7 @@ module HTTP
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def self.from_webmock(webmock_response, request_signature = nil)
|
14
|
-
status = webmock_response.status.first
|
14
|
+
status = Status.new(webmock_response.status.first)
|
15
15
|
headers = webmock_response.headers || {}
|
16
16
|
body = Body.new Streamer.new webmock_response.body
|
17
17
|
uri = URI request_signature.uri.to_s if request_signature
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module HTTP
|
2
|
+
class Response
|
3
|
+
class Streamer
|
4
|
+
def initialize(str)
|
5
|
+
@io = StringIO.new str
|
6
|
+
end
|
7
|
+
|
8
|
+
def readpartial(size = nil)
|
9
|
+
unless size
|
10
|
+
if defined?(HTTP::Client::BUFFER_SIZE)
|
11
|
+
size = HTTP::Client::BUFFER_SIZE
|
12
|
+
elsif defined?(HTTP::Connection::BUFFER_SIZE)
|
13
|
+
size = HTTP::Connection::BUFFER_SIZE
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
@io.read size
|
18
|
+
end
|
19
|
+
|
20
|
+
def sequence_id
|
21
|
+
-1
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
begin
|
2
|
+
require "http"
|
3
|
+
rescue LoadError
|
4
|
+
# HTTP gem not found
|
5
|
+
end
|
6
|
+
|
7
|
+
if defined?(HTTP) && defined?(HTTP::VERSION)
|
8
|
+
WebMock::VersionChecker.new("HTTP Gem", HTTP::VERSION, "0.6.0").check_version!
|
9
|
+
|
10
|
+
module WebMock
|
11
|
+
module HttpLibAdapters
|
12
|
+
class HttpRbAdapter < HttpLibAdapter
|
13
|
+
adapter_for :http_rb
|
14
|
+
|
15
|
+
class << self
|
16
|
+
def enable!
|
17
|
+
@enabled = true
|
18
|
+
end
|
19
|
+
|
20
|
+
def disable!
|
21
|
+
@enabled = false
|
22
|
+
end
|
23
|
+
|
24
|
+
def enabled?
|
25
|
+
@enabled
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
require "webmock/http_lib_adapters/http_rb/client"
|
33
|
+
require "webmock/http_lib_adapters/http_rb/request"
|
34
|
+
require "webmock/http_lib_adapters/http_rb/response"
|
35
|
+
require "webmock/http_lib_adapters/http_rb/streamer"
|
36
|
+
require "webmock/http_lib_adapters/http_rb/webmock"
|
37
|
+
end
|
@@ -137,7 +137,7 @@ module WebMock
|
|
137
137
|
else
|
138
138
|
# WebMock checks the query, Addressable checks everything else
|
139
139
|
WebMock::Util::URI.variations_of_uri_as_strings(uri.omit(:query)).any? { |u| @pattern.match(u) } &&
|
140
|
-
|
140
|
+
@query_params == WebMock::Util::QueryMapper.query_to_values(uri.query)
|
141
141
|
end
|
142
142
|
end
|
143
143
|
|
data/lib/webmock/request_stub.rb
CHANGED
@@ -22,6 +22,7 @@ module WebMock
|
|
22
22
|
end
|
23
23
|
self
|
24
24
|
end
|
25
|
+
alias_method :and_return, :to_return
|
25
26
|
|
26
27
|
def to_rack(app, options={})
|
27
28
|
@responses_sequences << ResponsesSequence.new([RackResponse.new(app)])
|
@@ -33,11 +34,13 @@ module WebMock
|
|
33
34
|
})
|
34
35
|
self
|
35
36
|
end
|
37
|
+
alias_method :and_raise, :to_raise
|
36
38
|
|
37
39
|
def to_timeout
|
38
40
|
@responses_sequences << ResponsesSequence.new([ResponseFactory.response_for(:should_timeout => true)])
|
39
41
|
self
|
40
42
|
end
|
43
|
+
alias_method :and_timeout, :to_timeout
|
41
44
|
|
42
45
|
def response
|
43
46
|
if @responses_sequences.empty?
|
data/lib/webmock/version.rb
CHANGED
@@ -2,10 +2,10 @@
|
|
2
2
|
|
3
3
|
require "spec_helper"
|
4
4
|
require "acceptance/webmock_shared"
|
5
|
-
require "acceptance/
|
5
|
+
require "acceptance/http_rb/http_rb_spec_helper"
|
6
6
|
|
7
|
-
describe "HTTP
|
8
|
-
include
|
7
|
+
describe "HTTP.rb" do
|
8
|
+
include HttpRbSpecHelper
|
9
9
|
|
10
10
|
include_examples "with WebMock", :no_status_message
|
11
11
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require "ostruct"
|
2
2
|
|
3
|
-
module
|
3
|
+
module HttpRbSpecHelper
|
4
4
|
def http_request(method, uri, options = {})
|
5
5
|
response = HTTP.request(method, normalize_uri(uri), options)
|
6
6
|
|
@@ -21,7 +21,7 @@ module HttpGemSpecHelper
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def http_library
|
24
|
-
:
|
24
|
+
:http_rb
|
25
25
|
end
|
26
26
|
|
27
27
|
def normalize_uri(uri)
|
data/webmock.gemspec
CHANGED
@@ -18,13 +18,15 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.add_dependency 'addressable', '>= 2.3.6'
|
19
19
|
s.add_dependency 'crack', '>=0.3.2'
|
20
20
|
|
21
|
+
patron_version = (RUBY_VERSION <= '1.8.7') ? '0.4.18' : '>= 0.4.18'
|
22
|
+
|
21
23
|
s.add_development_dependency 'rspec', '>= 3.1.0'
|
22
24
|
s.add_development_dependency 'http', '>= 0.6.0'
|
23
25
|
s.add_development_dependency 'httpclient', '>= 2.2.4'
|
24
|
-
s.add_development_dependency
|
26
|
+
s.add_development_dependency('patron', patron_version) unless RUBY_PLATFORM =~ /java/
|
25
27
|
s.add_development_dependency 'em-http-request', '>= 1.0.2'
|
26
28
|
s.add_development_dependency 'em-synchrony', '>= 1.0.0' if RUBY_VERSION >= "1.9"
|
27
|
-
s.add_development_dependency 'curb', '
|
29
|
+
s.add_development_dependency 'curb', '<= 0.8.6' unless RUBY_PLATFORM =~ /java/
|
28
30
|
s.add_development_dependency 'typhoeus', '>= 0.5.0' unless RUBY_PLATFORM =~ /java/
|
29
31
|
s.add_development_dependency 'excon', '>= 0.27.5'
|
30
32
|
s.add_development_dependency 'minitest', '~> 5.0.0'
|
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: 67
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 1.
|
8
|
+
- 21
|
9
|
+
- 0
|
10
|
+
version: 1.21.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:
|
18
|
+
date: 2015-03-28 23:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -103,7 +103,7 @@ dependencies:
|
|
103
103
|
version_requirements: &id006 !ruby/object:Gem::Requirement
|
104
104
|
none: false
|
105
105
|
requirements:
|
106
|
-
- - "
|
106
|
+
- - "="
|
107
107
|
- !ruby/object:Gem::Version
|
108
108
|
hash: 43
|
109
109
|
segments:
|
@@ -135,14 +135,14 @@ dependencies:
|
|
135
135
|
version_requirements: &id008 !ruby/object:Gem::Requirement
|
136
136
|
none: false
|
137
137
|
requirements:
|
138
|
-
- -
|
138
|
+
- - <=
|
139
139
|
- !ruby/object:Gem::Version
|
140
|
-
hash:
|
140
|
+
hash: 51
|
141
141
|
segments:
|
142
142
|
- 0
|
143
143
|
- 8
|
144
|
-
-
|
145
|
-
version: 0.8.
|
144
|
+
- 6
|
145
|
+
version: 0.8.6
|
146
146
|
prerelease: false
|
147
147
|
requirement: *id008
|
148
148
|
name: curb
|
@@ -242,14 +242,14 @@ files:
|
|
242
242
|
- lib/webmock/http_lib_adapters/em_http_request/em_http_request_1_x.rb
|
243
243
|
- lib/webmock/http_lib_adapters/em_http_request_adapter.rb
|
244
244
|
- lib/webmock/http_lib_adapters/excon_adapter.rb
|
245
|
-
- lib/webmock/http_lib_adapters/http_gem/client.rb
|
246
|
-
- lib/webmock/http_lib_adapters/http_gem/request.rb
|
247
|
-
- lib/webmock/http_lib_adapters/http_gem/response.rb
|
248
|
-
- lib/webmock/http_lib_adapters/http_gem/streamer.rb
|
249
|
-
- lib/webmock/http_lib_adapters/http_gem/webmock.rb
|
250
|
-
- lib/webmock/http_lib_adapters/http_gem_adapter.rb
|
251
245
|
- lib/webmock/http_lib_adapters/http_lib_adapter.rb
|
252
246
|
- lib/webmock/http_lib_adapters/http_lib_adapter_registry.rb
|
247
|
+
- lib/webmock/http_lib_adapters/http_rb/client.rb
|
248
|
+
- lib/webmock/http_lib_adapters/http_rb/request.rb
|
249
|
+
- lib/webmock/http_lib_adapters/http_rb/response.rb
|
250
|
+
- lib/webmock/http_lib_adapters/http_rb/streamer.rb
|
251
|
+
- lib/webmock/http_lib_adapters/http_rb/webmock.rb
|
252
|
+
- lib/webmock/http_lib_adapters/http_rb_adapter.rb
|
253
253
|
- lib/webmock/http_lib_adapters/httpclient_adapter.rb
|
254
254
|
- lib/webmock/http_lib_adapters/net_http.rb
|
255
255
|
- lib/webmock/http_lib_adapters/net_http_response.rb
|
@@ -291,8 +291,8 @@ files:
|
|
291
291
|
- spec/acceptance/em_http_request/em_http_request_spec_helper.rb
|
292
292
|
- spec/acceptance/excon/excon_spec.rb
|
293
293
|
- spec/acceptance/excon/excon_spec_helper.rb
|
294
|
-
- spec/acceptance/
|
295
|
-
- spec/acceptance/
|
294
|
+
- spec/acceptance/http_rb/http_rb_spec.rb
|
295
|
+
- spec/acceptance/http_rb/http_rb_spec_helper.rb
|
296
296
|
- spec/acceptance/httpclient/httpclient_spec.rb
|
297
297
|
- spec/acceptance/httpclient/httpclient_spec_helper.rb
|
298
298
|
- spec/acceptance/net_http/net_http_shared.rb
|
@@ -386,8 +386,8 @@ test_files:
|
|
386
386
|
- spec/acceptance/em_http_request/em_http_request_spec_helper.rb
|
387
387
|
- spec/acceptance/excon/excon_spec.rb
|
388
388
|
- spec/acceptance/excon/excon_spec_helper.rb
|
389
|
-
- spec/acceptance/
|
390
|
-
- spec/acceptance/
|
389
|
+
- spec/acceptance/http_rb/http_rb_spec.rb
|
390
|
+
- spec/acceptance/http_rb/http_rb_spec_helper.rb
|
391
391
|
- spec/acceptance/httpclient/httpclient_spec.rb
|
392
392
|
- spec/acceptance/httpclient/httpclient_spec_helper.rb
|
393
393
|
- spec/acceptance/net_http/net_http_shared.rb
|
@@ -1,38 +0,0 @@
|
|
1
|
-
begin
|
2
|
-
require "http"
|
3
|
-
__http_gem_found__ = true
|
4
|
-
rescue LoadError
|
5
|
-
__http_gem_found__ = false
|
6
|
-
end
|
7
|
-
|
8
|
-
if __http_gem_found__
|
9
|
-
WebMock::VersionChecker.new("HTTP Gem", HTTP::VERSION, "0.6.0").check_version!
|
10
|
-
|
11
|
-
module WebMock
|
12
|
-
module HttpLibAdapters
|
13
|
-
class HttpGemAdapter < HttpLibAdapter
|
14
|
-
adapter_for :http_gem
|
15
|
-
|
16
|
-
class << self
|
17
|
-
def enable!
|
18
|
-
@enabled = true
|
19
|
-
end
|
20
|
-
|
21
|
-
def disable!
|
22
|
-
@enabled = false
|
23
|
-
end
|
24
|
-
|
25
|
-
def enabled?
|
26
|
-
@enabled
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
require "webmock/http_lib_adapters/http_gem/client"
|
34
|
-
require "webmock/http_lib_adapters/http_gem/request"
|
35
|
-
require "webmock/http_lib_adapters/http_gem/response"
|
36
|
-
require "webmock/http_lib_adapters/http_gem/streamer"
|
37
|
-
require "webmock/http_lib_adapters/http_gem/webmock"
|
38
|
-
end
|