vcr 3.0.3 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. checksums.yaml +4 -4
  2. data/lib/vcr.rb +18 -1
  3. data/lib/vcr/cassette.rb +11 -3
  4. data/lib/vcr/cassette/persisters/file_system.rb +1 -1
  5. data/lib/vcr/configuration.rb +3 -5
  6. data/lib/vcr/deprecations.rb +0 -62
  7. data/lib/vcr/errors.rb +16 -0
  8. data/lib/vcr/library_hooks/typhoeus.rb +37 -8
  9. data/lib/vcr/middleware/faraday.rb +5 -1
  10. data/lib/vcr/structs.rb +1 -1
  11. data/lib/vcr/util/hooks.rb +1 -0
  12. data/lib/vcr/version.rb +1 -1
  13. metadata +9 -249
  14. data/features/CHANGELOG.md +0 -710
  15. data/features/CONTRIBUTING.md +0 -26
  16. data/features/LICENSE.md +0 -20
  17. data/features/README.md +0 -339
  18. data/features/Upgrade.md +0 -289
  19. data/features/about_these_examples.md +0 -18
  20. data/features/cassettes/allow_unused_http_interactions.feature +0 -100
  21. data/features/cassettes/automatic_re_recording.feature +0 -72
  22. data/features/cassettes/decompress.feature +0 -74
  23. data/features/cassettes/dynamic_erb.feature +0 -100
  24. data/features/cassettes/exclusive.feature +0 -126
  25. data/features/cassettes/format.feature +0 -411
  26. data/features/cassettes/freezing_time.feature +0 -68
  27. data/features/cassettes/naming.feature +0 -28
  28. data/features/cassettes/no_cassette.feature +0 -152
  29. data/features/cassettes/update_content_length_header.feature +0 -112
  30. data/features/configuration/allow_http_connections_when_no_cassette.feature +0 -55
  31. data/features/configuration/cassette_library_dir.feature +0 -31
  32. data/features/configuration/debug_logging.feature +0 -58
  33. data/features/configuration/default_cassette_options.feature +0 -100
  34. data/features/configuration/filter_sensitive_data.feature +0 -153
  35. data/features/configuration/hook_into.feature +0 -172
  36. data/features/configuration/ignore_request.feature +0 -192
  37. data/features/configuration/preserve_exact_body_bytes.feature +0 -108
  38. data/features/configuration/query_parser.feature +0 -84
  39. data/features/configuration/uri_parser.feature +0 -93
  40. data/features/getting_started.md +0 -82
  41. data/features/hooks/after_http_request.feature +0 -58
  42. data/features/hooks/around_http_request.feature +0 -57
  43. data/features/hooks/before_http_request.feature +0 -63
  44. data/features/hooks/before_playback.feature +0 -184
  45. data/features/hooks/before_record.feature +0 -172
  46. data/features/http_libraries/em_http_request.feature +0 -250
  47. data/features/http_libraries/net_http.feature +0 -179
  48. data/features/middleware/faraday.feature +0 -56
  49. data/features/middleware/rack.feature +0 -92
  50. data/features/record_modes/all.feature +0 -82
  51. data/features/record_modes/new_episodes.feature +0 -79
  52. data/features/record_modes/none.feature +0 -72
  53. data/features/record_modes/once.feature +0 -95
  54. data/features/request_matching/README.md +0 -30
  55. data/features/request_matching/body.feature +0 -91
  56. data/features/request_matching/body_as_json.feature +0 -90
  57. data/features/request_matching/custom_matcher.feature +0 -135
  58. data/features/request_matching/headers.feature +0 -85
  59. data/features/request_matching/host.feature +0 -95
  60. data/features/request_matching/identical_request_sequence.feature +0 -89
  61. data/features/request_matching/method.feature +0 -96
  62. data/features/request_matching/path.feature +0 -96
  63. data/features/request_matching/playback_repeats.feature +0 -98
  64. data/features/request_matching/query.feature +0 -97
  65. data/features/request_matching/uri.feature +0 -94
  66. data/features/request_matching/uri_without_param.feature +0 -101
  67. data/features/step_definitions/cli_steps.rb +0 -199
  68. data/features/support/env.rb +0 -46
  69. data/features/support/http_lib_filters.rb +0 -46
  70. data/features/test_frameworks/cucumber.feature +0 -211
  71. data/features/test_frameworks/rspec_macro.feature +0 -81
  72. data/features/test_frameworks/rspec_metadata.feature +0 -150
  73. data/features/test_frameworks/test_unit.feature +0 -49
  74. data/lib/vcr/extensions/net_http_response.rb +0 -36
  75. data/lib/vcr/library_hooks/fakeweb.rb +0 -197
  76. data/spec/acceptance/concurrency_spec.rb +0 -51
  77. data/spec/acceptance/threading_spec.rb +0 -34
  78. data/spec/fixtures/cassette_spec/1_x_cassette.yml +0 -110
  79. data/spec/fixtures/cassette_spec/empty.yml +0 -0
  80. data/spec/fixtures/cassette_spec/example.yml +0 -111
  81. data/spec/fixtures/cassette_spec/with_localhost_requests.yml +0 -111
  82. data/spec/fixtures/fake_example_responses.yml +0 -110
  83. data/spec/fixtures/match_requests_on.yml +0 -187
  84. data/spec/lib/vcr/cassette/erb_renderer_spec.rb +0 -53
  85. data/spec/lib/vcr/cassette/http_interaction_list_spec.rb +0 -295
  86. data/spec/lib/vcr/cassette/migrator_spec.rb +0 -196
  87. data/spec/lib/vcr/cassette/persisters/file_system_spec.rb +0 -75
  88. data/spec/lib/vcr/cassette/persisters_spec.rb +0 -39
  89. data/spec/lib/vcr/cassette/serializers_spec.rb +0 -182
  90. data/spec/lib/vcr/cassette_spec.rb +0 -618
  91. data/spec/lib/vcr/configuration_spec.rb +0 -326
  92. data/spec/lib/vcr/deprecations_spec.rb +0 -85
  93. data/spec/lib/vcr/errors_spec.rb +0 -178
  94. data/spec/lib/vcr/extensions/net_http_response_spec.rb +0 -86
  95. data/spec/lib/vcr/library_hooks/excon_spec.rb +0 -104
  96. data/spec/lib/vcr/library_hooks/fakeweb_spec.rb +0 -169
  97. data/spec/lib/vcr/library_hooks/faraday_spec.rb +0 -68
  98. data/spec/lib/vcr/library_hooks/typhoeus_0.4_spec.rb +0 -36
  99. data/spec/lib/vcr/library_hooks/typhoeus_spec.rb +0 -162
  100. data/spec/lib/vcr/library_hooks/webmock_spec.rb +0 -117
  101. data/spec/lib/vcr/library_hooks_spec.rb +0 -51
  102. data/spec/lib/vcr/middleware/faraday_spec.rb +0 -181
  103. data/spec/lib/vcr/middleware/rack_spec.rb +0 -115
  104. data/spec/lib/vcr/request_ignorer_spec.rb +0 -70
  105. data/spec/lib/vcr/request_matcher_registry_spec.rb +0 -345
  106. data/spec/lib/vcr/structs_spec.rb +0 -732
  107. data/spec/lib/vcr/test_frameworks/cucumber_spec.rb +0 -107
  108. data/spec/lib/vcr/test_frameworks/rspec_spec.rb +0 -94
  109. data/spec/lib/vcr/util/hooks_spec.rb +0 -158
  110. data/spec/lib/vcr/util/internet_connection_spec.rb +0 -37
  111. data/spec/lib/vcr/util/version_checker_spec.rb +0 -31
  112. data/spec/lib/vcr/version_spec.rb +0 -27
  113. data/spec/lib/vcr_spec.rb +0 -354
  114. data/spec/monkey_patches.rb +0 -186
  115. data/spec/spec_helper.rb +0 -63
  116. data/spec/support/configuration_stubbing.rb +0 -8
  117. data/spec/support/cucumber_helpers.rb +0 -39
  118. data/spec/support/fixnum_extension.rb +0 -10
  119. data/spec/support/http_library_adapters.rb +0 -289
  120. data/spec/support/limited_uri.rb +0 -21
  121. data/spec/support/ruby_interpreter.rb +0 -7
  122. data/spec/support/shared_example_groups/excon.rb +0 -63
  123. data/spec/support/shared_example_groups/hook_into_http_library.rb +0 -594
  124. data/spec/support/shared_example_groups/request_hooks.rb +0 -59
  125. data/spec/support/sinatra_app.rb +0 -86
  126. data/spec/support/vcr_localhost_server.rb +0 -76
  127. data/spec/support/vcr_stub_helpers.rb +0 -17
