vcr 3.0.2 → 6.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (140) hide show
  1. checksums.yaml +5 -5
  2. data/lib/vcr.rb +33 -1
  3. data/lib/vcr/cassette.rb +47 -12
  4. data/lib/vcr/cassette/http_interaction_list.rb +14 -9
  5. data/lib/vcr/cassette/migrator.rb +0 -5
  6. data/lib/vcr/cassette/persisters/file_system.rb +9 -1
  7. data/lib/vcr/cassette/serializers/compressed.rb +2 -2
  8. data/lib/vcr/cassette/serializers/json.rb +7 -7
  9. data/lib/vcr/cassette/serializers/psych.rb +3 -1
  10. data/lib/vcr/cassette/serializers/yaml.rb +3 -1
  11. data/lib/vcr/configuration.rb +20 -8
  12. data/lib/vcr/deprecations.rb +0 -62
  13. data/lib/vcr/errors.rb +17 -12
  14. data/lib/vcr/library_hooks/excon.rb +8 -0
  15. data/lib/vcr/library_hooks/typhoeus.rb +37 -8
  16. data/lib/vcr/linked_cassette.rb +4 -4
  17. data/lib/vcr/middleware/faraday.rb +10 -1
  18. data/lib/vcr/request_ignorer.rb +4 -1
  19. data/lib/vcr/request_matcher_registry.rb +1 -1
  20. data/lib/vcr/structs.rb +48 -32
  21. data/lib/vcr/test_frameworks/cucumber.rb +4 -4
  22. data/lib/vcr/test_frameworks/rspec.rb +12 -3
  23. data/lib/vcr/util/hooks.rb +1 -0
  24. data/lib/vcr/util/internet_connection.rb +15 -21
  25. data/lib/vcr/version.rb +1 -1
  26. metadata +36 -263
  27. data/features/CHANGELOG.md +0 -1
  28. data/features/CONTRIBUTING.md +0 -1
  29. data/features/LICENSE.md +0 -1
  30. data/features/README.md +0 -1
  31. data/features/Upgrade.md +0 -1
  32. data/features/about_these_examples.md +0 -18
  33. data/features/cassettes/allow_unused_http_interactions.feature +0 -100
  34. data/features/cassettes/automatic_re_recording.feature +0 -72
  35. data/features/cassettes/decompress.feature +0 -74
  36. data/features/cassettes/dynamic_erb.feature +0 -100
  37. data/features/cassettes/exclusive.feature +0 -126
  38. data/features/cassettes/format.feature +0 -411
  39. data/features/cassettes/freezing_time.feature +0 -68
  40. data/features/cassettes/naming.feature +0 -28
  41. data/features/cassettes/no_cassette.feature +0 -152
  42. data/features/cassettes/update_content_length_header.feature +0 -112
  43. data/features/configuration/allow_http_connections_when_no_cassette.feature +0 -55
  44. data/features/configuration/cassette_library_dir.feature +0 -31
  45. data/features/configuration/debug_logging.feature +0 -58
  46. data/features/configuration/default_cassette_options.feature +0 -100
  47. data/features/configuration/filter_sensitive_data.feature +0 -153
  48. data/features/configuration/hook_into.feature +0 -172
  49. data/features/configuration/ignore_request.feature +0 -192
  50. data/features/configuration/preserve_exact_body_bytes.feature +0 -108
  51. data/features/configuration/query_parser.feature +0 -84
  52. data/features/configuration/uri_parser.feature +0 -93
  53. data/features/getting_started.md +0 -82
  54. data/features/hooks/after_http_request.feature +0 -58
  55. data/features/hooks/around_http_request.feature +0 -57
  56. data/features/hooks/before_http_request.feature +0 -63
  57. data/features/hooks/before_playback.feature +0 -184
  58. data/features/hooks/before_record.feature +0 -172
  59. data/features/http_libraries/em_http_request.feature +0 -250
  60. data/features/http_libraries/net_http.feature +0 -179
  61. data/features/middleware/faraday.feature +0 -56
  62. data/features/middleware/rack.feature +0 -92
  63. data/features/record_modes/all.feature +0 -82
  64. data/features/record_modes/new_episodes.feature +0 -79
  65. data/features/record_modes/none.feature +0 -72
  66. data/features/record_modes/once.feature +0 -95
  67. data/features/request_matching/README.md +0 -30
  68. data/features/request_matching/body.feature +0 -91
  69. data/features/request_matching/body_as_json.feature +0 -90
  70. data/features/request_matching/custom_matcher.feature +0 -135
  71. data/features/request_matching/headers.feature +0 -85
  72. data/features/request_matching/host.feature +0 -95
  73. data/features/request_matching/identical_request_sequence.feature +0 -89
  74. data/features/request_matching/method.feature +0 -96
  75. data/features/request_matching/path.feature +0 -96
  76. data/features/request_matching/playback_repeats.feature +0 -98
  77. data/features/request_matching/query.feature +0 -97
  78. data/features/request_matching/uri.feature +0 -94
  79. data/features/request_matching/uri_without_param.feature +0 -101
  80. data/features/step_definitions/cli_steps.rb +0 -199
  81. data/features/support/env.rb +0 -46
  82. data/features/support/http_lib_filters.rb +0 -46
  83. data/features/test_frameworks/cucumber.feature +0 -211
  84. data/features/test_frameworks/rspec_macro.feature +0 -81
  85. data/features/test_frameworks/rspec_metadata.feature +0 -150
  86. data/features/test_frameworks/test_unit.feature +0 -49
  87. data/lib/vcr/extensions/net_http_response.rb +0 -36
  88. data/lib/vcr/library_hooks/fakeweb.rb +0 -197
  89. data/spec/acceptance/concurrency_spec.rb +0 -51
  90. data/spec/acceptance/threading_spec.rb +0 -34
  91. data/spec/fixtures/cassette_spec/1_x_cassette.yml +0 -110
  92. data/spec/fixtures/cassette_spec/empty.yml +0 -0
  93. data/spec/fixtures/cassette_spec/example.yml +0 -111
  94. data/spec/fixtures/cassette_spec/with_localhost_requests.yml +0 -111
  95. data/spec/fixtures/fake_example_responses.yml +0 -110
  96. data/spec/fixtures/match_requests_on.yml +0 -187
  97. data/spec/lib/vcr/cassette/erb_renderer_spec.rb +0 -53
  98. data/spec/lib/vcr/cassette/http_interaction_list_spec.rb +0 -295
  99. data/spec/lib/vcr/cassette/migrator_spec.rb +0 -196
  100. data/spec/lib/vcr/cassette/persisters/file_system_spec.rb +0 -75
  101. data/spec/lib/vcr/cassette/persisters_spec.rb +0 -39
  102. data/spec/lib/vcr/cassette/serializers_spec.rb +0 -182
  103. data/spec/lib/vcr/cassette_spec.rb +0 -618
  104. data/spec/lib/vcr/configuration_spec.rb +0 -326
  105. data/spec/lib/vcr/deprecations_spec.rb +0 -85
  106. data/spec/lib/vcr/errors_spec.rb +0 -178
  107. data/spec/lib/vcr/extensions/net_http_response_spec.rb +0 -86
  108. data/spec/lib/vcr/library_hooks/excon_spec.rb +0 -104
  109. data/spec/lib/vcr/library_hooks/fakeweb_spec.rb +0 -169
  110. data/spec/lib/vcr/library_hooks/faraday_spec.rb +0 -68
  111. data/spec/lib/vcr/library_hooks/typhoeus_0.4_spec.rb +0 -36
  112. data/spec/lib/vcr/library_hooks/typhoeus_spec.rb +0 -162
  113. data/spec/lib/vcr/library_hooks/webmock_spec.rb +0 -117
  114. data/spec/lib/vcr/library_hooks_spec.rb +0 -51
  115. data/spec/lib/vcr/middleware/faraday_spec.rb +0 -181
  116. data/spec/lib/vcr/middleware/rack_spec.rb +0 -115
  117. data/spec/lib/vcr/request_ignorer_spec.rb +0 -70
  118. data/spec/lib/vcr/request_matcher_registry_spec.rb +0 -345
  119. data/spec/lib/vcr/structs_spec.rb +0 -732
  120. data/spec/lib/vcr/test_frameworks/cucumber_spec.rb +0 -107
  121. data/spec/lib/vcr/test_frameworks/rspec_spec.rb +0 -94
  122. data/spec/lib/vcr/util/hooks_spec.rb +0 -158
  123. data/spec/lib/vcr/util/internet_connection_spec.rb +0 -37
  124. data/spec/lib/vcr/util/version_checker_spec.rb +0 -31
  125. data/spec/lib/vcr/version_spec.rb +0 -27
  126. data/spec/lib/vcr_spec.rb +0 -354
  127. data/spec/monkey_patches.rb +0 -186
  128. data/spec/spec_helper.rb +0 -63
  129. data/spec/support/configuration_stubbing.rb +0 -8
  130. data/spec/support/cucumber_helpers.rb +0 -39
  131. data/spec/support/fixnum_extension.rb +0 -10
  132. data/spec/support/http_library_adapters.rb +0 -289
  133. data/spec/support/limited_uri.rb +0 -21
  134. data/spec/support/ruby_interpreter.rb +0 -7
  135. data/spec/support/shared_example_groups/excon.rb +0 -63
  136. data/spec/support/shared_example_groups/hook_into_http_library.rb +0 -594
  137. data/spec/support/shared_example_groups/request_hooks.rb +0 -59
  138. data/spec/support/sinatra_app.rb +0 -86
  139. data/spec/support/vcr_localhost_server.rb +0 -76
  140. data/spec/support/vcr_stub_helpers.rb +0 -17
