vcr 2.2.5 → 2.3.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/.gitignore +5 -0
- data/.travis.yml +0 -5
- data/Appraisals +9 -0
- data/CHANGELOG.md +21 -0
- data/Gemfile +17 -21
- data/README.md +5 -2
- data/Rakefile +1 -0
- data/features/configuration/hook_into.feature +7 -6
- data/features/configuration/uri_parser.feature +91 -0
- data/features/middleware/faraday.feature +4 -3
- data/features/support/http_lib_filters.rb +2 -3
- data/features/support/vcr_cucumber_helpers.rb +2 -1
- data/features/test_frameworks/cucumber.feature +6 -0
- data/gemfiles/typhoeus-new.gemfile +18 -0
- data/gemfiles/typhoeus-new.gemfile.lock +172 -0
- data/gemfiles/typhoeus-old.gemfile +18 -0
- data/gemfiles/typhoeus-old.gemfile.lock +159 -0
- data/lib/vcr/cassette/migrator.rb +1 -1
- data/lib/vcr/configuration.rb +28 -0
- data/lib/vcr/errors.rb +1 -1
- data/lib/vcr/library_hooks/typhoeus.rb +74 -77
- data/lib/vcr/library_hooks/typhoeus_0.4.rb +99 -0
- data/lib/vcr/middleware/faraday.rb +1 -1
- data/lib/vcr/request_ignorer.rb +2 -2
- data/lib/vcr/request_matcher_registry.rb +8 -3
- data/lib/vcr/structs.rb +8 -1
- data/lib/vcr/test_frameworks/cucumber.rb +1 -1
- data/lib/vcr/version.rb +1 -1
- data/script/ci.sh +8 -1
- data/spec/capture_warnings.rb +10 -0
- data/spec/monkey_patches.rb +21 -3
- data/spec/spec_helper.rb +2 -0
- data/spec/support/http_library_adapters.rb +29 -0
- data/spec/support/limited_uri.rb +30 -0
- data/spec/support/vcr_localhost_server.rb +1 -4
- data/spec/vcr/cassette/http_interaction_list_spec.rb +0 -1
- data/spec/vcr/configuration_spec.rb +15 -1
- data/spec/vcr/library_hooks/typhoeus_0.4_spec.rb +31 -0
- data/spec/vcr/library_hooks/typhoeus_spec.rb +6 -6
- data/spec/vcr/library_hooks/webmock_spec.rb +3 -1
- data/spec/vcr/middleware/faraday_spec.rb +3 -1
- data/spec/vcr/request_matcher_registry_spec.rb +3 -1
- data/spec/vcr/structs_spec.rb +27 -1
- data/spec/vcr/test_frameworks/cucumber_spec.rb +1 -1
- metadata +41 -29
@@ -0,0 +1,18 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source :rubygems
|
4
|
+
|
5
|
+
gem "appraisal"
|
6
|
+
gem "jruby-openssl", :platforms=>:jruby
|
7
|
+
gem "yard"
|
8
|
+
gem "relish", "~> 0.6"
|
9
|
+
gem "fuubar"
|
10
|
+
gem "fuubar-cucumber"
|
11
|
+
gem "redcarpet", "~> 1.17.2"
|
12
|
+
gem "github-markup"
|
13
|
+
gem "ruby-debug", :platforms=>[:mri_18, :jruby]
|
14
|
+
gem "debugger", :platforms=>:mri_19
|
15
|
+
gem "typhoeus", "~> 0.4.2"
|
16
|
+
gem "webmock", "1.8.11"
|
17
|
+
|
18
|
+
gemspec :path=>"../"
|
@@ -0,0 +1,159 @@
|
|
1
|
+
PATH
|
2
|
+
remote: /Users/myron/code/vcr
|
3
|
+
specs:
|
4
|
+
vcr (2.2.5)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: http://rubygems.org/
|
8
|
+
specs:
|
9
|
+
addressable (2.3.2)
|
10
|
+
appraisal (0.4.1)
|
11
|
+
bundler
|
12
|
+
rake
|
13
|
+
archive-tar-minitar (0.5.2)
|
14
|
+
aruba (0.4.11)
|
15
|
+
childprocess (>= 0.2.3)
|
16
|
+
cucumber (>= 1.1.1)
|
17
|
+
ffi (>= 1.0.11)
|
18
|
+
rspec (>= 2.7.0)
|
19
|
+
builder (3.1.4)
|
20
|
+
childprocess (0.3.6)
|
21
|
+
ffi (~> 1.0, >= 1.0.6)
|
22
|
+
columnize (0.3.6)
|
23
|
+
cookiejar (0.3.0)
|
24
|
+
crack (0.3.1)
|
25
|
+
cucumber (1.1.9)
|
26
|
+
builder (>= 2.1.2)
|
27
|
+
diff-lcs (>= 1.1.2)
|
28
|
+
gherkin (~> 2.9.0)
|
29
|
+
json (>= 1.4.6)
|
30
|
+
term-ansicolor (>= 1.0.6)
|
31
|
+
curb (0.8.1)
|
32
|
+
debugger (1.2.1)
|
33
|
+
columnize (>= 0.3.1)
|
34
|
+
debugger-linecache (~> 1.1.1)
|
35
|
+
debugger-ruby_core_source (~> 1.1.4)
|
36
|
+
debugger-linecache (1.1.2)
|
37
|
+
debugger-ruby_core_source (>= 1.1.1)
|
38
|
+
debugger-ruby_core_source (1.1.4)
|
39
|
+
diff-lcs (1.1.3)
|
40
|
+
em-http-request (1.0.3)
|
41
|
+
addressable (>= 2.2.3)
|
42
|
+
cookiejar
|
43
|
+
em-socksify
|
44
|
+
eventmachine (>= 1.0.0.beta.4)
|
45
|
+
http_parser.rb (>= 0.5.3)
|
46
|
+
em-socksify (0.2.1)
|
47
|
+
eventmachine (>= 1.0.0.beta.4)
|
48
|
+
eventmachine (1.0.0)
|
49
|
+
excon (0.16.7)
|
50
|
+
fakeweb (1.3.0)
|
51
|
+
faraday (0.8.4)
|
52
|
+
multipart-post (~> 1.1)
|
53
|
+
ffi (1.1.5)
|
54
|
+
fuubar (1.0.0)
|
55
|
+
rspec (~> 2.0)
|
56
|
+
rspec-instafail (~> 0.2.0)
|
57
|
+
ruby-progressbar (~> 0.0.10)
|
58
|
+
fuubar-cucumber (0.0.15)
|
59
|
+
cucumber (>= 1.0.2)
|
60
|
+
ruby-progressbar (~> 0.0.10)
|
61
|
+
gherkin (2.9.3)
|
62
|
+
json (>= 1.4.6)
|
63
|
+
github-markup (0.7.4)
|
64
|
+
http_parser.rb (0.5.3)
|
65
|
+
httpclient (2.3.0.1)
|
66
|
+
json (1.6.7)
|
67
|
+
linecache (0.46)
|
68
|
+
rbx-require-relative (> 0.0.4)
|
69
|
+
mime-types (1.19)
|
70
|
+
multi_json (1.0.4)
|
71
|
+
multipart-post (1.1.5)
|
72
|
+
patron (0.4.18)
|
73
|
+
rack (1.3.6)
|
74
|
+
rack-protection (1.2.0)
|
75
|
+
rack
|
76
|
+
rake (0.9.2.2)
|
77
|
+
rbx-require-relative (0.0.9)
|
78
|
+
redcarpet (1.17.2)
|
79
|
+
redis (2.2.2)
|
80
|
+
relish (0.6)
|
81
|
+
archive-tar-minitar (>= 0.5.2)
|
82
|
+
json (>= 1.4.6)
|
83
|
+
rest-client (>= 1.6.1)
|
84
|
+
rest-client (1.6.7)
|
85
|
+
mime-types (>= 1.16)
|
86
|
+
rspec (2.11.0)
|
87
|
+
rspec-core (~> 2.11.0)
|
88
|
+
rspec-expectations (~> 2.11.0)
|
89
|
+
rspec-mocks (~> 2.11.0)
|
90
|
+
rspec-core (2.11.1)
|
91
|
+
rspec-expectations (2.11.3)
|
92
|
+
diff-lcs (~> 1.1.3)
|
93
|
+
rspec-instafail (0.2.4)
|
94
|
+
rspec-mocks (2.11.3)
|
95
|
+
ruby-debug (0.10.4)
|
96
|
+
columnize (>= 0.1)
|
97
|
+
ruby-debug-base (~> 0.10.4.0)
|
98
|
+
ruby-debug-base (0.10.4)
|
99
|
+
linecache (>= 0.3)
|
100
|
+
ruby-progressbar (0.0.10)
|
101
|
+
shoulda (2.9.2)
|
102
|
+
simplecov (0.5.4)
|
103
|
+
multi_json (~> 1.0.3)
|
104
|
+
simplecov-html (~> 0.5.3)
|
105
|
+
simplecov-html (0.5.3)
|
106
|
+
sinatra (1.3.3)
|
107
|
+
rack (~> 1.3, >= 1.3.6)
|
108
|
+
rack-protection (~> 1.2)
|
109
|
+
tilt (~> 1.3, >= 1.3.3)
|
110
|
+
term-ansicolor (1.0.7)
|
111
|
+
tilt (1.3.3)
|
112
|
+
timecop (0.3.5)
|
113
|
+
typhoeus (0.4.2)
|
114
|
+
ffi (~> 1.0)
|
115
|
+
mime-types (~> 1.18)
|
116
|
+
webmock (1.8.11)
|
117
|
+
addressable (>= 2.2.7)
|
118
|
+
crack (>= 0.1.7)
|
119
|
+
yajl-ruby (1.1.0)
|
120
|
+
yard (0.8.3)
|
121
|
+
|
122
|
+
PLATFORMS
|
123
|
+
ruby
|
124
|
+
|
125
|
+
DEPENDENCIES
|
126
|
+
appraisal
|
127
|
+
aruba (~> 0.4.11)
|
128
|
+
bundler (>= 1.0.7)
|
129
|
+
cucumber (~> 1.1.4)
|
130
|
+
curb (~> 0.8.0)
|
131
|
+
debugger
|
132
|
+
em-http-request (~> 1.0.2)
|
133
|
+
excon (>= 0.11.0, < 1.0)
|
134
|
+
fakeweb (~> 1.3.0)
|
135
|
+
faraday (~> 0.8)
|
136
|
+
fuubar
|
137
|
+
fuubar-cucumber
|
138
|
+
github-markup
|
139
|
+
httpclient (~> 2.2)
|
140
|
+
jruby-openssl
|
141
|
+
json (~> 1.6.5)
|
142
|
+
multi_json (~> 1.0.3)
|
143
|
+
patron (~> 0.4.15)
|
144
|
+
rack (~> 1.3.6)
|
145
|
+
rake (~> 0.9.2)
|
146
|
+
redcarpet (~> 1.17.2)
|
147
|
+
redis (~> 2.2.2)
|
148
|
+
relish (~> 0.6)
|
149
|
+
rspec (~> 2.11)
|
150
|
+
ruby-debug
|
151
|
+
shoulda (~> 2.9.2)
|
152
|
+
simplecov (~> 0.5.3)
|
153
|
+
sinatra (~> 1.3.2)
|
154
|
+
timecop (~> 0.3.5)
|
155
|
+
typhoeus (~> 0.4.2)
|
156
|
+
vcr!
|
157
|
+
webmock (= 1.8.11)
|
158
|
+
yajl-ruby (~> 1.1.0)
|
159
|
+
yard
|
@@ -75,7 +75,7 @@ module VCR
|
|
75
75
|
end
|
76
76
|
|
77
77
|
def remove_unnecessary_standard_port(interaction)
|
78
|
-
uri =
|
78
|
+
uri = VCR.configuration.uri_parser.parse(interaction.request.uri)
|
79
79
|
if uri.scheme == 'http' && uri.port == 80 ||
|
80
80
|
uri.scheme == 'https' && uri.port == 443
|
81
81
|
uri.port = nil
|
data/lib/vcr/configuration.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'vcr/util/hooks'
|
2
|
+
require 'uri'
|
2
3
|
|
3
4
|
module VCR
|
4
5
|
# Stores the VCR configuration.
|
@@ -123,6 +124,32 @@ module VCR
|
|
123
124
|
!!@allow_http_connections_when_no_cassette
|
124
125
|
end
|
125
126
|
|
127
|
+
# Sets a parser for VCR to use when parsing URIs. The new parser
|
128
|
+
# must implement a method `parse` that returns an instance of the
|
129
|
+
# URI object. This URI object must implement the following
|
130
|
+
# interface:
|
131
|
+
#
|
132
|
+
# * `scheme # => String`
|
133
|
+
# * `host # => String`
|
134
|
+
# * `port # => Fixnum`
|
135
|
+
# * `path # => String`
|
136
|
+
# * `query # => String`
|
137
|
+
# * `#port=`
|
138
|
+
# * `#query=`
|
139
|
+
# * `#to_s # => String`
|
140
|
+
# * `#== # => Boolean`
|
141
|
+
#
|
142
|
+
# The `#==` method must return true if both URI objects represent the
|
143
|
+
# same URI.
|
144
|
+
#
|
145
|
+
# This defaults to `URI` from the ruby standard library.
|
146
|
+
#
|
147
|
+
# @overload uri_parser
|
148
|
+
# @return [#parse] the current URI parser object
|
149
|
+
# @overload uri_parser=
|
150
|
+
# @param value [#parse] sets the uri_parser
|
151
|
+
attr_accessor :uri_parser
|
152
|
+
|
126
153
|
# Registers a request matcher for later use.
|
127
154
|
#
|
128
155
|
# @example
|
@@ -424,6 +451,7 @@ module VCR
|
|
424
451
|
:persist_with => :file_system
|
425
452
|
}
|
426
453
|
|
454
|
+
self.uri_parser = URI
|
427
455
|
self.debug_logger = NullDebugLogger
|
428
456
|
|
429
457
|
register_built_in_hooks
|
data/lib/vcr/errors.rb
CHANGED
@@ -188,7 +188,7 @@ module VCR
|
|
188
188
|
:try_debug_logger => [
|
189
189
|
["If you're surprised VCR is raising this error",
|
190
190
|
"and want insight about how VCR attempted to handle the request,",
|
191
|
-
"you can use the debug_logger
|
191
|
+
"you can use the debug_logger configuration option to log more details"],
|
192
192
|
"https://www.relishapp.com/myronmarston/vcr/v/%s/docs/configuration/debug-logging"
|
193
193
|
]
|
194
194
|
}
|
@@ -2,105 +2,102 @@ require 'vcr/util/version_checker'
|
|
2
2
|
require 'vcr/request_handler'
|
3
3
|
require 'typhoeus'
|
4
4
|
|
5
|
-
|
5
|
+
if Float(Typhoeus::VERSION[/^\d+\.\d+/]) < 0.5
|
6
|
+
require 'vcr/library_hooks/typhoeus_0.4'
|
7
|
+
else
|
8
|
+
VCR::VersionChecker.new('Typhoeus', Typhoeus::VERSION, '0.5.0', '0.5').check_version!
|
6
9
|
|
7
|
-
module VCR
|
8
|
-
|
9
|
-
# @private
|
10
|
-
module Typhoeus
|
10
|
+
module VCR
|
11
|
+
class LibraryHooks
|
11
12
|
# @private
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
module Typhoeus
|
14
|
+
# @private
|
15
|
+
class RequestHandler < ::VCR::RequestHandler
|
16
|
+
attr_reader :request
|
17
|
+
def initialize(request)
|
18
|
+
@request = request
|
19
|
+
request.block_connection = false if VCR.turned_on?
|
20
|
+
end
|
17
21
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
def vcr_request
|
23
|
+
@vcr_request ||= VCR::Request.new \
|
24
|
+
request.options.fetch(:method, :get),
|
25
|
+
request.url,
|
26
|
+
request.options.fetch(:body, ""),
|
27
|
+
request.options.fetch(:headers, {})
|
28
|
+
end
|
25
29
|
|
26
|
-
|
30
|
+
private
|
27
31
|
|
28
|
-
|
29
|
-
|
30
|
-
|
32
|
+
def externally_stubbed?
|
33
|
+
::Typhoeus::Expectation.find_by(request)
|
34
|
+
end
|
31
35
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
+
def set_typed_request_for_after_hook(*args)
|
37
|
+
super
|
38
|
+
request.instance_variable_set(:@__typed_vcr_request, @after_hook_typed_request)
|
39
|
+
end
|
36
40
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
+
def on_unhandled_request
|
42
|
+
invoke_after_request_hook(nil)
|
43
|
+
super
|
44
|
+
end
|
41
45
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
46
|
+
def on_stubbed_by_vcr_request
|
47
|
+
::Typhoeus::Response.new \
|
48
|
+
:http_version => stubbed_response.http_version,
|
49
|
+
:code => stubbed_response.status.code,
|
50
|
+
:status_message => stubbed_response.status.message,
|
51
|
+
:headers => stubbed_response_headers,
|
52
|
+
:body => stubbed_response.body,
|
53
|
+
:mock => true
|
54
|
+
end
|
50
55
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
+
def stubbed_response_headers
|
57
|
+
@stubbed_response_headers ||= {}.tap do |hash|
|
58
|
+
stubbed_response.headers.each do |key, values|
|
59
|
+
hash[key] = values.size == 1 ? values.first : values
|
60
|
+
end if stubbed_response.headers
|
61
|
+
end
|
56
62
|
end
|
57
63
|
end
|
58
|
-
end
|
59
64
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
65
|
+
# @private
|
66
|
+
def self.vcr_response_from(response)
|
67
|
+
VCR::Response.new \
|
68
|
+
VCR::ResponseStatus.new(response.code, response.status_message),
|
69
|
+
response.headers,
|
70
|
+
response.body,
|
71
|
+
response.http_version
|
72
|
+
end
|
68
73
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
74
|
+
::Typhoeus.on_complete do |response|
|
75
|
+
request = response.request
|
76
|
+
unless VCR.library_hooks.disabled?(:typhoeus)
|
77
|
+
vcr_response = vcr_response_from(response)
|
78
|
+
typed_vcr_request = request.send(:remove_instance_variable, :@__typed_vcr_request)
|
73
79
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
80
|
+
unless request.response.mock
|
81
|
+
http_interaction = VCR::HTTPInteraction.new(typed_vcr_request, vcr_response)
|
82
|
+
VCR.record_http_interaction(http_interaction)
|
83
|
+
end
|
78
84
|
|
79
|
-
|
85
|
+
VCR.configuration.invoke_hook(:after_http_request, typed_vcr_request, vcr_response)
|
86
|
+
end
|
80
87
|
end
|
81
|
-
end
|
82
88
|
|
83
|
-
|
84
|
-
|
89
|
+
::Typhoeus.before do |request|
|
90
|
+
if response = VCR::LibraryHooks::Typhoeus::RequestHandler.new(request).handle
|
91
|
+
request.finish(response)
|
92
|
+
else
|
93
|
+
true
|
94
|
+
end
|
95
|
+
end
|
85
96
|
end
|
86
97
|
end
|
87
98
|
end
|
88
99
|
end
|
89
100
|
|
90
|
-
# @private
|
91
|
-
module Typhoeus
|
92
|
-
class << Hydra
|
93
|
-
# ensure HTTP requests are always allowed; VCR takes care of disallowing
|
94
|
-
# them at the appropriate times in its hook
|
95
|
-
def allow_net_connect_with_vcr?(*args)
|
96
|
-
VCR.turned_on? ? true : allow_net_connect_without_vcr?
|
97
|
-
end
|
98
|
-
|
99
|
-
alias allow_net_connect_without_vcr? allow_net_connect?
|
100
|
-
alias allow_net_connect? allow_net_connect_with_vcr?
|
101
|
-
end unless Hydra.respond_to?(:allow_net_connect_with_vcr?)
|
102
|
-
end
|
103
|
-
|
104
101
|
VCR.configuration.after_library_hooks_loaded do
|
105
102
|
# ensure WebMock's Typhoeus adapter does not conflict with us here
|
106
103
|
# (i.e. to double record requests or whatever).
|
@@ -0,0 +1,99 @@
|
|
1
|
+
VCR::VersionChecker.new('Typhoeus', Typhoeus::VERSION, '0.3.2', '0.4').check_version!
|
2
|
+
|
3
|
+
module VCR
|
4
|
+
class LibraryHooks
|
5
|
+
# @private
|
6
|
+
module Typhoeus
|
7
|
+
# @private
|
8
|
+
class RequestHandler < ::VCR::RequestHandler
|
9
|
+
attr_reader :request
|
10
|
+
def initialize(request)
|
11
|
+
@request = request
|
12
|
+
end
|
13
|
+
|
14
|
+
def vcr_request
|
15
|
+
@vcr_request ||= VCR::Request.new \
|
16
|
+
request.method,
|
17
|
+
request.url,
|
18
|
+
request.body,
|
19
|
+
request.headers
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def externally_stubbed?
|
25
|
+
::Typhoeus::Hydra.stubs.detect { |stub| stub.matches?(request) }
|
26
|
+
end
|
27
|
+
|
28
|
+
def set_typed_request_for_after_hook(*args)
|
29
|
+
super
|
30
|
+
request.instance_variable_set(:@__typed_vcr_request, @after_hook_typed_request)
|
31
|
+
end
|
32
|
+
|
33
|
+
def on_unhandled_request
|
34
|
+
invoke_after_request_hook(nil)
|
35
|
+
super
|
36
|
+
end
|
37
|
+
|
38
|
+
def on_stubbed_by_vcr_request
|
39
|
+
::Typhoeus::Response.new \
|
40
|
+
:http_version => stubbed_response.http_version,
|
41
|
+
:code => stubbed_response.status.code,
|
42
|
+
:status_message => stubbed_response.status.message,
|
43
|
+
:headers_hash => stubbed_response_headers,
|
44
|
+
:body => stubbed_response.body
|
45
|
+
end
|
46
|
+
|
47
|
+
def stubbed_response_headers
|
48
|
+
@stubbed_response_headers ||= {}.tap do |hash|
|
49
|
+
stubbed_response.headers.each do |key, values|
|
50
|
+
hash[key] = values.size == 1 ? values.first : values
|
51
|
+
end if stubbed_response.headers
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# @private
|
57
|
+
def self.vcr_response_from(response)
|
58
|
+
VCR::Response.new \
|
59
|
+
VCR::ResponseStatus.new(response.code, response.status_message),
|
60
|
+
response.headers_hash,
|
61
|
+
response.body,
|
62
|
+
response.http_version
|
63
|
+
end
|
64
|
+
|
65
|
+
::Typhoeus::Hydra.after_request_before_on_complete do |request|
|
66
|
+
unless VCR.library_hooks.disabled?(:typhoeus)
|
67
|
+
vcr_response = vcr_response_from(request.response)
|
68
|
+
typed_vcr_request = request.send(:remove_instance_variable, :@__typed_vcr_request)
|
69
|
+
|
70
|
+
unless request.response.mock?
|
71
|
+
http_interaction = VCR::HTTPInteraction.new(typed_vcr_request, vcr_response)
|
72
|
+
VCR.record_http_interaction(http_interaction)
|
73
|
+
end
|
74
|
+
|
75
|
+
VCR.configuration.invoke_hook(:after_http_request, typed_vcr_request, vcr_response)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
::Typhoeus::Hydra.register_stub_finder do |request|
|
80
|
+
VCR::LibraryHooks::Typhoeus::RequestHandler.new(request).handle
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
# @private
|
87
|
+
module Typhoeus
|
88
|
+
class << Hydra
|
89
|
+
# ensure HTTP requests are always allowed; VCR takes care of disallowing
|
90
|
+
# them at the appropriate times in its hook
|
91
|
+
def allow_net_connect_with_vcr?(*args)
|
92
|
+
VCR.turned_on? ? true : allow_net_connect_without_vcr?
|
93
|
+
end
|
94
|
+
|
95
|
+
alias allow_net_connect_without_vcr? allow_net_connect?
|
96
|
+
alias allow_net_connect? allow_net_connect_with_vcr?
|
97
|
+
end unless Hydra.respond_to?(:allow_net_connect_with_vcr?)
|
98
|
+
end
|
99
|
+
|