@@ -1,162 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "Typhoeus hook", :with_monkey_patches => :typhoeus, :if => (RUBY_INTERPRETER == :mri) do
4
- after(:each) do
5
- ::Typhoeus::Expectation.clear
6
- end
7
-
8
- def disable_real_connections
9
- ::Typhoeus::Config.block_connection = true
10
- ::Typhoeus::Errors::NoStub
11
- end
12
-
13
- def enable_real_connections
14
- ::Typhoeus::Config.block_connection = false
15
- end
16
-
17
- def directly_stub_request(method, url, response_body)
18
- response = ::Typhoeus::Response.new(:code => 200, :body => response_body)
19
- ::Typhoeus.stub(url, :method => method).and_return(response)
20
- end
21
-
22
- it_behaves_like 'a hook into an HTTP library', :typhoeus, 'typhoeus'
23
-
24
- describe "VCR.configuration.after_library_hooks_loaded hook" do
25
- it 'disables the webmock typhoeus adapter so it does not conflict with our typhoeus hook' do
26
- expect(::WebMock::HttpLibAdapters::TyphoeusAdapter).to receive(:disable!)
27
- $typhoeus_after_loaded_hook.conditionally_invoke
28
- end
29
- end
30
-
31
- context 'when there are nested hydra queues' do
32
- def make_requests
33
- VCR.use_cassette("nested") do
34
- response_1 = response_2 = nil
35
-
36
- hydra = Typhoeus::Hydra.new
37
- request = Typhoeus::Request.new("http://localhost:#{VCR::SinatraApp.port}/")
38
-
39
- request.on_success do |r1|
40
- response_1 = r1
41
-
42
- nested = Typhoeus::Request.new("http://localhost:#{VCR::SinatraApp.port}/foo")
43
- nested.on_success { |r2| response_2 = r2 }
44
-
45
- hydra.queue(nested)
46
- end
47
-
48
- hydra.queue(request)
49
- hydra.run
50
-
51
- return body_for(response_1), body_for(response_2)
52
- end
53
- end
54
-
55
- def body_for(response)
56
- return :no_response if response.nil?
57
- response.body
58
- end
59
-
60
- it 'records and plays back properly' do
61
- recorded = make_requests
62
- played_back = make_requests
63
-
64
- expect(played_back).to eq(recorded)
65
- end
66
- end
67
-
68
- context "when used with a typhoeus-based faraday connection" do
69
- let(:base_url) { "http://localhost:#{VCR::SinatraApp.port}" }
70
-
71
- let(:conn) do
72
- Faraday.new(:url => base_url) do |faraday|
73
- faraday.adapter :typhoeus
74
- end
75
- end
76
-
77
- def get_response
78
- # Ensure faraday hook doesn't handle the request.
79
- VCR.library_hooks.exclusively_enabled(:typhoeus) do
80
- VCR.use_cassette("faraday") do
81
- conn.get("/")
82
- end
83
- end
84
- end
85
-
86
- it 'records and replays headers correctly' do
87
- recorded = get_response
88
- played_back = get_response
89
-
90
- expect(played_back.headers).to eq(recorded.headers)
91
- end
92
- end
93
-
94
- context 'when a request is made with a hash for the POST body' do
95
- def make_request
96
- VCR.use_cassette("hash_body") do
97
- Typhoeus::Request.post(
98
- "http://localhost:#{VCR::SinatraApp.port}/return-request-body",
99
- :body => { :foo => "17" }
100
- )
101
- end
102
- end
103
-
104
- it 'records and replays correctly' do
105
- recorded = make_request
106
- played_back = make_request
107
-
108
- expect(recorded.body).to eq("foo=17")
109
- expect(played_back.body).to eq(recorded.body)
110
- end
111
- end
112
-
113
- context '#effective_url' do
114
- ResponseValues = Struct.new(:status, :body, :effective_url)
115
-
116
- def url_for(path)
117
- "http://localhost:#{VCR::SinatraApp.port}#{path}"
118
- end
119
-
120
- def make_single_request(path, options = {})
121
- VCR.use_cassette('single') do |cassette|
122
- response = Typhoeus::Request.new(url_for(path), options).run
123
-
124
- yield cassette if block_given?
125
-
126
- ResponseValues.new(
127
- response.code,
128
- response.body,
129
- response.effective_url
130
- )
131
- end
132
- end
133
-
134
- it 'records and plays back properly' do
135
- recorded = make_single_request('/')
136
- played_back = make_single_request('/')
137
-
138
- expect(recorded.effective_url).to eq(url_for('/'))
139
- expect(played_back).to eq(recorded)
140
- end
141
-
142
- it 'falls back to the request url when it was not recorded (e.g. on VCR <= 2.5.0)' do
143
- make_single_request('/') do |cassette|
144
- cassette.new_recorded_interactions.each { |i| i.response.adapter_metadata.clear }
145
- end
146
-
147
- played_back = make_single_request('/')
148
- expect(played_back.effective_url).to eq(url_for('/'))
149
- end
150
-
151
- context "when following redirects" do
152
- it 'records and plays back properly' do
153
- recorded = make_single_request('/redirect-to-root', :followlocation => true)
154
- played_back = make_single_request('/redirect-to-root', :followlocation => true)
155
-
156
- expect(recorded.effective_url).to eq(url_for('/'))
157
- expect(played_back).to eq(recorded)
158
- end
159
- end
160
- end
161
- end
162
-
@@ -1,117 +0,0 @@
1
- require 'spec_helper'
2
- require 'support/shared_example_groups/excon'
3
-
4
- describe "WebMock hook", :with_monkey_patches => :webmock do
5
- after(:each) do
6
- ::WebMock.reset!
7
- end
8
-
9
- def disable_real_connections(options = {})
10
- ::WebMock.disable_net_connect!(options)
11
- ::WebMock::NetConnectNotAllowedError
12
- end
13
-
14
- def enable_real_connections
15
- ::WebMock.allow_net_connect!
16
- end
17
-
18
- def directly_stub_request(method, url, response_body)
19
- ::WebMock.stub_request(method, url).to_return(:body => response_body)
20
- end
21
-
22
- describe "our WebMock.after_request hook" do
23
- let(:webmock_request) { ::WebMock::RequestSignature.new(:get, "http://foo.com/", :body => "", :headers => {}) }
24
- let(:webmock_response) { ::WebMock::Response.new(:body => 'OK', :status => [200, '']) }
25
-
26
- def run_after_request_callback
27
- ::WebMock::CallbackRegistry.invoke_callbacks(
28
- { :real_request => true },
29
- webmock_request,
30
- webmock_response)
31
- end
32
-
33
- it 'removes the @__typed_vcr_request instance variable so as not to pollute the webmock object' do
34
- request = VCR::Request::Typed.new(VCR::Request, :ignored?)
35
- webmock_request.instance_variable_set(:@__typed_vcr_request, request)
36
-
37
- run_after_request_callback
38
- expect(webmock_request.instance_variables.map(&:to_sym)).not_to include(:@__typed_vcr_request)
39
- end
40
-
41
- context "when there'ss a bug and the request does not have the @__typed_vcr_request in the after_request callbacks" do
42
- let(:warner) { VCR::LibraryHooks::WebMock }
43
- before { allow(warner).to receive(:warn) }
44
-
45
- it 'records the HTTP interaction properly' do
46
- expect(VCR).to receive(:record_http_interaction) do |i|
47
- expect(i.request.uri).to eq("http://foo.com/")
48
- expect(i.response.body).to eq("OK")
49
- end
50
-
51
- run_after_request_callback
52
- end
53
-
54
- it 'invokes the after_http_request hook with an :unknown request' do
55
- request = nil
56
- VCR.configuration.after_http_request do |req, res|
57
- request = req
58
- end
59
-
60
- run_after_request_callback
61
- expect(request.uri).to eq("http://foo.com/")
62
- expect(request.type).to eq(:unknown)
63
- end
64
-
65
- it 'prints a warning' do
66
- expect(warner).to receive(:warn).at_least(:once).with(/bug.*after_request/)
67
-
68
- run_after_request_callback
69
- end
70
- end
71
- end
72
-
73
- http_libs = %w[net/http patron httpclient em-http-request curb typhoeus excon]
74
- http_libs.each do |lib|
75
- other = []
76
- other << :status_message_not_exposed if lib == 'excon'
77
- it_behaves_like 'a hook into an HTTP library', :webmock, lib, *other do
78
- if lib == 'net/http'
79
- def normalize_request_headers(headers)
80
- headers.merge(DEFAULT_REQUEST_HEADERS)
81
- end
82
- end
83
- end
84
-
85
- http_lib_unsupported = (RUBY_INTERPRETER != :mri && lib =~ /(typhoeus|curb|patron|em-http)/)
86
-
87
- adapter_module = HTTP_LIBRARY_ADAPTERS.fetch(lib)
88
- describe "using #{adapter_module.http_library_name}", :unless => http_lib_unsupported do
89
- include adapter_module
90
-
91
- let!(:request_url) { "http://localhost:#{VCR::SinatraApp.port}/foo" }
92
-
93
- context 'when real connections are disabled and VCR is turned off' do
94
- it 'can allow connections to localhost' do
95
- VCR.turn_off!
96
- disable_real_connections(:allow_localhost => true)
97
-
98
- expect {
99
- make_http_request(:get, request_url)
100
- }.to_not raise_error
101
- end
102
-
103
- it 'can allow connections to matching urls' do
104
- VCR.turn_off!
105
- disable_real_connections(:allow => /foo/)
106
-
107
- expect {
108
- make_http_request(:get, request_url)
109
- }.to_not raise_error
110
- end
111
- end
112
- end
113
- end
114
-
115
- it_behaves_like "Excon streaming"
116
- end
117
-
@@ -1,51 +0,0 @@
1
- require 'vcr/library_hooks'
2
-
3
- module VCR
4
- describe LibraryHooks do
5
- describe '#disabled?' do
6
- it 'returns false by default for any argument given' do
7
- expect(subject.disabled?(:foo)).to be false
8
- expect(subject.disabled?(:bar)).to be false
9
- end
10
-
11
- context 'when a library hook is exclusively enabled' do
12
- it 'returns false for the exclusively enabled hook' do
13
- faraday_disabled = nil
14
-
15
- subject.exclusively_enabled :faraday do
16
- faraday_disabled = subject.disabled?(:faraday)
17
- end
18
-
19
- expect(faraday_disabled).to eq(false)
20
- end
21
-
22
- it 'returns true for every other argument given' do
23
- foo_disabled = bar_disabled = nil
24
-
25
- subject.exclusively_enabled :faraday do
26
- foo_disabled = subject.disabled?(:foo)
27
- bar_disabled = subject.disabled?(:bar)
28
- end
29
-
30
- expect(foo_disabled).to be true
31
- expect(bar_disabled).to be true
32
- end
33
- end
34
- end
35
-
36
- describe '#exclusively_enabled' do
37
- it 'restores all hook to being enabled when the block completes' do
38
- subject.exclusively_enabled(:faraday) { }
39
- expect(subject.disabled?(:foo)).to be false
40
- expect(subject.disabled?(:faraday)).to be false
41
- end
42
-
43
- it 'restores all hooks to being enabled when the block completes, even if there is an error' do
44
- subject.exclusively_enabled(:faraday) { raise "boom" } rescue
45
- expect(subject.disabled?(:foo)).to be false
46
- expect(subject.disabled?(:faraday)).to be false
47
- end
48
- end
49
- end
50
- end
51
-
@@ -1,181 +0,0 @@
1
- require 'spec_helper'
2
- require 'vcr/library_hooks/faraday'
3
-
4
- describe VCR::Middleware::Faraday do
5
- http_libs = %w[ typhoeus net_http patron ]
6
- http_libs.each do |lib|
7
- it_behaves_like 'a hook into an HTTP library', :faraday, "faraday (w/ #{lib})",
8
- :status_message_not_exposed,
9
- :does_not_support_rotating_responses
10
- end
11
-
12
- context 'when performing a multipart upload' do
13
- let(:connection) do
14
- ::Faraday.new("http://localhost:#{VCR::SinatraApp.port}/") do |b|
15
- b.request :multipart
16
- end
17
- end
18
-
19
- def self.test_recording
20
- it 'records the request body correctly' do
21
- payload = { :file => Faraday::UploadIO.new(__FILE__, 'text/plain') }
22
-
23
- expect(VCR).to receive(:record_http_interaction) do |i|
24
- expect(i.request.headers['Content-Type'].first).to include("multipart")
25
- expect(i.request.body).to include(File.read(__FILE__))
26
- end
27
-
28
- VCR.use_cassette("upload") do
29
- connection.post '/files', payload
30
- end
31
- end
32
- end
33
-
34
- context 'when the net_http adapter is used' do
35
- before { connection.builder.adapter :net_http }
36
- test_recording
37
- end
38
-
39
- context 'when no adapter is used' do
40
- test_recording
41
- end
42
- end
43
-
44
- context 'when extending the response body with an extension module' do
45
- let(:connection) { ::Faraday.new("http://localhost:#{VCR::SinatraApp.port}/") }
46
-
47
- def process_response(response)
48
- response.body.extend Module.new { attr_accessor :_response }
49
- response.body._response = response
50
- end
51
-
52
- it 'does not record the body extensions to the cassette' do
53
- 3.times do |i|
54
- VCR.use_cassette("hack", :record => :new_episodes) do
55
- response = connection.get("/foo")
56
- process_response(response)
57
-
58
- # Do something different after the first time to
59
- # ensure new interactions are added to an existing
60
- # cassette.
61
- if i > 1
62
- response = connection.get("/")
63
- process_response(response)
64
- end
65
- end
66
- end
67
-
68
- contents = VCR::Cassette.new("hack").send(:raw_cassette_bytes)
69
- expect(contents).not_to include("ruby/object:Faraday::Response")
70
- end
71
- end
72
-
73
- context 'when making parallel requests' do
74
- include VCRStubHelpers
75
- let(:connection) { ::Faraday.new { |b| b.adapter :typhoeus } }
76
- let(:request_url) { "http://localhost:#{VCR::SinatraApp.port}/" }
77
-
78
- it 'works correctly with multiple parallel requests' do
79
- recorded, played_back = [1, 2].map do
80
- responses = []
81
-
82
- VCR.use_cassette("multiple_parallel") do
83
- connection.in_parallel do
84
- responses << connection.get(request_url)
85
- responses << connection.get(request_url)
86
- end
87
- end
88
-
89
- responses.map(&:body)
90
- end
91
-
92
- # there should be no blanks
93
- expect(recorded.select { |r| r.to_s == '' }).to eq([])
94
- expect(played_back).to eq(recorded)
95
- end
96
-
97
- shared_examples_for "exclusive library hook" do
98
- def make_request
99
- connection.in_parallel { connection.get(request_url) }
100
- end
101
-
102
- it 'makes the faraday middleware exclusively enabled for the duration of the request' do
103
- expect(VCR.library_hooks).not_to be_disabled(:fakeweb)
104
-
105
- hook_called = false
106
- VCR.configuration.after_http_request do
107
- hook_called = true
108
- expect(VCR.library_hooks).to be_disabled(:fakeweb)
109
- end
110
-
111
- make_request
112
- expect(VCR.library_hooks).not_to be_disabled(:fakeweb)
113
- expect(hook_called).to be true
114
- end
115
- end
116
-
117
- context 'for an ignored request' do
118
- before(:each) { VCR.configuration.ignore_request { true } }
119
- it_behaves_like "exclusive library hook"
120
- end
121
-
122
- context 'for a stubbed request' do
123
- it_behaves_like "exclusive library hook" do
124
- before(:each) do
125
- stub_requests([http_interaction(request_url)], [:method, :uri])
126
- end
127
- end
128
- end
129
-
130
- context "when another adapter is exclusive" do
131
- it 'still makes requests properly' do
132
- response = VCR.library_hooks.exclusively_enabled(:typhoeus) do
133
- Faraday.get("http://localhost:#{VCR::SinatraApp.port}/")
134
- end
135
-
136
- expect(response.body).to eq("GET to root")
137
- end
138
- end
139
-
140
- context 'for a recorded request' do
141
- let!(:inserted_cassette) { VCR.insert_cassette('new_cassette') }
142
- before(:each) { expect(VCR).to receive(:record_http_interaction) }
143
- it_behaves_like "exclusive library hook"
144
- end
145
-
146
- context 'for a disallowed request' do
147
- it_behaves_like "exclusive library hook" do
148
- undef make_request
149
- def make_request
150
- expect {
151
- connection.in_parallel { connection.get(request_url) }
152
- }.to raise_error(VCR::Errors::UnhandledHTTPRequestError)
153
- end
154
- end
155
- end
156
-
157
- it_behaves_like "request hooks", :faraday, :recordable do
158
- let!(:inserted_cassette) { VCR.insert_cassette('new_cassette') }
159
-
160
- undef make_request
161
- def make_request(disabled = false)
162
- response = nil
163
- connection.in_parallel do
164
- response = connection.get(request_url)
165
- end
166
- response
167
- end
168
-
169
- it 'can be used to eject a cassette after the request is recorded' do
170
- VCR.configuration.after_http_request { |request| VCR.eject_cassette }
171
-
172
- expect(VCR).to receive(:record_http_interaction) do |interaction|
173
- expect(VCR.current_cassette).to be(inserted_cassette)
174
- end
175
-
176
- make_request
177
- expect(VCR.current_cassette).to be_nil
178
- end
179
- end
180
- end if defined?(::Typhoeus)
181
- end