@@ -1,86 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe VCR::Net::HTTPResponse do
4
- def self.it_allows_the_body_to_be_read(expected_regex)
5
- it 'allows the body to be read using #body' do
6
- expect(response.body.to_s).to match expected_regex
7
- end
8
-
9
- it 'allows the body to be read using #read_body' do
10
- expect(response.read_body.to_s).to match expected_regex
11
- end
12
-
13
- it 'allows the body to be read using #read_body with a block' do
14
- yielded_body = ''
15
- response { |r| r.read_body { |s| yielded_body << s.to_s } }
16
- expect(yielded_body).to match expected_regex
17
- end
18
-
19
- it 'allows the body to be read by passing a destination string to #read_body' do
20
- dest = ''
21
- ret_val = response { |r| r.read_body(dest) }.body
22
- expect(dest.to_s).to match expected_regex
23
- expect(ret_val.to_s).to eq(dest)
24
- end
25
-
26
- it 'raises an ArgumentError if both a destination string and a block is given to #read_body' do
27
- dest = ''
28
- expect { response { |r| r.read_body(dest) { |s| } } }.to raise_error(ArgumentError, 'both arg and block given for HTTP method')
29
- end
30
-
31
- it 'raises an IOError when #read_body is called twice with a block' do
32
- response { |r| r.read_body { |s| } }
33
- expect { response { |r| r.read_body { |s| } } }.to raise_error(IOError, /read_body called twice/)
34
- end
35
-
36
- it 'raises an IOError when #read_body is called twice with a destination string' do
37
- dest = ''
38
- response { |r| r.read_body(dest) }
39
- expect { response { |r| r.read_body(dest) } }.to raise_error(IOError, /read_body called twice/)
40
- end
41
- end
42
-
43
- { :get => /GET to root/, :head => /\A\z/ }.each do |http_verb, expected_body_regex|
44
- context "for a #{http_verb.to_s.upcase} request" do
45
- let(:http_verb_method) { :"request_#{http_verb}" }
46
-
47
- def response(&block)
48
- if defined?(@response) && block
49
- block.call(@response)
50
- return @response
51
- end
52
-
53
- @response ||= begin
54
- http = Net::HTTP.new('localhost', VCR::SinatraApp.port)
55
- res = http.send(http_verb_method, '/', &block)
56
- expect(res).not_to be_a(VCR::Net::HTTPResponse)
57
- expect(res).not_to be_a(::Net::WebMockHTTPResponse)
58
- res
59
- end
60
- end
61
-
62
- context 'when the body has not already been read' do
63
- it_allows_the_body_to_be_read(expected_body_regex)
64
- end
65
-
66
- context 'when the body has already been read using #read_body and a dest string' do
67
- before(:each) do
68
- dest = ''
69
- response { |res| res.read_body(dest) }
70
- response.extend VCR::Net::HTTPResponse
71
- end
72
-
73
- it_allows_the_body_to_be_read(expected_body_regex)
74
- end
75
-
76
- context 'when the body has already been read using #body' do
77
- before(:each) do
78
- response.body
79
- response.extend VCR::Net::HTTPResponse
80
- end
81
-
82
- it_allows_the_body_to_be_read(expected_body_regex)
83
- end
84
- end
85
- end
86
- end
@@ -1,104 +0,0 @@
1
- require 'spec_helper'
2
- require 'support/shared_example_groups/excon'
3
-
4
- describe "Excon hook", :with_monkey_patches => :excon do
5
- after(:each) do
6
- ::Excon.stubs.clear
7
- ::Excon.defaults[:mock] = false
8
- end
9
-
10
- def directly_stub_request(method, url, response_body)
11
- ::Excon.defaults[:mock] = true
12
- ::Excon.stub({ :method => method, :url => url }, { :body => response_body })
13
- end
14
-
15
- it_behaves_like 'a hook into an HTTP library', :excon, 'excon', :status_message_not_exposed
16
-
17
- context "when the query is specified as a hash option" do
18
- let(:excon) { ::Excon.new("http://localhost:#{VCR::SinatraApp.port}/search") }
19
-
20
- it 'properly records and plays back the response' do
21
- allow(VCR).to receive(:real_http_connections_allowed?).and_return(true)
22
- recorded, played_back = [1, 2].map do
23
- VCR.use_cassette('excon_query', :record => :once) do
24
- excon.request(:method => :get, :query => { :q => 'Tolkien' }).body
25
- end
26
- end
27
-
28
- expect(recorded).to eq(played_back)
29
- expect(recorded).to eq('query: Tolkien')
30
- end
31
- end
32
-
33
- context "when Excon's expects and idempotent middlewares cause errors to be raised" do
34
- let(:excon) { ::Excon.new("http://localhost:#{VCR::SinatraApp.port}/404_not_200") }
35
-
36
- def make_request
37
- VCR.use_cassette('with_errors', :record => :once) do
38
- excon.request(:method => :get, :expects => [200], :idempotent => true).body
39
- end
40
- end
41
-
42
- it 'records and plays back properly' do
43
- expect { make_request }.to raise_error(Excon::Errors::NotFound)
44
- expect { make_request }.to raise_error(Excon::Errors::NotFound)
45
- end
46
- end
47
-
48
- include_examples "Excon streaming"
49
-
50
- context 'when Excon raises an error due to an unexpected response status' do
51
- before(:each) do
52
- allow(VCR).to receive(:real_http_connections_allowed?).and_return(true)
53
- end
54
-
55
- it 'still records properly' do
56
- expect(VCR).to receive(:record_http_interaction) do |interaction|
57
- expect(interaction.response.status.code).to eq(404)
58
- expect(interaction.response.body).to eq('404 not 200')
59
- end
60
-
61
- expect {
62
- Excon.get("http://localhost:#{VCR::SinatraApp.port}/404_not_200", :expects => 200)
63
- }.to raise_error(Excon::Errors::Error)
64
- end
65
-
66
- def error_raised_by
67
- yield
68
- rescue => e
69
- return e
70
- else
71
- raise "No error was raised"
72
- end
73
-
74
- it 'raises the same error class as excon itself raises' do
75
- real_error, stubbed_error = 2.times.map do
76
- error_raised_by do
77
- VCR.use_cassette('excon_error', :record => :once) do
78
- Excon.get("http://localhost:#{VCR::SinatraApp.port}/not_found", :expects => 200)
79
- end
80
- end
81
- end
82
-
83
- expect(stubbed_error.class).to be(real_error.class)
84
- end
85
-
86
- it_behaves_like "request hooks", :excon, :recordable do
87
- undef make_request
88
- def make_request(disabled = false)
89
- expect {
90
- Excon.get(request_url, :expects => 404)
91
- }.to raise_error(Excon::Errors::Error)
92
- end
93
- end
94
- end
95
-
96
- describe "VCR.configuration.after_library_hooks_loaded hook" do
97
- it 'disables the webmock excon adapter so it does not conflict with our typhoeus hook' do
98
- expect(::WebMock::HttpLibAdapters::ExconAdapter).to respond_to(:disable!)
99
- expect(::WebMock::HttpLibAdapters::ExconAdapter).to receive(:disable!)
100
- $excon_after_loaded_hook.conditionally_invoke
101
- end
102
- end
103
- end
104
-
@@ -1,169 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "FakeWeb hook", :with_monkey_patches => :fakeweb do
4
- after(:each) do
5
- ::FakeWeb.clean_registry
6
- end
7
-
8
- def disable_real_connections
9
- ::FakeWeb.allow_net_connect = false
10
- ::FakeWeb::NetConnectNotAllowedError
11
- end
12
-
13
- def enable_real_connections
14
- ::FakeWeb.allow_net_connect = true
15
- end
16
-
17
- def directly_stub_request(method, url, response_body)
18
- ::FakeWeb.register_uri(method, url, :body => response_body)
19
- end
20
-
21
- it_behaves_like 'a hook into an HTTP library', :fakeweb, 'net/http'
22
-
23
- describe "some specific Net::HTTP edge cases" do
24
- before(:each) do
25
- allow(VCR).to receive(:real_http_connections_allowed?).and_return(true)
26
- end
27
-
28
- it 'records the request body when using #post_form' do
29
- expect(VCR).to receive(:record_http_interaction) do |interaction|
30
- expect(interaction.request.body).to eq("q=ruby")
31
- end
32
-
33
- uri = URI("http://localhost:#{VCR::SinatraApp.port}/foo")
34
- Net::HTTP.post_form(uri, 'q' => 'ruby')
35
- end
36
-
37
- it "does not record headers for which Net::HTTP sets defaults near the end of the real request" do
38
- expect(VCR).to receive(:record_http_interaction) do |interaction|
39
- expect(interaction.request.headers).not_to have_key('content-type')
40
- expect(interaction.request.headers).not_to have_key('host')
41
- end
42
- Net::HTTP.new('localhost', VCR::SinatraApp.port).send_request('POST', '/', '', { 'x-http-user' => 'me' })
43
- end
44
-
45
- it "records headers for which Net::HTTP usually sets defaults when the user manually sets their values" do
46
- expect(VCR).to receive(:record_http_interaction) do |interaction|
47
- expect(interaction.request.headers['content-type']).to eq(['foo/bar'])
48
- expect(interaction.request.headers['host']).to eq(['my-example.com'])
49
- end
50
- Net::HTTP.new('localhost', VCR::SinatraApp.port).send_request('POST', '/', '', { 'Content-Type' => 'foo/bar', 'Host' => 'my-example.com' })
51
- end
52
-
53
- def perform_get_with_returning_block
54
- Net::HTTP.new('localhost', VCR::SinatraApp.port).request(Net::HTTP::Get.new('/', {})) do |response|
55
- return response
56
- end
57
- end
58
-
59
- it 'records the interaction when Net::HTTP#request is called with a block with a return statement' do
60
- expect(VCR).to receive(:record_http_interaction).once
61
- expect(perform_get_with_returning_block.body).to eq("GET to root")
62
- end
63
-
64
- def make_post_request
65
- Net::HTTP.new('localhost', VCR::SinatraApp.port).post('/record-and-playback', '')
66
- end
67
-
68
- it 'records the interaction only once, even when Net::HTTP internally recursively calls #request' do
69
- expect(VCR).to receive(:record_http_interaction).once
70
- make_post_request
71
- end
72
-
73
- it 'properly returns the response body for a post request when recording, stubbing or ignoring the request' do
74
- recorded_body = nil
75
- VCR.use_cassette("new_cassette", :record => :once) do
76
- recorded_body = make_post_request.body
77
- expect(recorded_body).to match(/Response \d+/)
78
- end
79
-
80
- VCR.use_cassette("new_cassette", :record => :once) do
81
- expect(make_post_request.body).to eq(recorded_body)
82
- end
83
-
84
- VCR.configuration.ignore_request { |r| true }
85
- ignored_body = make_post_request.body
86
- expect(ignored_body).not_to eq(recorded_body)
87
- expect(ignored_body).to match(/Response \d+/)
88
- end
89
-
90
- context 'when the same Net::HTTP request object is used twice' do
91
- let(:uri) { URI("http://localhost:#{VCR::SinatraApp.port}/foo") }
92
- let(:http) { Net::HTTP.new(uri.host, uri.port) }
93
-
94
- it 'raises an UnhandledHTTPRequestError when using a cassette that only recorded one request' do
95
- VCR.use_cassette("new_cassette", :record => :once) do
96
- request = Net::HTTP::Get.new(uri.request_uri)
97
- http.request(request)
98
- end
99
-
100
- VCR.use_cassette("new_cassette", :record => :once) do
101
- request = Net::HTTP::Get.new(uri.request_uri)
102
- http.request(request)
103
- http.request(request)
104
- end
105
- end
106
- end
107
- end
108
-
109
- describe "VCR.configuration.after_library_hooks_loaded hook" do
110
- let(:run_hook) { $fakeweb_after_loaded_hook.conditionally_invoke }
111
-
112
- context 'when WebMock has been loaded' do
113
- before(:each) do
114
- expect(defined?(WebMock)).to be_truthy
115
- end
116
-
117
- it 'raises an error since FakeWeb and WebMock cannot both be used simultaneously' do
118
- expect { run_hook }.to raise_error(ArgumentError, /cannot use both/)
119
- end
120
- end
121
-
122
- context 'when WebMock has not been loaded' do
123
- let!(:orig_webmock_constant) { ::WebMock }
124
- before(:each) { Object.send(:remove_const, :WebMock) }
125
- after(:each) { ::WebMock = orig_webmock_constant }
126
-
127
- it 'does not raise an error' do
128
- run_hook # should not raise an error
129
- end
130
-
131
- it "warns about FakeWeb deprecation" do
132
- expect(::Kernel).to receive(:warn).with("WARNING: VCR's FakeWeb integration is deprecated and will be removed in VCR 4.0.")
133
- run_hook
134
- end
135
- end
136
- end
137
-
138
- describe "when a SocketError occurs" do
139
- before(:each) do
140
- VCR.configuration.ignore_request { |r| true }
141
- end
142
-
143
- it_behaves_like "request hooks", :fakeweb, :ignored do
144
- undef assert_expected_response
145
- def assert_expected_response(response)
146
- expect(response).to be_nil
147
- end
148
-
149
- undef make_request
150
- def make_request(disabled = false)
151
- allow_any_instance_of(::Net::HTTP).to receive(:request_without_vcr).and_raise(SocketError)
152
- expect {
153
- ::Net::HTTP.get_response(URI(request_url))
154
- }.to raise_error(SocketError)
155
- end
156
- end
157
- end
158
-
159
- describe "when VCR is turned off" do
160
- it 'allows white listed connections' do
161
- ::FakeWeb.allow_net_connect = %r[localhost]
162
-
163
- VCR.turn_off!
164
-
165
- uri = URI("http://localhost:#{VCR::SinatraApp.port}/foo")
166
- expect(Net::HTTP.get(uri)).to eq("FOO!")
167
- end
168
- end
169
- end
@@ -1,68 +0,0 @@
1
- require 'spec_helper'
2
- require 'vcr/library_hooks/faraday'
3
-
4
- describe "Faraday hook" do
5
- it 'inserts the VCR middleware just before the adapter' do
6
- conn = Faraday.new(:url => 'http://sushi.com') do |builder|
7
- builder.request :url_encoded
8
- builder.response :logger
9
- builder.adapter :net_http
10
- end
11
-
12
- conn.builder.lock!
13
- expect(conn.builder.handlers.last(2).map(&:klass)).to eq([
14
- VCR::Middleware::Faraday,
15
- Faraday::Adapter::NetHttp
16
- ])
17
- end
18
-
19
- it 'handles the case where no adapter is declared' do
20
- conn = Faraday.new
21
-
22
- conn.builder.lock!
23
- expect(conn.builder.handlers.last(2).map(&:klass)).to eq([
24
- VCR::Middleware::Faraday,
25
- Faraday::Adapter::NetHttp
26
- ])
27
- end
28
-
29
- it 'does nothing if the VCR middleware has already been included' do
30
- conn = Faraday.new(:url => 'http://sushi.com') do |builder|
31
- builder.use VCR::Middleware::Faraday
32
- builder.use Faraday::Response::Logger
33
- builder.use Faraday::Adapter::NetHttp
34
- end
35
-
36
- conn.builder.lock!
37
- expect(conn.builder.handlers.map(&:klass)).to eq([
38
- VCR::Middleware::Faraday,
39
- Faraday::Response::Logger,
40
- Faraday::Adapter::NetHttp
41
- ])
42
- end
43
-
44
- it 'prints a warning if the faraday connection stack contains a middleware after the HTTP adapter' do
45
- conn = Faraday.new(:url => 'http://sushi.com') do |builder|
46
- builder.use Faraday::Adapter::NetHttp
47
- builder.use Faraday::Response::Logger
48
- end
49
-
50
- expect(conn.builder).to receive(:warn).with(/Faraday::Response::Logger/)
51
- conn.builder.lock!
52
- end
53
-
54
- it 'gracefully handles the case where there is no explicit HTTP adapter' do
55
- conn = Faraday.new(:url => 'http://sushi.com') do |builder|
56
- builder.request :url_encoded
57
- builder.response :logger
58
- end
59
-
60
- conn.builder.lock!
61
- expect(conn.builder.handlers.map(&:klass)).to eq([
62
- Faraday::Request::UrlEncoded,
63
- Faraday::Response::Logger,
64
- VCR::Middleware::Faraday
65
- ])
66
- end
67
- end
68
-
@@ -1,36 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "Typhoeus 0.4 hook", :with_monkey_patches => :typhoeus_0_4 do
4
- after(:each) do
5
- ::Typhoeus::Hydra.clear_stubs
6
- end
7
-
8
- def disable_real_connections
9
- ::Typhoeus::Hydra.allow_net_connect = false
10
- ::Typhoeus::Hydra::NetConnectNotAllowedError
11
- end
12
-
13
- def enable_real_connections
14
- ::Typhoeus::Hydra.allow_net_connect = true
15
- end
16
-
17
- def directly_stub_request(method, url, response_body)
18
- response = ::Typhoeus::Response.new(:code => 200, :body => response_body)
19
- ::Typhoeus::Hydra.stub(method, url).and_return(response)
20
- end
21
-
22
- it_behaves_like 'a hook into an HTTP library', :typhoeus, 'typhoeus 0.4'
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
-
30
- it "warns about Typhoeus 0.4 deprecation" do
31
- expect(::Kernel).to receive(:warn).with("WARNING: VCR's Typhoeus 0.4 integration is deprecated and will be removed in VCR 3.0.")
32
- $typhoeus_0_4_after_loaded_hook.conditionally_invoke
33
- end
34
- end
35
- end if RUBY_INTERPRETER == :mri && ::Typhoeus::VERSION.to_f < 0.5
36
-