vcr 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +62 -0
- data/README.md +224 -0
- data/Rakefile +12 -5
- data/VERSION +1 -1
- data/benchmarks/http_stubbing_libraries.rb +59 -0
- data/features/fixtures/vcr_cassettes/1.8.6/cucumber_tags/replay_cassette1.yml +25 -25
- data/features/fixtures/vcr_cassettes/1.8.6/cucumber_tags/replay_cassette2.yml +32 -30
- data/features/fixtures/vcr_cassettes/1.8.6/cucumber_tags/replay_cassette3.yml +40 -40
- data/features/fixtures/vcr_cassettes/1.8.6/nested_replay_cassette.yml +16 -15
- data/features/fixtures/vcr_cassettes/1.8.6/not_the_real_response.yml +25 -25
- data/features/fixtures/vcr_cassettes/1.8.7/cucumber_tags/replay_cassette1.yml +23 -23
- data/features/fixtures/vcr_cassettes/1.8.7/cucumber_tags/replay_cassette2.yml +24 -22
- data/features/fixtures/vcr_cassettes/1.8.7/cucumber_tags/replay_cassette3.yml +36 -36
- data/features/fixtures/vcr_cassettes/1.8.7/nested_replay_cassette.yml +12 -11
- data/features/fixtures/vcr_cassettes/1.8.7/not_the_real_response.yml +23 -23
- data/features/fixtures/vcr_cassettes/1.9.1/cucumber_tags/replay_cassette1.yml +24 -24
- data/features/fixtures/vcr_cassettes/1.9.1/cucumber_tags/replay_cassette2.yml +26 -24
- data/features/fixtures/vcr_cassettes/1.9.1/cucumber_tags/replay_cassette3.yml +38 -38
- data/features/fixtures/vcr_cassettes/1.9.1/nested_replay_cassette.yml +13 -12
- data/features/fixtures/vcr_cassettes/1.9.1/not_the_real_response.yml +24 -24
- data/features/record_response.feature +2 -2
- data/features/replay_recorded_response.feature +1 -1
- data/features/step_definitions/vcr_steps.rb +8 -8
- data/features/support/env.rb +6 -0
- data/lib/vcr.rb +16 -3
- data/lib/vcr/cassette.rb +49 -46
- data/lib/vcr/config.rb +8 -0
- data/lib/vcr/extensions/fake_web.rb +12 -26
- data/lib/vcr/extensions/net_http.rb +9 -26
- data/lib/vcr/http_stubbing_adapters/base.rb +34 -0
- data/lib/vcr/http_stubbing_adapters/fakeweb.rb +75 -0
- data/lib/vcr/http_stubbing_adapters/webmock.rb +80 -0
- data/lib/vcr/structs.rb +44 -0
- data/lib/vcr/task_runner.rb +47 -0
- data/lib/vcr/tasks/vcr.rake +9 -0
- data/spec/cassette_spec.rb +70 -71
- data/spec/config_spec.rb +27 -0
- data/spec/extensions/net_http_spec.rb +21 -17
- data/spec/fixtures/1.8.6/0_3_1_cassette.yml +29 -0
- data/spec/fixtures/1.8.6/cassette_spec/example.yml +110 -108
- data/spec/fixtures/1.8.6/example_net_http.yml +14 -0
- data/spec/fixtures/1.8.6/example_net_http_request.yml +12 -0
- data/spec/fixtures/1.8.6/example_net_http_response.yml +25 -0
- data/spec/fixtures/1.8.6/fake_example.com_responses.yml +90 -0
- data/spec/fixtures/1.8.7/0_3_1_cassette.yml +29 -0
- data/spec/fixtures/1.8.7/cassette_spec/example.yml +110 -108
- data/spec/fixtures/1.8.7/example_net_http.yml +14 -0
- data/spec/fixtures/1.8.7/example_net_http_request.yml +12 -0
- data/spec/fixtures/1.8.7/example_net_http_response.yml +25 -0
- data/spec/fixtures/1.8.7/fake_example.com_responses.yml +90 -0
- data/spec/fixtures/1.9.1/0_3_1_cassette.yml +29 -0
- data/spec/fixtures/1.9.1/cassette_spec/example.yml +62 -59
- 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 +90 -0
- data/spec/http_stubbing_adapters/fakeweb_spec.rb +24 -0
- data/spec/http_stubbing_adapters/webmock_spec.rb +23 -0
- data/spec/spec_helper.rb +5 -0
- data/spec/structs_spec.rb +95 -0
- data/spec/support/http_stubbing_adapter.rb +113 -0
- data/spec/task_runner_spec.rb +59 -0
- data/spec/vcr_spec.rb +37 -0
- data/vcr.gemspec +45 -15
- metadata +67 -26
- data/History.rdoc +0 -31
- data/README.rdoc +0 -222
- data/lib/vcr/recorded_response.rb +0 -4
- data/spec/extensions/fake_web_spec.rb +0 -63
- data/spec/recorded_response_spec.rb +0 -25
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe VCR::HttpStubbingAdapters::FakeWeb do
|
4
|
+
it_should_behave_like 'an http stubbing adapter'
|
5
|
+
|
6
|
+
describe '#check_version!' do
|
7
|
+
before(:each) { @orig_version = FakeWeb::VERSION }
|
8
|
+
after(:each) { FakeWeb::VERSION = @orig_version }
|
9
|
+
|
10
|
+
%w( 1.2.8 1.2.9 1.2.10 1.3.0 1.10.0 2.0.0 ).each do |version|
|
11
|
+
it "does nothing when FakeWeb's version is #{version}" do
|
12
|
+
FakeWeb::VERSION = version
|
13
|
+
expect { described_class.check_version! }.to_not raise_error
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
%w( 1.2.7 1.1.30 0.30.30 ).each do |version|
|
18
|
+
it "raises an error when FakeWeb's version is #{version}" do
|
19
|
+
FakeWeb::VERSION = version
|
20
|
+
expect { described_class.check_version! }.to raise_error(/You are using FakeWeb #{version}. VCR requires version .* or greater/)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe VCR::HttpStubbingAdapters::WebMock do
|
4
|
+
it_should_behave_like 'an http stubbing adapter'
|
5
|
+
|
6
|
+
describe '#check_version!' do
|
7
|
+
before(:each) { WebMock.should respond_to(:version) }
|
8
|
+
|
9
|
+
%w( 1.1.0 1.1.1 1.2.0 2.0.0 ).each do |version|
|
10
|
+
it "does nothing when WebMock's version is #{version}" do
|
11
|
+
WebMock.stub!(:version).and_return(version)
|
12
|
+
expect { described_class.check_version! }.to_not raise_error
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
%w( 0.9.9 0.9.10 0.1.30 1.0.30 ).each do |version|
|
17
|
+
it "raises an error when WebMock's version is #{version}" do
|
18
|
+
WebMock.stub!(:version).and_return(version)
|
19
|
+
expect { described_class.check_version! }.to raise_error(/You are using WebMock #{version}. VCR requires version .* or greater/)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -24,6 +24,11 @@ Spec::Runner.configure do |config|
|
|
24
24
|
|
25
25
|
config.before(:each) do
|
26
26
|
VCR::Config.default_cassette_options = { :record => :new_episodes }
|
27
|
+
VCR::Config.http_stubbing_library = :fakeweb
|
28
|
+
|
29
|
+
WebMock.allow_net_connect!
|
30
|
+
WebMock.reset_webmock
|
31
|
+
|
27
32
|
FakeWeb.allow_net_connect = true
|
28
33
|
FakeWeb.clean_registry
|
29
34
|
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe VCR::Request do
|
4
|
+
describe '.from_net_http_request' do
|
5
|
+
let(:net_http) { YAML.load(File.read(File.dirname(__FILE__) + "/fixtures/#{RUBY_VERSION}/example_net_http.yml")) }
|
6
|
+
let(:request) { YAML.load(File.read(File.dirname(__FILE__) + "/fixtures/#{RUBY_VERSION}/example_net_http_request.yml")) }
|
7
|
+
subject { described_class.from_net_http_request(net_http, request) }
|
8
|
+
|
9
|
+
before(:each) do
|
10
|
+
VCR.http_stubbing_adapter.should respond_to(:request_uri)
|
11
|
+
VCR.http_stubbing_adapter.stub!(:request_uri)
|
12
|
+
end
|
13
|
+
|
14
|
+
it { should be_instance_of(VCR::Request) }
|
15
|
+
its(:method) { should == :post }
|
16
|
+
its(:body) { should == 'id=7' }
|
17
|
+
its(:headers) { should == {
|
18
|
+
'accept' => ['*/*'],
|
19
|
+
'content-type' => ['application/x-www-form-urlencoded']
|
20
|
+
} }
|
21
|
+
|
22
|
+
it 'sets the uri using the http_stubbing_adapter.request_uri' do
|
23
|
+
VCR.http_stubbing_adapter.should_receive(:request_uri).with(net_http, request).and_return('foo/bar')
|
24
|
+
subject.uri.should == 'foo/bar'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe VCR::ResponseStatus do
|
30
|
+
describe '.from_net_http_response' do
|
31
|
+
let(:response) { YAML.load(File.read(File.dirname(__FILE__) + "/fixtures/#{RUBY_VERSION}/example_net_http_response.yml")) }
|
32
|
+
subject { described_class.from_net_http_response(response) }
|
33
|
+
|
34
|
+
it { should be_instance_of(described_class) }
|
35
|
+
its(:code) { should == 200 }
|
36
|
+
its(:message) { should == 'OK' }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe VCR::Response do
|
41
|
+
describe '.from_net_http_response' do
|
42
|
+
let(:response) { YAML.load(File.read(File.dirname(__FILE__) + "/fixtures/#{RUBY_VERSION}/example_net_http_response.yml")) }
|
43
|
+
subject { described_class.from_net_http_response(response) }
|
44
|
+
|
45
|
+
it { should be_instance_of(described_class) }
|
46
|
+
its(:body) { should == 'The response from example.com' }
|
47
|
+
its(:http_version) { should == '1.1' }
|
48
|
+
its(:headers) { should == {
|
49
|
+
"last-modified" => ['Tue, 15 Nov 2005 13:24:10 GMT'],
|
50
|
+
"connection" => ['close'],
|
51
|
+
"etag" => ["\"24ec5-1b6-4059a80bfd280\""],
|
52
|
+
"content-type" => ["text/html; charset=UTF-8"],
|
53
|
+
"date" => ['Wed, 31 Mar 2010 02:43:26 GMT'],
|
54
|
+
"server" => ['Apache/2.2.3 (CentOS)'],
|
55
|
+
"content-length" => ['438'],
|
56
|
+
"accept-ranges" => ['bytes']
|
57
|
+
} }
|
58
|
+
|
59
|
+
it 'assigns the status using VCR::ResponseStatus.from_net_http_response' do
|
60
|
+
VCR::ResponseStatus.should respond_to(:from_net_http_response)
|
61
|
+
VCR::ResponseStatus.should_receive(:from_net_http_response).with(response).and_return(:the_status)
|
62
|
+
subject.status.should == :the_status
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe VCR::HTTPInteraction do
|
68
|
+
describe '.from_net_http_objects' do
|
69
|
+
let(:response) { YAML.load(File.read(File.dirname(__FILE__) + "/fixtures/#{RUBY_VERSION}/example_net_http_response.yml")) }
|
70
|
+
let(:net_http) { YAML.load(File.read(File.dirname(__FILE__) + "/fixtures/#{RUBY_VERSION}/example_net_http.yml")) }
|
71
|
+
let(:request) { YAML.load(File.read(File.dirname(__FILE__) + "/fixtures/#{RUBY_VERSION}/example_net_http_request.yml")) }
|
72
|
+
subject { described_class.from_net_http_objects(net_http, request, response) }
|
73
|
+
|
74
|
+
it 'returns a new record with the proper values' do
|
75
|
+
VCR::Request.should respond_to(:from_net_http_request)
|
76
|
+
VCR::Request.should_receive(:from_net_http_request).with(net_http, request).and_return(:the_request)
|
77
|
+
|
78
|
+
VCR::Response.should respond_to(:from_net_http_response)
|
79
|
+
VCR::Response.should_receive(:from_net_http_response).with(response).and_return(:the_response)
|
80
|
+
|
81
|
+
subject.should be_instance_of(VCR::HTTPInteraction)
|
82
|
+
subject.request.should == :the_request
|
83
|
+
subject.response.should == :the_response
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
%w( uri method ).each do |attr|
|
88
|
+
it "delegates :#{attr} to the request signature" do
|
89
|
+
sig = mock('request signature')
|
90
|
+
sig.should_receive(attr).and_return(:the_value)
|
91
|
+
instance = described_class.new(sig, nil)
|
92
|
+
instance.send(attr).should == :the_value
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
shared_examples_for "an http stubbing adapter" do
|
2
|
+
subject { described_class }
|
3
|
+
|
4
|
+
def make_http_request(method, path, body = {})
|
5
|
+
case method
|
6
|
+
when :get
|
7
|
+
Net::HTTP.get_response(URI.parse('http://example.com' + path))
|
8
|
+
when :post
|
9
|
+
Net::HTTP.post_form(URI.parse('http://example.com' + path), body)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.test_real_http_request(http_allowed)
|
14
|
+
if http_allowed
|
15
|
+
it 'allows real http requests' do
|
16
|
+
make_http_request(:get, '/foo').body.should =~ /The requested URL \/foo was not found/
|
17
|
+
end
|
18
|
+
else
|
19
|
+
it 'does not allow real HTTP requests' do
|
20
|
+
lambda { make_http_request(:get, '/foo') }.should raise_error(StandardError, /You can use VCR to automatically record this request and replay it later/)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
[true, false].each do |http_allowed|
|
26
|
+
context "when #http_connections_allowed is set to #{http_allowed}" do
|
27
|
+
before(:each) { subject.http_connections_allowed = http_allowed }
|
28
|
+
|
29
|
+
it "returns #{http_allowed} for #http_connections_allowed?" do
|
30
|
+
subject.http_connections_allowed?.should == http_allowed
|
31
|
+
end
|
32
|
+
|
33
|
+
test_real_http_request(http_allowed)
|
34
|
+
|
35
|
+
context 'when some requests are stubbed, after setting a checkpoint' do
|
36
|
+
before(:each) do
|
37
|
+
subject.create_stubs_checkpoint(:my_checkpoint)
|
38
|
+
@recorded_interactions = YAML.load(File.read(File.join(File.dirname(__FILE__), '..', 'fixtures', RUBY_VERSION, 'fake_example.com_responses.yml')))
|
39
|
+
subject.stub_requests(@recorded_interactions)
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'returns true from #request_stubbed? for the requests that are stubbed' do
|
43
|
+
subject.request_stubbed?(:post, 'http://example.com').should be_true
|
44
|
+
subject.request_stubbed?(:get, 'http://example.com/foo').should be_true
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'returns false from #request_stubbed? for requests that are not stubbed' do
|
48
|
+
subject.request_stubbed?(:post, 'http://example.com/foo').should be_false
|
49
|
+
subject.request_stubbed?(:get, 'http://google.com').should be_false
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'gets the stubbed responses when multple post requests are made to http://example.com' do
|
53
|
+
make_http_request(:post, '/', { 'id' => '7' }).body.should == 'example.com post response with id=7'
|
54
|
+
make_http_request(:post, '/', { 'id' => '3' }).body.should == 'example.com post response with id=3'
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'gets the stubbed responses when requests are made to http://example.com/foo' do
|
58
|
+
make_http_request(:get, '/foo').body.should == 'example.com get response with path=foo'
|
59
|
+
end
|
60
|
+
|
61
|
+
context 'when we restore our previous check point' do
|
62
|
+
before(:each) { subject.restore_stubs_checkpoint(:my_checkpoint) }
|
63
|
+
|
64
|
+
test_real_http_request(http_allowed)
|
65
|
+
|
66
|
+
it 'returns false from #request_stubbed?' do
|
67
|
+
subject.request_stubbed?(:get, 'http://example.com/foo').should be_false
|
68
|
+
subject.request_stubbed?(:post, 'http://example.com').should be_false
|
69
|
+
subject.request_stubbed?(:get, 'http://google.com').should be_false
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe '#request_uri' do
|
77
|
+
it 'returns the uri for the given http request' do
|
78
|
+
net_http = Net::HTTP.new('example.com', 80)
|
79
|
+
request = Net::HTTP::Get.new('/foo/bar')
|
80
|
+
subject.request_uri(net_http, request).should == 'http://example.com:80/foo/bar'
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe "#with_http_connections_allowed_set_to" do
|
85
|
+
it 'sets http_connections_allowed for the duration of the block to the provided value' do
|
86
|
+
[true, false].each do |expected|
|
87
|
+
yielded_value = :not_set
|
88
|
+
subject.with_http_connections_allowed_set_to(expected) { yielded_value = subject.http_connections_allowed? }
|
89
|
+
yielded_value.should == expected
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'returns the value returned by the block' do
|
94
|
+
subject.with_http_connections_allowed_set_to(true) { :return_value }.should == :return_value
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'reverts http_connections_allowed when the block completes' do
|
98
|
+
[true, false].each do |expected|
|
99
|
+
subject.http_connections_allowed = expected
|
100
|
+
subject.with_http_connections_allowed_set_to(true) { }
|
101
|
+
subject.http_connections_allowed?.should == expected
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'reverts http_connections_allowed when the block completes, even if an error is raised' do
|
106
|
+
[true, false].each do |expected|
|
107
|
+
subject.http_connections_allowed = expected
|
108
|
+
lambda { subject.with_http_connections_allowed_set_to(true) { raise RuntimeError } }.should raise_error(RuntimeError)
|
109
|
+
subject.http_connections_allowed?.should == expected
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'vcr/task_runner'
|
3
|
+
|
4
|
+
describe VCR::TaskRunner do
|
5
|
+
describe '.migrate_cassettes' do
|
6
|
+
temp_dir File.expand_path(File.dirname(__FILE__) + '/fixtures/task_runner')
|
7
|
+
|
8
|
+
let(:file_name) { '0_3_1_cassette.yml' }
|
9
|
+
let(:orig_file_name) { File.dirname(__FILE__) + "/fixtures/#{RUBY_VERSION}/#{file_name}" }
|
10
|
+
let(:test_dir) { @temp_dir + '/migrate_cassettes' }
|
11
|
+
|
12
|
+
def migrate
|
13
|
+
VCR::TaskRunner.migrate_cassettes(test_dir)
|
14
|
+
end
|
15
|
+
|
16
|
+
before(:each) do
|
17
|
+
FileUtils.mkdir_p(test_dir)
|
18
|
+
FileUtils.cp(orig_file_name, test_dir)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'makes a backup of the directory' do
|
22
|
+
migrate
|
23
|
+
expected_backup_dir_name = test_dir + '-backup'
|
24
|
+
expected_backup_file_name = expected_backup_dir_name + "/#{file_name}"
|
25
|
+
File.exist?(expected_backup_dir_name).should be_true
|
26
|
+
File.file?(expected_backup_file_name).should be_true
|
27
|
+
File.read(expected_backup_file_name).should == File.read(orig_file_name)
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'does not error out on yaml files with individual records' do
|
31
|
+
YAML.should_receive(:load).and_return(VCR::Request.new(:get, 'http://example.com'))
|
32
|
+
migrate
|
33
|
+
end
|
34
|
+
|
35
|
+
describe 'the structure serialized in the new 0_3_1_cassette_yml file' do
|
36
|
+
subject do
|
37
|
+
migrate
|
38
|
+
YAML.load(File.read(test_dir + "/#{file_name}")).first
|
39
|
+
end
|
40
|
+
|
41
|
+
its(:request) { should be_instance_of(VCR::Request) }
|
42
|
+
|
43
|
+
describe '.request' do
|
44
|
+
def subject; super.request; end
|
45
|
+
|
46
|
+
its(:method) { should == :post }
|
47
|
+
its(:uri) { should == 'http://example.com:80/' }
|
48
|
+
its(:body) { should be_nil }
|
49
|
+
its(:headers) { should be_nil }
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'assigns the response using VCR::Response.from_net_http_response' do
|
53
|
+
VCR::Response.should respond_to(:from_net_http_response)
|
54
|
+
VCR::Response.should_receive(:from_net_http_response).with(an_instance_of(Net::HTTPOK)).and_return(:the_response)
|
55
|
+
subject.response.should == :the_response
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
data/spec/vcr_spec.rb
CHANGED
@@ -68,6 +68,18 @@ describe VCR do
|
|
68
68
|
end
|
69
69
|
yielded_object.should == VCR::Config
|
70
70
|
end
|
71
|
+
|
72
|
+
it "disallows http connections" do
|
73
|
+
VCR.http_stubbing_adapter.should respond_to(:http_connections_allowed=)
|
74
|
+
VCR.http_stubbing_adapter.should_receive(:http_connections_allowed=).with(false)
|
75
|
+
VCR.config { }
|
76
|
+
end
|
77
|
+
|
78
|
+
it "checks the adapted library's version to make sure it's compatible with VCR" do
|
79
|
+
VCR.http_stubbing_adapter.should respond_to(:check_version!)
|
80
|
+
VCR.http_stubbing_adapter.should_receive(:check_version!)
|
81
|
+
VCR.config { }
|
82
|
+
end
|
71
83
|
end
|
72
84
|
|
73
85
|
describe 'cucumber_tags' do
|
@@ -79,4 +91,29 @@ describe VCR do
|
|
79
91
|
yielded_object.should be_instance_of(VCR::CucumberTags)
|
80
92
|
end
|
81
93
|
end
|
94
|
+
|
95
|
+
describe '#http_stubbing_adapter' do
|
96
|
+
subject { VCR.http_stubbing_adapter }
|
97
|
+
before(:each) do
|
98
|
+
VCR.instance_variable_set(:@http_stubbing_adapter, nil)
|
99
|
+
end
|
100
|
+
|
101
|
+
{
|
102
|
+
:fakeweb => VCR::HttpStubbingAdapters::FakeWeb,
|
103
|
+
:webmock => VCR::HttpStubbingAdapters::WebMock
|
104
|
+
}.each do |setting, adapter|
|
105
|
+
context "when config http_stubbing_library = :#{setting.to_s}" do
|
106
|
+
before(:each) { VCR::Config.http_stubbing_library = setting }
|
107
|
+
|
108
|
+
it "returns #{adapter}" do
|
109
|
+
subject.should == adapter
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'raises an error when library is not set' do
|
115
|
+
VCR::Config.http_stubbing_library = nil
|
116
|
+
lambda { subject }.should raise_error(/The http stubbing library is not configured correctly/)
|
117
|
+
end
|
118
|
+
end
|
82
119
|
end
|
data/vcr.gemspec
CHANGED
@@ -5,25 +5,26 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{vcr}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.4.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Myron Marston"]
|
12
|
-
s.date = %q{2010-04-
|
13
|
-
s.description = %q{VCR provides helpers to record HTTP
|
12
|
+
s.date = %q{2010-04-28}
|
13
|
+
s.description = %q{VCR provides helpers to record your test suite's HTTP interactions and replay them during future test runs for fast, deterministic, accurate tests. It works with any ruby testing framework, and provides built-in support for cucumber.}
|
14
14
|
s.email = %q{myron.marston@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE",
|
17
|
-
"README.
|
17
|
+
"README.md"
|
18
18
|
]
|
19
19
|
s.files = [
|
20
20
|
".document",
|
21
21
|
".gitignore",
|
22
|
-
"
|
22
|
+
"CHANGELOG.md",
|
23
23
|
"LICENSE",
|
24
|
-
"README.
|
24
|
+
"README.md",
|
25
25
|
"Rakefile",
|
26
26
|
"VERSION",
|
27
|
+
"benchmarks/http_stubbing_libraries.rb",
|
27
28
|
"features/fixtures/vcr_cassettes/1.8.6/cucumber_tags/replay_cassette1.yml",
|
28
29
|
"features/fixtures/vcr_cassettes/1.8.6/cucumber_tags/replay_cassette2.yml",
|
29
30
|
"features/fixtures/vcr_cassettes/1.8.6/cucumber_tags/replay_cassette3.yml",
|
@@ -51,23 +52,46 @@ Gem::Specification.new do |s|
|
|
51
52
|
"lib/vcr/extensions/fake_web.rb",
|
52
53
|
"lib/vcr/extensions/net_http.rb",
|
53
54
|
"lib/vcr/extensions/net_read_adapter.rb",
|
54
|
-
"lib/vcr/
|
55
|
+
"lib/vcr/http_stubbing_adapters/base.rb",
|
56
|
+
"lib/vcr/http_stubbing_adapters/fakeweb.rb",
|
57
|
+
"lib/vcr/http_stubbing_adapters/webmock.rb",
|
58
|
+
"lib/vcr/structs.rb",
|
59
|
+
"lib/vcr/task_runner.rb",
|
60
|
+
"lib/vcr/tasks/vcr.rake",
|
55
61
|
"spec/cassette_spec.rb",
|
56
62
|
"spec/config_spec.rb",
|
57
63
|
"spec/cucumber_tags_spec.rb",
|
58
64
|
"spec/deprecations_spec.rb",
|
59
|
-
"spec/extensions/fake_web_spec.rb",
|
60
65
|
"spec/extensions/net_http_spec.rb",
|
61
66
|
"spec/extensions/net_read_adapter_spec.rb",
|
67
|
+
"spec/fixtures/1.8.6/0_3_1_cassette.yml",
|
62
68
|
"spec/fixtures/1.8.6/cassette_spec/example.yml",
|
69
|
+
"spec/fixtures/1.8.6/example_net_http.yml",
|
70
|
+
"spec/fixtures/1.8.6/example_net_http_request.yml",
|
71
|
+
"spec/fixtures/1.8.6/example_net_http_response.yml",
|
72
|
+
"spec/fixtures/1.8.6/fake_example.com_responses.yml",
|
73
|
+
"spec/fixtures/1.8.7/0_3_1_cassette.yml",
|
63
74
|
"spec/fixtures/1.8.7/cassette_spec/example.yml",
|
75
|
+
"spec/fixtures/1.8.7/example_net_http.yml",
|
76
|
+
"spec/fixtures/1.8.7/example_net_http_request.yml",
|
77
|
+
"spec/fixtures/1.8.7/example_net_http_response.yml",
|
78
|
+
"spec/fixtures/1.8.7/fake_example.com_responses.yml",
|
79
|
+
"spec/fixtures/1.9.1/0_3_1_cassette.yml",
|
64
80
|
"spec/fixtures/1.9.1/cassette_spec/example.yml",
|
65
|
-
"spec/
|
81
|
+
"spec/fixtures/1.9.1/example_net_http.yml",
|
82
|
+
"spec/fixtures/1.9.1/example_net_http_request.yml",
|
83
|
+
"spec/fixtures/1.9.1/example_net_http_response.yml",
|
84
|
+
"spec/fixtures/1.9.1/fake_example.com_responses.yml",
|
85
|
+
"spec/http_stubbing_adapters/fakeweb_spec.rb",
|
86
|
+
"spec/http_stubbing_adapters/webmock_spec.rb",
|
66
87
|
"spec/spec.opts",
|
67
88
|
"spec/spec_helper.rb",
|
89
|
+
"spec/structs_spec.rb",
|
68
90
|
"spec/support/deprecated.rb",
|
69
91
|
"spec/support/disable_warnings.rb",
|
92
|
+
"spec/support/http_stubbing_adapter.rb",
|
70
93
|
"spec/support/temp_cassette_library_dir.rb",
|
94
|
+
"spec/task_runner_spec.rb",
|
71
95
|
"spec/vcr_spec.rb",
|
72
96
|
"vcr.gemspec"
|
73
97
|
]
|
@@ -75,20 +99,23 @@ Gem::Specification.new do |s|
|
|
75
99
|
s.rdoc_options = ["--charset=UTF-8"]
|
76
100
|
s.require_paths = ["lib"]
|
77
101
|
s.rubygems_version = %q{1.3.6}
|
78
|
-
s.summary = %q{
|
102
|
+
s.summary = %q{Record your test suite's HTTP interactions and replay them during future test runs for fast, deterministic, accurate tests.}
|
79
103
|
s.test_files = [
|
80
104
|
"spec/cassette_spec.rb",
|
81
105
|
"spec/config_spec.rb",
|
82
106
|
"spec/cucumber_tags_spec.rb",
|
83
107
|
"spec/deprecations_spec.rb",
|
84
|
-
"spec/extensions/fake_web_spec.rb",
|
85
108
|
"spec/extensions/net_http_spec.rb",
|
86
109
|
"spec/extensions/net_read_adapter_spec.rb",
|
87
|
-
"spec/
|
110
|
+
"spec/http_stubbing_adapters/fakeweb_spec.rb",
|
111
|
+
"spec/http_stubbing_adapters/webmock_spec.rb",
|
88
112
|
"spec/spec_helper.rb",
|
113
|
+
"spec/structs_spec.rb",
|
89
114
|
"spec/support/deprecated.rb",
|
90
115
|
"spec/support/disable_warnings.rb",
|
116
|
+
"spec/support/http_stubbing_adapter.rb",
|
91
117
|
"spec/support/temp_cassette_library_dir.rb",
|
118
|
+
"spec/task_runner_spec.rb",
|
92
119
|
"spec/vcr_spec.rb"
|
93
120
|
]
|
94
121
|
|
@@ -97,18 +124,21 @@ Gem::Specification.new do |s|
|
|
97
124
|
s.specification_version = 3
|
98
125
|
|
99
126
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
100
|
-
s.add_runtime_dependency(%q<fakeweb>, [">= 1.2.8"])
|
101
127
|
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
102
128
|
s.add_development_dependency(%q<cucumber>, [">= 0.6.1"])
|
129
|
+
s.add_development_dependency(%q<fakeweb>, [">= 1.2.8"])
|
130
|
+
s.add_development_dependency(%q<webmock>, [">= 1.1.0"])
|
103
131
|
else
|
104
|
-
s.add_dependency(%q<fakeweb>, [">= 1.2.8"])
|
105
132
|
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
106
133
|
s.add_dependency(%q<cucumber>, [">= 0.6.1"])
|
134
|
+
s.add_dependency(%q<fakeweb>, [">= 1.2.8"])
|
135
|
+
s.add_dependency(%q<webmock>, [">= 1.1.0"])
|
107
136
|
end
|
108
137
|
else
|
109
|
-
s.add_dependency(%q<fakeweb>, [">= 1.2.8"])
|
110
138
|
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
111
139
|
s.add_dependency(%q<cucumber>, [">= 0.6.1"])
|
140
|
+
s.add_dependency(%q<fakeweb>, [">= 1.2.8"])
|
141
|
+
s.add_dependency(%q<webmock>, [">= 1.1.0"])
|
112
142
|
end
|
113
143
|
end
|
114
144
|
|