vcr 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +27 -0
- data/CHANGELOG.md +13 -0
- data/Gemfile +24 -0
- data/Gemfile.lock +119 -0
- data/README.md +3 -6
- data/Rakefile +70 -0
- data/benchmarks/http_stubbing_libraries.rb +59 -0
- data/features/fixtures/vcr_cassettes/1.9.1/cucumber_tags/regex_cassette.yml +43 -0
- data/features/fixtures/vcr_cassettes/1.9.1/cucumber_tags/replay_cassette1.yml +43 -0
- data/features/fixtures/vcr_cassettes/1.9.1/cucumber_tags/replay_cassette2.yml +63 -0
- data/features/fixtures/vcr_cassettes/1.9.1/cucumber_tags/replay_cassette3.yml +85 -0
- data/features/fixtures/vcr_cassettes/1.9.1/erb_cassette.yml +36 -0
- data/features/fixtures/vcr_cassettes/1.9.1/match_requests_on.yml +35 -0
- data/features/fixtures/vcr_cassettes/1.9.1/nested_replay_cassette.yml +32 -0
- data/features/fixtures/vcr_cassettes/1.9.1/not_the_real_response.yml +43 -0
- data/features/fixtures/vcr_cassettes/1.9.1/replay_localhost_cassette.yml +32 -0
- data/features/fixtures/vcr_cassettes/not_1.9.1/cucumber_tags/regex_cassette.yml +43 -0
- data/features/fixtures/vcr_cassettes/not_1.9.1/cucumber_tags/replay_cassette1.yml +43 -0
- data/features/fixtures/vcr_cassettes/not_1.9.1/cucumber_tags/replay_cassette2.yml +47 -0
- data/features/fixtures/vcr_cassettes/not_1.9.1/cucumber_tags/replay_cassette3.yml +85 -0
- data/features/fixtures/vcr_cassettes/not_1.9.1/erb_cassette.yml +36 -0
- data/features/fixtures/vcr_cassettes/not_1.9.1/match_requests_on.yml +35 -0
- data/features/fixtures/vcr_cassettes/not_1.9.1/nested_replay_cassette.yml +24 -0
- data/features/fixtures/vcr_cassettes/not_1.9.1/not_the_real_response.yml +43 -0
- data/features/fixtures/vcr_cassettes/not_1.9.1/replay_localhost_cassette.yml +32 -0
- data/features/http_client.feature +16 -0
- data/features/net_http.feature +27 -0
- data/features/record_response.feature +66 -0
- data/features/replay_recorded_response.feature +96 -0
- data/features/step_definitions/http_client_steps.rb +7 -0
- data/features/step_definitions/net_http_steps.rb +37 -0
- data/features/step_definitions/vcr_steps.rb +240 -0
- data/features/support/env.rb +104 -0
- data/features/webmock.feature +26 -0
- data/lib/vcr.rb +2 -2
- data/lib/vcr/extensions/net_http.rb +0 -8
- data/lib/vcr/http_stubbing_adapters/common.rb +39 -0
- data/lib/vcr/http_stubbing_adapters/fakeweb.rb +74 -70
- data/lib/vcr/http_stubbing_adapters/webmock.rb +61 -62
- data/lib/vcr/version.rb +1 -1
- data/spec/cassette_spec.rb +280 -0
- data/spec/config_spec.rb +76 -0
- data/spec/cucumber_tags_spec.rb +55 -0
- data/spec/deprecations_spec.rb +52 -0
- data/spec/extensions/net_http_response_spec.rb +85 -0
- data/spec/extensions/net_http_spec.rb +77 -0
- data/spec/fixtures/1.9.1/0_3_1_cassette.yml +29 -0
- data/spec/fixtures/1.9.1/cassette_spec/erb_with_no_vars.yml +32 -0
- data/spec/fixtures/1.9.1/cassette_spec/erb_with_vars.yml +32 -0
- data/spec/fixtures/1.9.1/cassette_spec/example.yml +110 -0
- data/spec/fixtures/1.9.1/cassette_spec/with_localhost_requests.yml +86 -0
- data/spec/fixtures/1.9.1/example_net_http.yml +14 -0
- data/spec/fixtures/1.9.1/example_net_http_request.yml +12 -0
- data/spec/fixtures/1.9.1/example_net_http_response.yml +25 -0
- data/spec/fixtures/1.9.1/fake_example.com_responses.yml +106 -0
- data/spec/fixtures/1.9.1/match_requests_on.yml +185 -0
- data/spec/fixtures/not_1.9.1/0_3_1_cassette.yml +29 -0
- data/spec/fixtures/not_1.9.1/cassette_spec/erb_with_no_vars.yml +32 -0
- data/spec/fixtures/not_1.9.1/cassette_spec/erb_with_vars.yml +32 -0
- data/spec/fixtures/not_1.9.1/cassette_spec/example.yml +110 -0
- data/spec/fixtures/not_1.9.1/cassette_spec/with_localhost_requests.yml +86 -0
- data/spec/fixtures/not_1.9.1/example_net_http.yml +14 -0
- data/spec/fixtures/not_1.9.1/example_net_http_request.yml +12 -0
- data/spec/fixtures/not_1.9.1/example_net_http_response.yml +25 -0
- data/spec/fixtures/not_1.9.1/fake_example.com_responses.yml +106 -0
- data/spec/fixtures/not_1.9.1/match_requests_on.yml +185 -0
- data/spec/http_stubbing_adapters/fakeweb_spec.rb +35 -0
- data/spec/http_stubbing_adapters/webmock_spec.rb +35 -0
- data/spec/request_matcher_spec.rb +194 -0
- data/spec/spec_helper.rb +40 -0
- data/spec/structs_spec.rb +121 -0
- data/spec/support/disable_warnings.rb +12 -0
- data/spec/support/http_library_adapters.rb +272 -0
- data/spec/support/http_stubbing_adapter.rb +100 -0
- data/spec/support/pending_on_heroku.rb +14 -0
- data/spec/support/temp_cassette_library_dir.rb +16 -0
- data/spec/support/vcr_localhost_server.rb +53 -0
- data/spec/vcr_spec.rb +198 -0
- data/spec/version_spec.rb +11 -0
- data/vcr.gemspec +43 -0
- metadata +134 -73
- data/lib/vcr/http_stubbing_adapters/base.rb +0 -36
- data/lib/vcr/version.rbc +0 -572
data/spec/config_spec.rb
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe VCR::Config do
|
4
|
+
describe '#cassette_library_dir=' do
|
5
|
+
temp_dir(File.expand_path(File.dirname(__FILE__) + '/fixtures/config_spec'))
|
6
|
+
|
7
|
+
it 'creates the directory if it does not exist' do
|
8
|
+
lambda { VCR::Config.cassette_library_dir = @temp_dir }.should change { File.exist?(@temp_dir) }.from(false).to(true)
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'does not raise an error if given nil' do
|
12
|
+
lambda { VCR::Config.cassette_library_dir = nil }.should_not raise_error
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#default_cassette_options' do
|
17
|
+
it 'has a hash with some defaults even if it is set to nil' do
|
18
|
+
VCR::Config.default_cassette_options = nil
|
19
|
+
VCR::Config.default_cassette_options.should == { :match_requests_on => VCR::RequestMatcher::DEFAULT_MATCH_ATTRIBUTES }
|
20
|
+
end
|
21
|
+
|
22
|
+
it "returns #{VCR::RequestMatcher::DEFAULT_MATCH_ATTRIBUTES.inspect} for :match_requests_on when other defaults have been set" do
|
23
|
+
VCR::Config.default_cassette_options = { :record => :none }
|
24
|
+
VCR::Config.default_cassette_options.should == {
|
25
|
+
:record => :none,
|
26
|
+
:match_requests_on => VCR::RequestMatcher::DEFAULT_MATCH_ATTRIBUTES
|
27
|
+
}
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#http_stubbing_library' do
|
32
|
+
it 'returns the configured value' do
|
33
|
+
[:fakeweb, :webmock].each do |setting|
|
34
|
+
VCR::Config.http_stubbing_library = setting
|
35
|
+
VCR::Config.http_stubbing_library.should == setting
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'when set to nil' do
|
40
|
+
before(:each) { VCR::Config.http_stubbing_library = nil }
|
41
|
+
|
42
|
+
{
|
43
|
+
[:FakeWeb, :WebMock] => nil,
|
44
|
+
[] => nil,
|
45
|
+
[:FakeWeb] => :fakeweb,
|
46
|
+
[:WebMock] => :webmock
|
47
|
+
}.each do |defined_constants, expected_return_value|
|
48
|
+
it "returns #{expected_return_value.inspect} when these constants are defined: #{defined_constants.inspect}" do
|
49
|
+
[:FakeWeb, :WebMock].each do |const|
|
50
|
+
Object.should_receive(:const_defined?).with(const).and_return(defined_constants.include?(const))
|
51
|
+
end
|
52
|
+
VCR::Config.http_stubbing_library.should == expected_return_value
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe '#ignore_localhost' do
|
59
|
+
it 'sets VCR.http_stubbing_adapter.ignore_localhost?' do
|
60
|
+
[true, false].each do |val|
|
61
|
+
VCR.http_stubbing_adapter.ignore_localhost = !val
|
62
|
+
expect {
|
63
|
+
VCR::Config.ignore_localhost = val
|
64
|
+
}.to change { VCR.http_stubbing_adapter.ignore_localhost? }.from(!val).to(val)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'stores the value even when VCR.http_stubbing_adapter is nil' do
|
69
|
+
VCR.stub!(:http_stubbing_adapter).and_return(nil)
|
70
|
+
[true, false].each do |val|
|
71
|
+
VCR::Config.ignore_localhost = val
|
72
|
+
VCR::Config.ignore_localhost?.should == val
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe VCR::CucumberTags do
|
4
|
+
subject { described_class.new(self) }
|
5
|
+
let(:blocks_for_tags) { {} }
|
6
|
+
|
7
|
+
# define our own Around so we can test this in isolation from cucumber's implementation.
|
8
|
+
def Around(tag, &block)
|
9
|
+
blocks_for_tags[tag.sub('@', '')] = block
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_tag(cassette_attribute, tag, expected_value)
|
13
|
+
VCR.current_cassette.should be_nil
|
14
|
+
|
15
|
+
cassette_during_scenario, scenario = nil, lambda { cassette_during_scenario = VCR.current_cassette }
|
16
|
+
blocks_for_tags[tag].call(:scenario_name, scenario)
|
17
|
+
cassette_during_scenario.send(cassette_attribute).should == expected_value
|
18
|
+
|
19
|
+
VCR.current_cassette.should be_nil
|
20
|
+
end
|
21
|
+
|
22
|
+
%w(tags tag).each do |tag_method|
|
23
|
+
describe "##{tag_method}" do
|
24
|
+
it "creates a cucumber Around hook for each given tag so that the scenario runs with the cassette inserted" do
|
25
|
+
subject.send(tag_method, 'tag1', 'tag2')
|
26
|
+
|
27
|
+
test_tag(:name, 'tag1', 'cucumber_tags/tag1')
|
28
|
+
test_tag(:name, 'tag2', 'cucumber_tags/tag2')
|
29
|
+
end
|
30
|
+
|
31
|
+
it "works with tags that start with an @" do
|
32
|
+
subject.send(tag_method, '@tag1', '@tag2')
|
33
|
+
|
34
|
+
test_tag(:name, 'tag1', 'cucumber_tags/tag1')
|
35
|
+
test_tag(:name, 'tag2', 'cucumber_tags/tag2')
|
36
|
+
end
|
37
|
+
|
38
|
+
it "passes along the given options to the cassette" do
|
39
|
+
subject.send(tag_method, 'tag1', :record => :none)
|
40
|
+
subject.send(tag_method, 'tag2', :record => :new_episodes)
|
41
|
+
|
42
|
+
test_tag(:record_mode, 'tag1', :none)
|
43
|
+
test_tag(:record_mode, 'tag2', :new_episodes)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '.tags' do
|
49
|
+
it 'returns the list of cucumber tags' do
|
50
|
+
subject.tags 'tag1', 'tag2'
|
51
|
+
subject.tags 'tag3', 'tag4'
|
52
|
+
described_class.tags[-4, 4].should == %w(@tag1 @tag2 @tag3 @tag4)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe 'Deprecations' do
|
4
|
+
describe VCR::Cassette do
|
5
|
+
disable_warnings
|
6
|
+
subject { VCR::Cassette.new('cassette name') }
|
7
|
+
|
8
|
+
it 'raises an error when an :allow_real_http lambda is given' do
|
9
|
+
expect { VCR::Cassette.new('cassette name', :allow_real_http => lambda {}) }.to raise_error(ArgumentError)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "prints a warning: WARNING: VCR::Cassette#allow_real_http_requests_to? is deprecated and should no longer be used" do
|
13
|
+
subject.should_receive(:warn).with("WARNING: VCR::Cassette#allow_real_http_requests_to? is deprecated and should no longer be used.")
|
14
|
+
subject.allow_real_http_requests_to?(URI.parse('http://example.org'))
|
15
|
+
end
|
16
|
+
|
17
|
+
[true, false].each do |orig_ignore_localhost|
|
18
|
+
context "when the http_stubbing_adapter's ignore_localhost is set to #{orig_ignore_localhost}" do
|
19
|
+
before(:each) { VCR.http_stubbing_adapter.ignore_localhost = orig_ignore_localhost }
|
20
|
+
|
21
|
+
context 'when the :allow_real_http option is set to :localhost' do
|
22
|
+
subject { VCR::Cassette.new('cassette name', :allow_real_http => :localhost) }
|
23
|
+
|
24
|
+
it "sets the http_stubbing_adapter's ignore_localhost attribute to true" do
|
25
|
+
subject
|
26
|
+
VCR.http_stubbing_adapter.ignore_localhost?.should be_true
|
27
|
+
end
|
28
|
+
|
29
|
+
it "prints a warning: VCR's :allow_real_http cassette option is deprecated. Instead, use the ignore_localhost configuration option." do
|
30
|
+
Kernel.should_receive(:warn).with("WARNING: VCR's :allow_real_http cassette option is deprecated. Instead, use the ignore_localhost configuration option.")
|
31
|
+
subject
|
32
|
+
end
|
33
|
+
|
34
|
+
it "reverts ignore_localhost when the cassette is ejected" do
|
35
|
+
subject.eject
|
36
|
+
VCR.http_stubbing_adapter.ignore_localhost?.should == orig_ignore_localhost
|
37
|
+
end
|
38
|
+
|
39
|
+
{
|
40
|
+
'http://localhost' => true,
|
41
|
+
'http://127.0.0.1' => true,
|
42
|
+
'http://example.com' => false
|
43
|
+
}.each do |url, expected_value|
|
44
|
+
it "returns #{expected_value} for #allow_real_http_requests_to? when it is given #{url}" do
|
45
|
+
subject.allow_real_http_requests_to?(URI.parse(url)).should == expected_value
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe "Net::HTTP Response extensions" do
|
4
|
+
context 'extending an already read response' do
|
5
|
+
# WebMock uses this extension, too, and to prevent it from automatically being included
|
6
|
+
# (and hence, causing issues with this spec), we remove all callbacks for the duration
|
7
|
+
# of this spec, since the absence of any callbacks will prevent WebMock from reading the response
|
8
|
+
# and extending the response with the response extension.
|
9
|
+
before(:all) do
|
10
|
+
@orig_webmock_callbacks = ::WebMock::CallbackRegistry.callbacks.dup
|
11
|
+
::WebMock::CallbackRegistry.reset
|
12
|
+
end
|
13
|
+
|
14
|
+
after(:all) do
|
15
|
+
@orig_webmock_callbacks.each do |cb|
|
16
|
+
::WebMock::CallbackRegistry.add_callback(cb[:options], cb[:block])
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.it_allows_the_body_to_be_read_again
|
21
|
+
subject { @response.clone }
|
22
|
+
let(:expected_regex) { /You have reached this web page by typing.*example\.com/ }
|
23
|
+
|
24
|
+
it 'allows the body to be read using #body' do
|
25
|
+
subject.body.to_s.should =~ expected_regex
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'allows the body to be read using #read_body' do
|
29
|
+
subject.read_body.to_s.should =~ expected_regex
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'allows the body to be read using #read_body with a block' do
|
33
|
+
yielded_body = ''
|
34
|
+
ret_val = subject.read_body { |s| yielded_body << s }
|
35
|
+
yielded_body.should =~ expected_regex
|
36
|
+
ret_val.should be_instance_of(Net::ReadAdapter)
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'allows the body to be read by passing a destination string to #read_body' do
|
40
|
+
dest = ''
|
41
|
+
ret_val = subject.read_body(dest)
|
42
|
+
dest.should =~ expected_regex
|
43
|
+
ret_val.should == dest
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'raises an ArgumentError if both a destination string and a block is given to #read_body' do
|
47
|
+
dest = ''
|
48
|
+
expect { subject.read_body(dest) { |s| } }.should raise_error(ArgumentError, 'both arg and block given for HTTP method')
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'raises an IOError when #read_body is called twice with a block' do
|
52
|
+
subject.read_body { |s| }
|
53
|
+
expect { subject.read_body { |s| } }.to raise_error(IOError, /read_body called twice/)
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'raises an IOError when #read_body is called twice with a destination string' do
|
57
|
+
dest = ''
|
58
|
+
subject.read_body(dest)
|
59
|
+
expect { subject.read_body(dest) }.to raise_error(IOError, /read_body called twice/)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
context 'when the body has already been read using #read_body and a dest string' do
|
64
|
+
before(:each) do
|
65
|
+
http = Net::HTTP.new('example.com', 80)
|
66
|
+
dest = ''
|
67
|
+
@response = http.request_get('/') { |res| res.read_body(dest) }
|
68
|
+
@response.extend VCR::Net::HTTPResponse
|
69
|
+
end
|
70
|
+
|
71
|
+
it_allows_the_body_to_be_read_again
|
72
|
+
end
|
73
|
+
|
74
|
+
context 'when the body has already been read using #body' do
|
75
|
+
before(:each) do
|
76
|
+
http = Net::HTTP.new('example.com', 80)
|
77
|
+
@response = http.request_get('/')
|
78
|
+
@response.body
|
79
|
+
@response.extend VCR::Net::HTTPResponse
|
80
|
+
end
|
81
|
+
|
82
|
+
it_allows_the_body_to_be_read_again
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe "Net::HTTP Extensions" do
|
4
|
+
let(:uri) { URI.parse('http://example.com') }
|
5
|
+
|
6
|
+
it 'checks if the request is stubbed using a VCR::Request' do
|
7
|
+
VCR.http_stubbing_adapter.should_receive(:request_stubbed?) do |request, _|
|
8
|
+
request.uri.should == 'http://example.com:80/'
|
9
|
+
request.method.should == :get
|
10
|
+
true
|
11
|
+
end
|
12
|
+
Net::HTTP.get(uri)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "checks if the request is stubbed using the current VCR cassette's match_request_on option" do
|
16
|
+
VCR.should_receive(:current_cassette).and_return(stub(:match_requests_on => [:body, :header]))
|
17
|
+
VCR.http_stubbing_adapter.should_receive(:request_stubbed?).with(anything, [:body, :header]).and_return(true)
|
18
|
+
Net::HTTP.get(uri)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "checks if the request is stubbed using the default match attributes when there is no current cassette" do
|
22
|
+
VCR.should_receive(:current_cassette).and_return(nil)
|
23
|
+
VCR.http_stubbing_adapter.should_receive(:request_stubbed?).with(anything, VCR::RequestMatcher::DEFAULT_MATCH_ATTRIBUTES).and_return(true)
|
24
|
+
Net::HTTP.get(uri)
|
25
|
+
end
|
26
|
+
|
27
|
+
describe 'a request that is not registered with the http stubbing adapter' do
|
28
|
+
before(:each) do
|
29
|
+
VCR.http_stubbing_adapter.stub(:request_stubbed?).and_return(false)
|
30
|
+
end
|
31
|
+
|
32
|
+
def perform_get_with_returning_block
|
33
|
+
Net::HTTP.new('example.com', 80).request(Net::HTTP::Get.new('/', {})) do |response|
|
34
|
+
return response
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
it "does not record headers for which Net::HTTP sets defaults near the end of the real request" do
|
39
|
+
VCR.should_receive(:record_http_interaction) do |interaction|
|
40
|
+
interaction.request.headers.should_not have_key('content-type')
|
41
|
+
interaction.request.headers.should_not have_key('host')
|
42
|
+
end
|
43
|
+
Net::HTTP.new('example.com', 80).send_request('POST', '/', '', {})
|
44
|
+
end
|
45
|
+
|
46
|
+
it "records headers for which Net::HTTP usually sets defaults when the user manually sets their values" do
|
47
|
+
VCR.should_receive(:record_http_interaction) do |interaction|
|
48
|
+
interaction.request.headers['content-type'].should == ['foo/bar']
|
49
|
+
interaction.request.headers['host'].should == ['my-example.com']
|
50
|
+
end
|
51
|
+
Net::HTTP.new('example.com', 80).send_request('POST', '/', '', { 'Content-Type' => 'foo/bar', 'Host' => 'my-example.com' })
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'calls VCR.record_http_interaction' do
|
55
|
+
VCR.should_receive(:record_http_interaction).with(instance_of(VCR::HTTPInteraction))
|
56
|
+
Net::HTTP.get(uri)
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'calls #record_http_interaction only once, even when Net::HTTP internally recursively calls #request' do
|
60
|
+
VCR.should_receive(:record_http_interaction).once
|
61
|
+
Net::HTTP.new('example.com', 80).post('/', nil)
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'calls #record_http_interaction when Net::HTTP#request is called with a block with a return statement' do
|
65
|
+
VCR.should_receive(:record_http_interaction).once
|
66
|
+
perform_get_with_returning_block
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe 'a request that is registered with the http stubbing adapter' do
|
71
|
+
it 'does not call #record_http_interaction on the current cassette' do
|
72
|
+
VCR.http_stubbing_adapter.stub(:request_stubbed?).and_return(true)
|
73
|
+
VCR.should_receive(:record_http_interaction).never
|
74
|
+
Net::HTTP.get(uri)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
---
|
2
|
+
- !ruby/struct:VCR::RecordedResponse
|
3
|
+
:method: :post
|
4
|
+
:uri: http://example.com:80/
|
5
|
+
:response: !ruby/object:Net::HTTPOK
|
6
|
+
body: The response from example.com
|
7
|
+
body_exist: true
|
8
|
+
code: "200"
|
9
|
+
header:
|
10
|
+
etag:
|
11
|
+
- "\"24ec5-1b6-4059a80bfd280\""
|
12
|
+
last-modified:
|
13
|
+
- Tue, 15 Nov 2005 13:24:10 GMT
|
14
|
+
content-type:
|
15
|
+
- text/html; charset=UTF-8
|
16
|
+
connection:
|
17
|
+
- close
|
18
|
+
server:
|
19
|
+
- Apache/2.2.3 (CentOS)
|
20
|
+
date:
|
21
|
+
- Wed, 31 Mar 2010 02:43:26 GMT
|
22
|
+
content-length:
|
23
|
+
- "438"
|
24
|
+
accept-ranges:
|
25
|
+
- bytes
|
26
|
+
http_version: "1.1"
|
27
|
+
message: OK
|
28
|
+
read: true
|
29
|
+
socket:
|
@@ -0,0 +1,32 @@
|
|
1
|
+
---
|
2
|
+
- !ruby/struct:VCR::HTTPInteraction
|
3
|
+
:request: !ruby/struct:VCR::Request
|
4
|
+
:method: :get
|
5
|
+
:uri: http://example.com:80/
|
6
|
+
:body:
|
7
|
+
:headers:
|
8
|
+
:response: !ruby/struct:VCR::Response
|
9
|
+
:status: !ruby/struct:VCR::ResponseStatus
|
10
|
+
:code: 200
|
11
|
+
:message: OK
|
12
|
+
:headers:
|
13
|
+
etag:
|
14
|
+
- "\"24ec5-1b6-4059a80bfd280\""
|
15
|
+
last-modified:
|
16
|
+
- Tue, 15 Nov 2005 13:24:10 GMT
|
17
|
+
connection:
|
18
|
+
- Keep-Alive
|
19
|
+
content-type:
|
20
|
+
- text/html; charset=UTF-8
|
21
|
+
date:
|
22
|
+
- Thu, 25 Feb 2010 07:53:51 GMT
|
23
|
+
server:
|
24
|
+
- Apache/2.2.3 (CentOS)
|
25
|
+
content-length:
|
26
|
+
- "438"
|
27
|
+
age:
|
28
|
+
- "9260"
|
29
|
+
accept-ranges:
|
30
|
+
- bytes
|
31
|
+
:body: "sum: <%= 1 + 2 %>"
|
32
|
+
:http_version: "1.1"
|
@@ -0,0 +1,32 @@
|
|
1
|
+
---
|
2
|
+
- !ruby/struct:VCR::HTTPInteraction
|
3
|
+
:request: !ruby/struct:VCR::Request
|
4
|
+
:method: :get
|
5
|
+
:uri: http://example.com:80/
|
6
|
+
:body:
|
7
|
+
:headers:
|
8
|
+
:response: !ruby/struct:VCR::Response
|
9
|
+
:status: !ruby/struct:VCR::ResponseStatus
|
10
|
+
:code: 200
|
11
|
+
:message: OK
|
12
|
+
:headers:
|
13
|
+
etag:
|
14
|
+
- "\"24ec5-1b6-4059a80bfd280\""
|
15
|
+
last-modified:
|
16
|
+
- Tue, 15 Nov 2005 13:24:10 GMT
|
17
|
+
connection:
|
18
|
+
- Keep-Alive
|
19
|
+
content-type:
|
20
|
+
- text/html; charset=UTF-8
|
21
|
+
date:
|
22
|
+
- Thu, 25 Feb 2010 07:53:51 GMT
|
23
|
+
server:
|
24
|
+
- Apache/2.2.3 (CentOS)
|
25
|
+
content-length:
|
26
|
+
- "438"
|
27
|
+
age:
|
28
|
+
- "9260"
|
29
|
+
accept-ranges:
|
30
|
+
- bytes
|
31
|
+
:body: "var1: <%= var1 %>; var2: <%= var2 %>; var3: <%= var3 %>"
|
32
|
+
:http_version: "1.1"
|