vcr 2.4.0 → 2.5.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.
- checksums.yaml +15 -0
- data/.gitignore +3 -0
- data/.travis.yml +2 -0
- data/CHANGELOG.md +31 -0
- data/Gemfile +1 -2
- data/Gemfile.lock +63 -46
- data/README.md +5 -2
- data/features/cassettes/allow_unused_http_interactions.feature +1 -1
- data/features/cassettes/automatic_re_recording.feature +1 -1
- data/features/cassettes/decompress.feature +3 -3
- data/features/cassettes/dynamic_erb.feature +2 -2
- data/features/cassettes/exclusive.feature +1 -1
- data/features/cassettes/naming.feature +1 -1
- data/features/cassettes/no_cassette.feature +6 -3
- data/features/cassettes/persistence.feature +1 -1
- data/features/cassettes/update_content_length_header.feature +1 -1
- data/features/configuration/allow_http_connections_when_no_cassette.feature +1 -1
- data/features/configuration/cassette_library_dir.feature +1 -1
- data/features/configuration/debug_logging.feature +5 -5
- data/features/configuration/filter_sensitive_data.feature +2 -2
- data/features/configuration/hook_into.feature +4 -7
- data/features/getting_started.md +2 -2
- data/features/hooks/before_playback.feature +5 -5
- data/features/hooks/before_record.feature +5 -5
- data/features/middleware/rack.feature +2 -2
- data/features/record_modes/all.feature +1 -1
- data/features/record_modes/new_episodes.feature +1 -1
- data/features/record_modes/none.feature +1 -1
- data/features/record_modes/once.feature +1 -1
- data/features/request_matching/custom_matcher.feature +1 -1
- data/features/request_matching/headers.feature +0 -2
- data/features/request_matching/playback_repeats.feature +1 -1
- data/features/request_matching/uri_without_param.feature +1 -1
- data/features/support/env.rb +1 -0
- data/features/test_frameworks/cucumber.feature +8 -8
- data/features/test_frameworks/rspec_macro.feature +2 -2
- data/features/test_frameworks/rspec_metadata.feature +1 -1
- data/gemfiles/typhoeus_old.gemfile +1 -1
- data/gemfiles/typhoeus_old.gemfile.lock +31 -57
- data/lib/vcr/cassette/migrator.rb +8 -1
- data/lib/vcr/configuration.rb +9 -2
- data/lib/vcr/library_hooks/excon.rb +2 -184
- data/lib/vcr/library_hooks/typhoeus.rb +1 -1
- data/lib/vcr/library_hooks/typhoeus_0.4.rb +4 -0
- data/lib/vcr/library_hooks/webmock.rb +1 -1
- data/lib/vcr/middleware/excon.rb +226 -0
- data/lib/vcr/version.rb +1 -1
- data/spec/acceptance/threading_spec.rb +28 -0
- data/spec/monkey_patches.rb +3 -7
- data/spec/quality_spec.rb +1 -1
- data/spec/spec_helper.rb +7 -4
- data/spec/support/http_library_adapters.rb +4 -3
- data/spec/support/shared_example_groups/excon.rb +22 -0
- data/spec/support/shared_example_groups/hook_into_http_library.rb +46 -46
- data/spec/support/shared_example_groups/request_hooks.rb +8 -8
- data/spec/vcr/cassette/erb_renderer_spec.rb +5 -5
- data/spec/vcr/cassette/http_interaction_list_spec.rb +52 -40
- data/spec/vcr/cassette/migrator_spec.rb +11 -11
- data/spec/vcr/cassette/persisters/file_system_spec.rb +11 -11
- data/spec/vcr/cassette/persisters_spec.rb +2 -2
- data/spec/vcr/cassette/serializers_spec.rb +13 -12
- data/spec/vcr/cassette_spec.rb +58 -58
- data/spec/vcr/configuration_spec.rb +43 -31
- data/spec/vcr/deprecations_spec.rb +3 -3
- data/spec/vcr/errors_spec.rb +25 -25
- data/spec/vcr/extensions/net_http_response_spec.rb +7 -7
- data/spec/vcr/library_hooks/excon_spec.rb +7 -85
- data/spec/vcr/library_hooks/fakeweb_spec.rb +15 -13
- data/spec/vcr/library_hooks/faraday_spec.rb +4 -4
- data/spec/vcr/library_hooks/typhoeus_0.4_spec.rb +5 -0
- data/spec/vcr/library_hooks/typhoeus_spec.rb +3 -3
- data/spec/vcr/library_hooks/webmock_spec.rb +13 -5
- data/spec/vcr/library_hooks_spec.rb +9 -9
- data/spec/vcr/middleware/faraday_spec.rb +10 -10
- data/spec/vcr/middleware/rack_spec.rb +20 -15
- data/spec/vcr/request_ignorer_spec.rb +3 -3
- data/spec/vcr/request_matcher_registry_spec.rb +88 -61
- data/spec/vcr/structs_spec.rb +85 -85
- data/spec/vcr/test_frameworks/cucumber_spec.rb +7 -7
- data/spec/vcr/test_frameworks/rspec_spec.rb +10 -10
- data/spec/vcr/util/hooks_spec.rb +20 -20
- data/spec/vcr/util/internet_connection_spec.rb +2 -2
- data/spec/vcr_spec.rb +50 -48
- data/vcr.gemspec +4 -4
- metadata +308 -372
@@ -10,7 +10,7 @@ describe VCR, 'deprecations', :disable_warnings do
|
|
10
10
|
it 'yields the configuration object' do
|
11
11
|
config_object = nil
|
12
12
|
VCR.config { |c| config_object = c }
|
13
|
-
config_object.
|
13
|
+
expect(config_object).to be(VCR.configuration)
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'prints a deprecation warning' do
|
@@ -22,7 +22,7 @@ describe VCR, 'deprecations', :disable_warnings do
|
|
22
22
|
|
23
23
|
describe "Config" do
|
24
24
|
it 'returns the same object referenced by VCR.configuration' do
|
25
|
-
VCR::Config.
|
25
|
+
expect(VCR::Config).to be(VCR.configuration)
|
26
26
|
end
|
27
27
|
|
28
28
|
it 'prints a deprecation warning' do
|
@@ -40,7 +40,7 @@ describe VCR, 'deprecations', :disable_warnings do
|
|
40
40
|
|
41
41
|
describe "Cassette::MissingERBVariableError" do
|
42
42
|
it 'returns VCR::Errors::MissingERBVariableError' do
|
43
|
-
VCR::Cassette::MissingERBVariableError.
|
43
|
+
expect(VCR::Cassette::MissingERBVariableError).to be(VCR::Errors::MissingERBVariableError)
|
44
44
|
end
|
45
45
|
|
46
46
|
it 'prints a deprecation warning' do
|
data/spec/vcr/errors_spec.rb
CHANGED
@@ -17,119 +17,119 @@ module VCR
|
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'identifies the request by method and URI' do
|
20
|
-
message_for(:method => :post, :uri => 'http://foo.com/').
|
20
|
+
expect(message_for(:method => :post, :uri => 'http://foo.com/')).to include(
|
21
21
|
'POST http://foo.com/'
|
22
22
|
)
|
23
23
|
end
|
24
24
|
|
25
25
|
context 'when there is no current cassette' do
|
26
26
|
it 'mentions that there is no current cassette' do
|
27
|
-
message.
|
27
|
+
expect(message).to include('There is currently no cassette in use.')
|
28
28
|
end
|
29
29
|
|
30
30
|
it 'mentions that the request can be recorded by inserting a cassette' do
|
31
|
-
message.
|
31
|
+
expect(message).to match(/record this request and play it back.*VCR.use_cassette/m)
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'mentions the allow_http_connections_when_no_cassette option' do
|
35
|
-
message.
|
35
|
+
expect(message).to include('allow_http_connections_when_no_cassette')
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'mentions that the request can be ignored' do
|
39
|
-
message.
|
39
|
+
expect(message).to include('set an `ignore_request` callback')
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'does not double-insert the asterisks for the bullet points' do
|
43
|
-
message.
|
43
|
+
expect(message).not_to match(/\s+\*\s+\*/)
|
44
44
|
end
|
45
45
|
|
46
46
|
it 'mentions the debug logging configuration option' do
|
47
|
-
message.
|
47
|
+
expect(message).to include('debug_logger')
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
51
|
context 'when there is a current cassette' do
|
52
52
|
it 'mentions the details about the current casette' do
|
53
53
|
VCR.use_cassette('example') do
|
54
|
-
message.
|
54
|
+
expect(message).to match(/VCR is currently using the following cassette:.+example.yml/m)
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
58
|
it 'mentions that :new_episodes can be used to record the request' do
|
59
59
|
VCR.use_cassette('example') do
|
60
|
-
message.
|
60
|
+
expect(message).to include('use the :new_episodes record mode')
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
64
|
it 'mentions that :once does not allow a cassette to be re-recorded' do
|
65
65
|
VCR.use_cassette('example', :record => :once) do
|
66
|
-
message.
|
66
|
+
expect(message).to include('(:once) does not allow new requests to be recorded')
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
70
|
it 'mentions that :none does not allow any recording' do
|
71
71
|
VCR.use_cassette('example', :record => :none) do
|
72
|
-
message.
|
72
|
+
expect(message).to include('(:none) does not allow requests to be recorded')
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
76
76
|
it 'does not mention the :once or :none record modes if using the :new_episodes record mode' do
|
77
77
|
VCR.use_cassette('example', :record => :new_episodes) do
|
78
|
-
message.
|
78
|
+
expect(message).not_to include(':once', ':none')
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
82
|
it 'mentions :allow_playback_repeats if the current cassette has a used matching interaction' do
|
83
83
|
VCR.use_cassette('example') do |cassette|
|
84
|
-
cassette.http_interactions.
|
84
|
+
expect(cassette.http_interactions).to respond_to(:has_used_interaction_matching?)
|
85
85
|
cassette.http_interactions.stub(:has_used_interaction_matching? => true)
|
86
|
-
message.
|
86
|
+
expect(message).to include('allow_playback_repeats')
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
90
|
it 'does not mention :allow_playback_repeats if the current cassette does not have a used matching interaction' do
|
91
91
|
VCR.use_cassette('example') do |cassette|
|
92
|
-
cassette.http_interactions.
|
92
|
+
expect(cassette.http_interactions).to respond_to(:has_used_interaction_matching?)
|
93
93
|
cassette.http_interactions.stub(:has_used_interaction_matching? => false)
|
94
|
-
message.
|
94
|
+
expect(message).not_to include('allow_playback_repeats')
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
98
98
|
it 'does not mention using a different :match_requests_on option when there are no remaining unused interactions' do
|
99
99
|
VCR.use_cassette('example') do |cassette|
|
100
|
-
cassette.http_interactions.
|
100
|
+
expect(cassette.http_interactions).to respond_to(:remaining_unused_interaction_count)
|
101
101
|
cassette.http_interactions.stub(:remaining_unused_interaction_count => 0)
|
102
|
-
message.
|
102
|
+
expect(message).not_to include('match_requests_on cassette option')
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
106
106
|
it 'mentions using a different :match_requests_on option when there are some remaining unused interactions' do
|
107
107
|
VCR.use_cassette('example') do |cassette|
|
108
|
-
cassette.http_interactions.
|
108
|
+
expect(cassette.http_interactions).to respond_to(:remaining_unused_interaction_count)
|
109
109
|
cassette.http_interactions.stub(:remaining_unused_interaction_count => 1)
|
110
|
-
message.
|
110
|
+
expect(message).to include('match_requests_on cassette option')
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
114
114
|
it 'uses the singular (HTTP interaction) when there is only 1 left' do
|
115
115
|
VCR.use_cassette('example') do |cassette|
|
116
|
-
cassette.http_interactions.
|
116
|
+
expect(cassette.http_interactions).to respond_to(:remaining_unused_interaction_count)
|
117
117
|
cassette.http_interactions.stub(:remaining_unused_interaction_count => 1)
|
118
|
-
message.
|
118
|
+
expect(message).to include('1 HTTP interaction ')
|
119
119
|
end
|
120
120
|
end
|
121
121
|
|
122
122
|
it 'uses the plural (HTTP interactions) when there is more than 1 left' do
|
123
123
|
VCR.use_cassette('example') do |cassette|
|
124
|
-
cassette.http_interactions.
|
124
|
+
expect(cassette.http_interactions).to respond_to(:remaining_unused_interaction_count)
|
125
125
|
cassette.http_interactions.stub(:remaining_unused_interaction_count => 2)
|
126
|
-
message.
|
126
|
+
expect(message).to include('2 HTTP interactions ')
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
130
130
|
it 'mentions the debug logging configuration option' do
|
131
131
|
VCR.use_cassette('example', :record => :new_episodes) do
|
132
|
-
message.
|
132
|
+
expect(message).to include('debug_logger')
|
133
133
|
end
|
134
134
|
end
|
135
135
|
end
|
@@ -3,24 +3,24 @@ require 'spec_helper'
|
|
3
3
|
describe VCR::Net::HTTPResponse do
|
4
4
|
def self.it_allows_the_body_to_be_read(expected_regex)
|
5
5
|
it 'allows the body to be read using #body' do
|
6
|
-
response.body.to_s.
|
6
|
+
expect(response.body.to_s).to match expected_regex
|
7
7
|
end
|
8
8
|
|
9
9
|
it 'allows the body to be read using #read_body' do
|
10
|
-
response.read_body.to_s.
|
10
|
+
expect(response.read_body.to_s).to match expected_regex
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'allows the body to be read using #read_body with a block' do
|
14
14
|
yielded_body = ''
|
15
15
|
response { |r| r.read_body { |s| yielded_body << s.to_s } }
|
16
|
-
yielded_body.
|
16
|
+
expect(yielded_body).to match expected_regex
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'allows the body to be read by passing a destination string to #read_body' do
|
20
20
|
dest = ''
|
21
21
|
ret_val = response { |r| r.read_body(dest) }.body
|
22
|
-
dest.to_s.
|
23
|
-
ret_val.to_s.
|
22
|
+
expect(dest.to_s).to match expected_regex
|
23
|
+
expect(ret_val.to_s).to eq(dest)
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'raises an ArgumentError if both a destination string and a block is given to #read_body' do
|
@@ -53,8 +53,8 @@ describe VCR::Net::HTTPResponse do
|
|
53
53
|
@response ||= begin
|
54
54
|
http = Net::HTTP.new('localhost', VCR::SinatraApp.port)
|
55
55
|
res = http.send(http_verb_method, '/', &block)
|
56
|
-
res.
|
57
|
-
res.
|
56
|
+
expect(res).not_to be_a(VCR::Net::HTTPResponse)
|
57
|
+
expect(res).not_to be_a(::Net::WebMockHTTPResponse)
|
58
58
|
res
|
59
59
|
end
|
60
60
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'support/shared_example_groups/excon'
|
2
3
|
|
3
4
|
describe "Excon hook", :with_monkey_patches => :excon do
|
4
5
|
# TODO: figure out a way to get disabling VCR to work with Excon
|
@@ -20,68 +21,12 @@ describe "Excon hook", :with_monkey_patches => :excon do
|
|
20
21
|
end
|
21
22
|
end
|
22
23
|
|
23
|
-
recorded.
|
24
|
-
recorded.
|
24
|
+
expect(recorded).to eq(played_back)
|
25
|
+
expect(recorded).to eq('query: Tolkien')
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
28
|
-
|
29
|
-
let!(:excon) { ::Excon.new("http://localhost:#{VCR::SinatraApp.port}/") }
|
30
|
-
|
31
|
-
def deep_dup(hash)
|
32
|
-
Marshal.load(Marshal.dump hash)
|
33
|
-
end
|
34
|
-
|
35
|
-
def intercept_request(&interception)
|
36
|
-
orig_new = ::Excon::Connection.method(:new)
|
37
|
-
|
38
|
-
::Excon::Connection.stub(:new) do |*args1|
|
39
|
-
orig_new.call(*args1).tap do |inst|
|
40
|
-
|
41
|
-
meth = inst.method(:request)
|
42
|
-
inst.stub(:request) do |*args2|
|
43
|
-
interception.call(inst, *args2)
|
44
|
-
meth.call(*args2)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
it 'runs the real request with the same connection params' do
|
51
|
-
connection_params_1 = deep_dup(excon.connection)
|
52
|
-
connection_params_2 = nil
|
53
|
-
|
54
|
-
intercept_request do |instance, *args|
|
55
|
-
connection_params_2 = deep_dup(instance.connection)
|
56
|
-
end
|
57
|
-
|
58
|
-
VCR.use_cassette("excon") do
|
59
|
-
excon.request(:method => :get, :path => '/foo')
|
60
|
-
end
|
61
|
-
|
62
|
-
connection_params_2.should eq(connection_params_1)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
context "when Excon's streaming API is used" do
|
67
|
-
it 'properly records and plays back the response' do
|
68
|
-
VCR.stub(:real_http_connections_allowed? => true)
|
69
|
-
recorded, played_back = [1, 2].map do
|
70
|
-
chunks = []
|
71
|
-
|
72
|
-
VCR.use_cassette('excon_streaming', :record => :once) do
|
73
|
-
Excon.get "http://localhost:#{VCR::SinatraApp.port}/foo", :response_block => lambda { |chunk, remaining_bytes, total_bytes|
|
74
|
-
chunks << chunk
|
75
|
-
}
|
76
|
-
end
|
77
|
-
|
78
|
-
chunks.join
|
79
|
-
end
|
80
|
-
|
81
|
-
recorded.should eq(played_back)
|
82
|
-
recorded.should eq("FOO!")
|
83
|
-
end
|
84
|
-
end
|
29
|
+
include_examples "Excon streaming"
|
85
30
|
|
86
31
|
context 'when Excon raises an error due to an unexpected response status' do
|
87
32
|
before(:each) do
|
@@ -90,7 +35,7 @@ describe "Excon hook", :with_monkey_patches => :excon do
|
|
90
35
|
|
91
36
|
it 'still records properly' do
|
92
37
|
VCR.should_receive(:record_http_interaction) do |interaction|
|
93
|
-
interaction.response.status.code.
|
38
|
+
expect(interaction.response.status.code).to eq(404)
|
94
39
|
end
|
95
40
|
|
96
41
|
expect {
|
@@ -98,29 +43,6 @@ describe "Excon hook", :with_monkey_patches => :excon do
|
|
98
43
|
}.to raise_error(Excon::Errors::Error)
|
99
44
|
end
|
100
45
|
|
101
|
-
it 'performs the right number of retries' do
|
102
|
-
connection = Excon.new("http://localhost:#{VCR::SinatraApp.port}/not_found")
|
103
|
-
|
104
|
-
Excon::Connection.stub(:new => connection)
|
105
|
-
|
106
|
-
connection.extend Module.new {
|
107
|
-
def request_kernel_call_counts
|
108
|
-
@request_kernel_call_counts ||= Hash.new(0)
|
109
|
-
end
|
110
|
-
|
111
|
-
def request_kernel(params, &block)
|
112
|
-
request_kernel_call_counts[params[:mock]] += 1
|
113
|
-
super
|
114
|
-
end
|
115
|
-
}
|
116
|
-
|
117
|
-
expect {
|
118
|
-
connection.get(:expects => 200, :idempotent => true, :retry_limit => 3)
|
119
|
-
}.to raise_error(Excon::Errors::Error)
|
120
|
-
|
121
|
-
connection.request_kernel_call_counts.should eq(true => 3, false => 3)
|
122
|
-
end
|
123
|
-
|
124
46
|
def error_raised_by
|
125
47
|
yield
|
126
48
|
rescue => e
|
@@ -138,7 +60,7 @@ describe "Excon hook", :with_monkey_patches => :excon do
|
|
138
60
|
end
|
139
61
|
end
|
140
62
|
|
141
|
-
stubbed_error.class.
|
63
|
+
expect(stubbed_error.class).to be(real_error.class)
|
142
64
|
end
|
143
65
|
|
144
66
|
it_behaves_like "request hooks", :excon, :recordable do
|
@@ -153,7 +75,7 @@ describe "Excon hook", :with_monkey_patches => :excon do
|
|
153
75
|
|
154
76
|
describe "VCR.configuration.after_library_hooks_loaded hook" do
|
155
77
|
it 'disables the webmock excon adapter so it does not conflict with our typhoeus hook' do
|
156
|
-
::WebMock::HttpLibAdapters::ExconAdapter.
|
78
|
+
expect(::WebMock::HttpLibAdapters::ExconAdapter).to respond_to(:disable!)
|
157
79
|
::WebMock::HttpLibAdapters::ExconAdapter.should_receive(:disable!)
|
158
80
|
$excon_after_loaded_hook.conditionally_invoke
|
159
81
|
end
|
@@ -27,7 +27,7 @@ describe "FakeWeb hook", :with_monkey_patches => :fakeweb do
|
|
27
27
|
|
28
28
|
it 'records the request body when using #post_form' do
|
29
29
|
VCR.should_receive(:record_http_interaction) do |interaction|
|
30
|
-
interaction.request.body.
|
30
|
+
expect(interaction.request.body).to eq("q=ruby")
|
31
31
|
end
|
32
32
|
|
33
33
|
uri = URI("http://localhost:#{VCR::SinatraApp.port}/foo")
|
@@ -36,16 +36,16 @@ describe "FakeWeb hook", :with_monkey_patches => :fakeweb do
|
|
36
36
|
|
37
37
|
it "does not record headers for which Net::HTTP sets defaults near the end of the real request" do
|
38
38
|
VCR.should_receive(:record_http_interaction) do |interaction|
|
39
|
-
interaction.request.headers.
|
40
|
-
interaction.request.headers.
|
39
|
+
expect(interaction.request.headers).not_to have_key('content-type')
|
40
|
+
expect(interaction.request.headers).not_to have_key('host')
|
41
41
|
end
|
42
42
|
Net::HTTP.new('localhost', VCR::SinatraApp.port).send_request('POST', '/', '', { 'x-http-user' => 'me' })
|
43
43
|
end
|
44
44
|
|
45
45
|
it "records headers for which Net::HTTP usually sets defaults when the user manually sets their values" do
|
46
46
|
VCR.should_receive(:record_http_interaction) do |interaction|
|
47
|
-
interaction.request.headers['content-type'].
|
48
|
-
interaction.request.headers['host'].
|
47
|
+
expect(interaction.request.headers['content-type']).to eq(['foo/bar'])
|
48
|
+
expect(interaction.request.headers['host']).to eq(['my-example.com'])
|
49
49
|
end
|
50
50
|
Net::HTTP.new('localhost', VCR::SinatraApp.port).send_request('POST', '/', '', { 'Content-Type' => 'foo/bar', 'Host' => 'my-example.com' })
|
51
51
|
end
|
@@ -58,7 +58,7 @@ describe "FakeWeb hook", :with_monkey_patches => :fakeweb do
|
|
58
58
|
|
59
59
|
it 'records the interaction when Net::HTTP#request is called with a block with a return statement' do
|
60
60
|
VCR.should_receive(:record_http_interaction).once
|
61
|
-
perform_get_with_returning_block.body.
|
61
|
+
expect(perform_get_with_returning_block.body).to eq("GET to root")
|
62
62
|
end
|
63
63
|
|
64
64
|
def make_post_request
|
@@ -74,17 +74,17 @@ describe "FakeWeb hook", :with_monkey_patches => :fakeweb do
|
|
74
74
|
recorded_body = nil
|
75
75
|
VCR.use_cassette("new_cassette", :record => :once) do
|
76
76
|
recorded_body = make_post_request.body
|
77
|
-
recorded_body.
|
77
|
+
expect(recorded_body).to match(/Response \d+/)
|
78
78
|
end
|
79
79
|
|
80
80
|
VCR.use_cassette("new_cassette", :record => :once) do
|
81
|
-
make_post_request.body.
|
81
|
+
expect(make_post_request.body).to eq(recorded_body)
|
82
82
|
end
|
83
83
|
|
84
84
|
VCR.configuration.ignore_request { |r| true }
|
85
85
|
ignored_body = make_post_request.body
|
86
|
-
ignored_body.
|
87
|
-
ignored_body.
|
86
|
+
expect(ignored_body).not_to eq(recorded_body)
|
87
|
+
expect(ignored_body).to match(/Response \d+/)
|
88
88
|
end
|
89
89
|
|
90
90
|
context 'when the same Net::HTTP request object is used twice' do
|
@@ -110,7 +110,9 @@ describe "FakeWeb hook", :with_monkey_patches => :fakeweb do
|
|
110
110
|
let(:run_hook) { $fakeweb_after_loaded_hook.conditionally_invoke }
|
111
111
|
|
112
112
|
context 'when WebMock has been loaded' do
|
113
|
-
before(:each)
|
113
|
+
before(:each) do
|
114
|
+
expect(defined?(WebMock)).to be_true
|
115
|
+
end
|
114
116
|
|
115
117
|
it 'raises an error since FakeWeb and WebMock cannot both be used simultaneously' do
|
116
118
|
expect { run_hook }.to raise_error(ArgumentError, /cannot use both/)
|
@@ -141,7 +143,7 @@ describe "FakeWeb hook", :with_monkey_patches => :fakeweb do
|
|
141
143
|
it_behaves_like "request hooks", :fakeweb, :ignored do
|
142
144
|
undef assert_expected_response
|
143
145
|
def assert_expected_response(response)
|
144
|
-
response.
|
146
|
+
expect(response).to be_nil
|
145
147
|
end
|
146
148
|
|
147
149
|
undef make_request
|
@@ -161,7 +163,7 @@ describe "FakeWeb hook", :with_monkey_patches => :fakeweb do
|
|
161
163
|
VCR.turn_off!
|
162
164
|
|
163
165
|
uri = URI("http://localhost:#{VCR::SinatraApp.port}/foo")
|
164
|
-
Net::HTTP.get(uri).
|
166
|
+
expect(Net::HTTP.get(uri)).to eq("FOO!")
|
165
167
|
end
|
166
168
|
end
|
167
169
|
end
|
@@ -10,7 +10,7 @@ describe "Faraday hook" do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
conn.builder.lock!
|
13
|
-
conn.builder.handlers.last(2).map(&:klass).
|
13
|
+
expect(conn.builder.handlers.last(2).map(&:klass)).to eq([
|
14
14
|
VCR::Middleware::Faraday,
|
15
15
|
Faraday::Adapter::NetHttp
|
16
16
|
])
|
@@ -20,7 +20,7 @@ describe "Faraday hook" do
|
|
20
20
|
conn = Faraday.new
|
21
21
|
|
22
22
|
conn.builder.lock!
|
23
|
-
conn.builder.handlers.last(2).map(&:klass).
|
23
|
+
expect(conn.builder.handlers.last(2).map(&:klass)).to eq([
|
24
24
|
VCR::Middleware::Faraday,
|
25
25
|
Faraday::Adapter::NetHttp
|
26
26
|
])
|
@@ -34,7 +34,7 @@ describe "Faraday hook" do
|
|
34
34
|
end
|
35
35
|
|
36
36
|
conn.builder.lock!
|
37
|
-
conn.builder.handlers.map(&:klass).
|
37
|
+
expect(conn.builder.handlers.map(&:klass)).to eq([
|
38
38
|
VCR::Middleware::Faraday,
|
39
39
|
Faraday::Response::Logger,
|
40
40
|
Faraday::Adapter::NetHttp
|
@@ -58,7 +58,7 @@ describe "Faraday hook" do
|
|
58
58
|
end
|
59
59
|
|
60
60
|
conn.builder.lock!
|
61
|
-
conn.builder.handlers.map(&:klass).
|
61
|
+
expect(conn.builder.handlers.map(&:klass)).to eq([
|
62
62
|
Faraday::Request::UrlEncoded,
|
63
63
|
Faraday::Response::Logger,
|
64
64
|
VCR::Middleware::Faraday
|