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
@@ -0,0 +1,100 @@
|
|
1
|
+
shared_examples_for "an http stubbing adapter" do |supported_http_libraries, supported_request_match_attributes|
|
2
|
+
extend HttpLibrarySpecs
|
3
|
+
before(:each) { VCR.stub!(:http_stubbing_adapter).and_return(subject) }
|
4
|
+
subject { described_class }
|
5
|
+
|
6
|
+
describe '#request_uri' do
|
7
|
+
it 'returns the uri for the given http request' do
|
8
|
+
net_http = Net::HTTP.new('example.com', 80)
|
9
|
+
request = Net::HTTP::Get.new('/foo/bar')
|
10
|
+
subject.request_uri(net_http, request).should == 'http://example.com:80/foo/bar'
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'handles basic auth' do
|
14
|
+
net_http = Net::HTTP.new('example.com',80)
|
15
|
+
request = Net::HTTP::Get.new('/auth.txt')
|
16
|
+
request.basic_auth 'user', 'pass'
|
17
|
+
subject.request_uri(net_http, request).should == 'http://user:pass@example.com:80/auth.txt'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '.ignore_localhost?' do
|
22
|
+
[true, false].each do |val|
|
23
|
+
it "returns #{val} when ignore_localhost is set to #{val}" do
|
24
|
+
subject.ignore_localhost = val
|
25
|
+
subject.ignore_localhost?.should == val
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#request_stubbed? using specific match_attributes' do
|
31
|
+
let(:interactions) { YAML.load(File.read(File.join(File.dirname(__FILE__), '..', 'fixtures', YAML_SERIALIZATION_VERSION, 'match_requests_on.yml'))) }
|
32
|
+
|
33
|
+
@supported_request_match_attributes = supported_request_match_attributes
|
34
|
+
def self.matching_on(attribute, valid1, valid2, invalid, &block)
|
35
|
+
supported_request_match_attributes = @supported_request_match_attributes
|
36
|
+
|
37
|
+
describe ":#{attribute}" do
|
38
|
+
if supported_request_match_attributes.include?(attribute)
|
39
|
+
before(:each) { subject.stub_requests(interactions, [attribute]) }
|
40
|
+
module_eval(&block)
|
41
|
+
|
42
|
+
[valid1, valid2].each do |val|
|
43
|
+
it "returns true for a #{val.inspect} request" do
|
44
|
+
subject.request_stubbed?(request(val), [attribute]).should be_true
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
it "returns false for another #{attribute}" do
|
49
|
+
subject.request_stubbed?(request(invalid), [attribute]).should be_false
|
50
|
+
end
|
51
|
+
else
|
52
|
+
it 'raises an error indicating matching requests on this attribute is not supported' do
|
53
|
+
expect { subject.request_stubbed?(VCR::Request.new, [attribute]) }.to raise_error(/does not support matching requests on #{attribute}/)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
matching_on :method, :get, :post, :put do
|
60
|
+
def request(http_method)
|
61
|
+
VCR::Request.new(http_method, 'http://some-wrong-domain.com/', nil, {})
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
matching_on :host, 'example1.com', 'example2.com', 'example3.com' do
|
66
|
+
def request(host)
|
67
|
+
VCR::Request.new(:get, "http://#{host}/some/wrong/path", nil, {})
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
matching_on :uri, 'http://example.com/uri1', 'http://example.com/uri2', 'http://example.com/uri3' do
|
72
|
+
def request(uri)
|
73
|
+
VCR::Request.new(:get, uri, nil, {})
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
matching_on :path, '/path1', '/path2', '/path3' do
|
78
|
+
def request(path)
|
79
|
+
VCR::Request.new(:get, "http://example.com#{path}", nil, {})
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
matching_on :body, 'param=val1', 'param=val2', 'param=val3' do
|
84
|
+
def request(body)
|
85
|
+
VCR::Request.new(:put, "http://wrong-domain.com/wrong/path", body, {})
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
matching_on :headers, { 'X-HTTP-HEADER1' => 'val1' }, { 'X-HTTP-HEADER1' => 'val2' }, { 'X-HTTP-HEADER1' => 'val3' } do
|
90
|
+
def request(headers)
|
91
|
+
VCR::Request.new(:get, "http://wrong-domain.com/wrong/path", nil, headers)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
supported_http_libraries.each do |library|
|
97
|
+
test_http_library library, supported_request_match_attributes
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# The VCR test suite spawns a localhost webserver in a separate process, but it appears that
|
2
|
+
# heroku does not support this. I'm using heroku for my CI server, so we disable these specs
|
3
|
+
# as pending specs when we're running on heroku.
|
4
|
+
module PendingOnHeroku
|
5
|
+
if ENV.keys.include?('HEROKU_SLUG')
|
6
|
+
def it(*args, &block)
|
7
|
+
super description, *args do
|
8
|
+
pending('pending on heroku because heroku does not allow the spawning of a localhost webserver') do
|
9
|
+
instance_eval(&block)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module TempCassetteLibraryDir
|
2
|
+
def temp_dir(dir, options = {})
|
3
|
+
before(:each) do
|
4
|
+
@temp_dir = dir
|
5
|
+
@dir_remover = lambda { FileUtils.rm_rf(@temp_dir) if File.exist?(@temp_dir) }
|
6
|
+
@dir_remover.call
|
7
|
+
if options[:assign_to_cassette_library_dir]
|
8
|
+
VCR::Config.cassette_library_dir = @temp_dir
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
after(:each) do
|
13
|
+
@dir_remover.call
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'capybara'
|
2
|
+
require 'capybara/wait_until'
|
3
|
+
|
4
|
+
# This uses a separate process rather than a separate thread to run the server.
|
5
|
+
# Patron always times out when this is running in a thread in the same process.
|
6
|
+
#
|
7
|
+
# However, jruby doesn't support forking, and patron doesn't work on jruby...
|
8
|
+
# so we just leave Capybara::Server's definition of #boot.
|
9
|
+
class VCR::LocalhostServer < Capybara::Server
|
10
|
+
|
11
|
+
def boot
|
12
|
+
return self unless @app
|
13
|
+
find_available_port
|
14
|
+
Capybara.log "application has already booted" and return self if responsive?
|
15
|
+
Capybara.log "booting Rack applicartion on port #{port}"
|
16
|
+
|
17
|
+
pid = Process.fork do
|
18
|
+
trap(:INT) { Rack::Handler::WEBrick.shutdown }
|
19
|
+
Rack::Handler::WEBrick.run(Identify.new(@app), :Port => port, :AccessLog => [], :Logger => WEBrick::BasicLog.new(StringIO.new))
|
20
|
+
exit # manually exit; otherwise this sub-process will re-run the specs that haven't run yet.
|
21
|
+
end
|
22
|
+
Capybara.log "checking if application has booted"
|
23
|
+
|
24
|
+
Capybara::WaitUntil.timeout(10) do
|
25
|
+
if responsive?
|
26
|
+
Capybara.log("application has booted")
|
27
|
+
true
|
28
|
+
else
|
29
|
+
sleep 0.5
|
30
|
+
false
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
at_exit do
|
35
|
+
Process.kill('INT', pid)
|
36
|
+
begin
|
37
|
+
Process.wait(pid)
|
38
|
+
rescue Errno::ECHILD
|
39
|
+
# ignore this error...I think it means the child process has already exited.
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
self
|
44
|
+
rescue Timeout::Error
|
45
|
+
Capybara.log "Rack application timed out during boot"
|
46
|
+
exit
|
47
|
+
end unless RUBY_PLATFORM =~ /java/
|
48
|
+
|
49
|
+
STATIC_SERVERS = Hash.new do |h, k|
|
50
|
+
h[k] = server = new(lambda { |env| [200, {}, StringIO.new(k)] })
|
51
|
+
server.boot
|
52
|
+
end
|
53
|
+
end
|
data/spec/vcr_spec.rb
ADDED
@@ -0,0 +1,198 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe VCR do
|
4
|
+
def insert_cassette
|
5
|
+
VCR.insert_cassette(:cassette_test)
|
6
|
+
end
|
7
|
+
|
8
|
+
describe '.insert_cassette' do
|
9
|
+
it 'creates a new cassette' do
|
10
|
+
insert_cassette.should be_instance_of(VCR::Cassette)
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'takes over as the #current_cassette' do
|
14
|
+
orig_cassette = VCR.current_cassette
|
15
|
+
new_cassette = insert_cassette
|
16
|
+
new_cassette.should_not == orig_cassette
|
17
|
+
VCR.current_cassette.should == new_cassette
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '.eject_cassette' do
|
22
|
+
it 'ejects the current cassette' do
|
23
|
+
cassette = insert_cassette
|
24
|
+
cassette.should_receive(:eject)
|
25
|
+
VCR.eject_cassette
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'returns the ejected cassette' do
|
29
|
+
cassette = insert_cassette
|
30
|
+
VCR.eject_cassette.should == cassette
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'returns the #current_cassette to the previous one' do
|
34
|
+
cassette1, cassette2 = insert_cassette, insert_cassette
|
35
|
+
lambda { VCR.eject_cassette }.should change(VCR, :current_cassette).from(cassette2).to(cassette1)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '.use_cassette' do
|
40
|
+
it 'inserts a new cassette' do
|
41
|
+
new_cassette = VCR::Cassette.new(:use_cassette_test)
|
42
|
+
VCR.should_receive(:insert_cassette).and_return(new_cassette)
|
43
|
+
VCR.use_cassette(:cassette_test) { }
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'yields' do
|
47
|
+
yielded = false
|
48
|
+
VCR.use_cassette(:cassette_test) { yielded = true }
|
49
|
+
yielded.should be_true
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'ejects the cassette' do
|
53
|
+
VCR.should_receive(:eject_cassette)
|
54
|
+
VCR.use_cassette(:cassette_test) { }
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'ejects the cassette even if there is an error' do
|
58
|
+
VCR.should_receive(:eject_cassette)
|
59
|
+
lambda { VCR.use_cassette(:cassette_test) { raise StandardError } }.should raise_error
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'does not eject a cassette if there was an error inserting it' do
|
63
|
+
VCR.should_receive(:insert_cassette).and_raise(StandardError.new('Boom!'))
|
64
|
+
VCR.should_not_receive(:eject_cassette)
|
65
|
+
lambda { VCR.use_cassette(:test) { } }.should raise_error(StandardError, 'Boom!')
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe '.config' do
|
70
|
+
it 'yields the configuration object' do
|
71
|
+
yielded_object = nil
|
72
|
+
VCR.config do |obj|
|
73
|
+
yielded_object = obj
|
74
|
+
end
|
75
|
+
yielded_object.should == VCR::Config
|
76
|
+
end
|
77
|
+
|
78
|
+
it "disallows http connections" do
|
79
|
+
VCR.http_stubbing_adapter.should respond_to(:http_connections_allowed=)
|
80
|
+
VCR.http_stubbing_adapter.should_receive(:http_connections_allowed=).with(false)
|
81
|
+
VCR.config { }
|
82
|
+
end
|
83
|
+
|
84
|
+
it "checks the adapted library's version to make sure it's compatible with VCR" do
|
85
|
+
VCR.http_stubbing_adapter.should respond_to(:check_version!)
|
86
|
+
VCR.http_stubbing_adapter.should_receive(:check_version!)
|
87
|
+
VCR.config { }
|
88
|
+
end
|
89
|
+
|
90
|
+
[true, false].each do |val|
|
91
|
+
it "sets http_stubbing_adapter.ignore_localhost to #{val} when so configured" do
|
92
|
+
VCR.config do |c|
|
93
|
+
c.ignore_localhost = val
|
94
|
+
|
95
|
+
# this is mocked at this point since it should be set when the block completes.
|
96
|
+
VCR.http_stubbing_adapter.should_receive(:ignore_localhost=).with(val)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
describe '.cucumber_tags' do
|
103
|
+
it 'yields a cucumber tags object' do
|
104
|
+
yielded_object = nil
|
105
|
+
VCR.cucumber_tags do |obj|
|
106
|
+
yielded_object = obj
|
107
|
+
end
|
108
|
+
yielded_object.should be_instance_of(VCR::CucumberTags)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
describe '.http_stubbing_adapter' do
|
113
|
+
subject { VCR.http_stubbing_adapter }
|
114
|
+
before(:each) do
|
115
|
+
VCR.instance_variable_set(:@http_stubbing_adapter, nil)
|
116
|
+
end
|
117
|
+
|
118
|
+
{
|
119
|
+
:fakeweb => VCR::HttpStubbingAdapters::FakeWeb,
|
120
|
+
:webmock => VCR::HttpStubbingAdapters::WebMock
|
121
|
+
}.each do |setting, adapter|
|
122
|
+
context "when config http_stubbing_library = :#{setting.to_s}" do
|
123
|
+
before(:each) { VCR::Config.http_stubbing_library = setting }
|
124
|
+
|
125
|
+
it "returns #{adapter}" do
|
126
|
+
subject.should == adapter
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
it 'raises an error when library is not set' do
|
132
|
+
VCR::Config.http_stubbing_library = nil
|
133
|
+
lambda { subject }.should raise_error(/The http stubbing library is not configured correctly/)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
describe '.record_http_interaction' do
|
138
|
+
before(:each) { VCR.stub!(:current_cassette).and_return(current_cassette) }
|
139
|
+
|
140
|
+
def self.with_ignore_localhost_set_to(value, &block)
|
141
|
+
context "when http_stubbing_adapter.ignore_localhost is #{value}" do
|
142
|
+
before(:each) { VCR.http_stubbing_adapter.stub!(:ignore_localhost?).and_return(value) }
|
143
|
+
|
144
|
+
instance_eval(&block)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
def self.it_records_requests_to(host)
|
149
|
+
it "records requests to #{host}" do
|
150
|
+
interaction = stub(:uri => "http://#{host}/")
|
151
|
+
current_cassette.should_receive(:record_http_interaction).with(interaction).once
|
152
|
+
VCR.record_http_interaction(interaction)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
def self.it_does_not_record_requests_to(host)
|
157
|
+
it "does not record requests to #{host}" do
|
158
|
+
interaction = stub(:uri => "http://#{host}/")
|
159
|
+
current_cassette.should_receive(:record_http_interaction).never unless current_cassette.nil?
|
160
|
+
VCR.record_http_interaction(interaction)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
context 'when there is a current cassette' do
|
165
|
+
let(:current_cassette) { mock('current casette') }
|
166
|
+
|
167
|
+
with_ignore_localhost_set_to(true) do
|
168
|
+
it_records_requests_to "example.com"
|
169
|
+
|
170
|
+
VCR::LOCALHOST_ALIASES.each do |host|
|
171
|
+
it_does_not_record_requests_to host
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
with_ignore_localhost_set_to(false) do
|
176
|
+
(VCR::LOCALHOST_ALIASES + ['example.com']).each do |host|
|
177
|
+
it_records_requests_to host
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
context 'when there is not a current cassette' do
|
183
|
+
let(:current_cassette) { nil }
|
184
|
+
|
185
|
+
with_ignore_localhost_set_to(true) do
|
186
|
+
(VCR::LOCALHOST_ALIASES + ['example.com']).each do |host|
|
187
|
+
it_does_not_record_requests_to host
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
with_ignore_localhost_set_to(false) do
|
192
|
+
(VCR::LOCALHOST_ALIASES + ['example.com']).each do |host|
|
193
|
+
it_does_not_record_requests_to host
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "VCR.version" do
|
4
|
+
subject { VCR.version }
|
5
|
+
|
6
|
+
it { should =~ /\A\d+\.\d+\.\d+\z/ }
|
7
|
+
its(:parts) { should be_instance_of(Array) }
|
8
|
+
its(:major) { should be_instance_of(Fixnum) }
|
9
|
+
its(:minor) { should be_instance_of(Fixnum) }
|
10
|
+
its(:patch) { should be_instance_of(Fixnum) }
|
11
|
+
end
|
data/vcr.gemspec
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require File.expand_path("../lib/vcr/version", __FILE__)
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = "vcr"
|
5
|
+
s.homepage = "http://github.com/myronmarston/vcr"
|
6
|
+
s.authors = ["Myron Marston"]
|
7
|
+
s.summary = "Record your test suite's HTTP interactions and replay them during future test runs for fast, deterministic, accurate tests."
|
8
|
+
s.description = "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."
|
9
|
+
s.email = "myron.marston@gmail.com"
|
10
|
+
s.require_path = "lib"
|
11
|
+
s.files = `git ls-files`.split("\n")
|
12
|
+
s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
|
13
|
+
|
14
|
+
s.version = VCR.version
|
15
|
+
s.platform = Gem::Platform::RUBY
|
16
|
+
s.required_ruby_version = '>= 1.8.6'
|
17
|
+
s.required_rubygems_version = '>= 1.3.5'
|
18
|
+
|
19
|
+
{
|
20
|
+
'bundler' => '~> 1.0.0.rc6',
|
21
|
+
'rake' => '~> 0.8.7',
|
22
|
+
|
23
|
+
'rspec' => '~> 2.0.0.beta.20',
|
24
|
+
'cucumber' => '~> 0.8.5',
|
25
|
+
|
26
|
+
'fakeweb' => '~> 1.3.0',
|
27
|
+
'webmock' => '1.3.3',
|
28
|
+
|
29
|
+
'httpclient' => '~> 2.1.5.2',
|
30
|
+
|
31
|
+
'capybara' => '~> 0.3.9',
|
32
|
+
'rack' => '1.2.0'
|
33
|
+
}.each do |lib, version|
|
34
|
+
s.add_development_dependency lib, version
|
35
|
+
end
|
36
|
+
|
37
|
+
{
|
38
|
+
'patron' => '~> 0.4.6',
|
39
|
+
'em-http-request' => '~> 0.2.7',
|
40
|
+
}.each do |lib, version|
|
41
|
+
s.add_development_dependency lib, version
|
42
|
+
end unless RUBY_PLATFORM == 'java'
|
43
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vcr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 1.1.
|
9
|
+
- 1
|
10
|
+
version: 1.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Myron Marston
|
@@ -15,86 +15,91 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-08-
|
18
|
+
date: 2010-08-26 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|
23
23
|
none: false
|
24
24
|
requirements:
|
25
|
-
- -
|
25
|
+
- - ~>
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
hash:
|
27
|
+
hash: 27
|
28
28
|
segments:
|
29
|
-
-
|
30
|
-
-
|
29
|
+
- 1
|
30
|
+
- 3
|
31
31
|
- 0
|
32
|
-
|
33
|
-
- 19
|
34
|
-
version: 2.0.0.beta.19
|
32
|
+
version: 1.3.0
|
35
33
|
requirement: *id001
|
36
34
|
type: :development
|
37
|
-
name:
|
35
|
+
name: fakeweb
|
38
36
|
prerelease: false
|
39
37
|
- !ruby/object:Gem::Dependency
|
40
38
|
version_requirements: &id002 !ruby/object:Gem::Requirement
|
41
39
|
none: false
|
42
40
|
requirements:
|
43
|
-
- -
|
41
|
+
- - ~>
|
44
42
|
- !ruby/object:Gem::Version
|
45
|
-
hash:
|
43
|
+
hash: 119
|
46
44
|
segments:
|
47
|
-
-
|
48
|
-
|
45
|
+
- 2
|
46
|
+
- 1
|
47
|
+
- 5
|
48
|
+
- 2
|
49
|
+
version: 2.1.5.2
|
49
50
|
requirement: *id002
|
50
51
|
type: :development
|
51
|
-
name:
|
52
|
+
name: httpclient
|
52
53
|
prerelease: false
|
53
54
|
- !ruby/object:Gem::Dependency
|
54
55
|
version_requirements: &id003 !ruby/object:Gem::Requirement
|
55
56
|
none: false
|
56
57
|
requirements:
|
57
|
-
- -
|
58
|
+
- - ~>
|
58
59
|
- !ruby/object:Gem::Version
|
59
|
-
hash:
|
60
|
+
hash: 49
|
60
61
|
segments:
|
61
62
|
- 0
|
62
|
-
|
63
|
+
- 8
|
64
|
+
- 7
|
65
|
+
version: 0.8.7
|
63
66
|
requirement: *id003
|
64
67
|
type: :development
|
65
|
-
name:
|
68
|
+
name: rake
|
66
69
|
prerelease: false
|
67
70
|
- !ruby/object:Gem::Dependency
|
68
71
|
version_requirements: &id004 !ruby/object:Gem::Requirement
|
69
72
|
none: false
|
70
73
|
requirements:
|
71
|
-
- -
|
74
|
+
- - ~>
|
72
75
|
- !ruby/object:Gem::Version
|
73
|
-
hash:
|
76
|
+
hash: 62196427
|
74
77
|
segments:
|
78
|
+
- 2
|
75
79
|
- 0
|
76
|
-
-
|
77
|
-
-
|
78
|
-
|
80
|
+
- 0
|
81
|
+
- beta
|
82
|
+
- 20
|
83
|
+
version: 2.0.0.beta.20
|
79
84
|
requirement: *id004
|
80
85
|
type: :development
|
81
|
-
name:
|
86
|
+
name: rspec
|
82
87
|
prerelease: false
|
83
88
|
- !ruby/object:Gem::Dependency
|
84
89
|
version_requirements: &id005 !ruby/object:Gem::Requirement
|
85
90
|
none: false
|
86
91
|
requirements:
|
87
|
-
- -
|
92
|
+
- - "="
|
88
93
|
- !ruby/object:Gem::Version
|
89
|
-
hash:
|
94
|
+
hash: 31
|
90
95
|
segments:
|
91
96
|
- 1
|
92
97
|
- 2
|
93
|
-
-
|
94
|
-
version: 1.2.
|
98
|
+
- 0
|
99
|
+
version: 1.2.0
|
95
100
|
requirement: *id005
|
96
101
|
type: :development
|
97
|
-
name:
|
102
|
+
name: rack
|
98
103
|
prerelease: false
|
99
104
|
- !ruby/object:Gem::Dependency
|
100
105
|
version_requirements: &id006 !ruby/object:Gem::Requirement
|
@@ -102,15 +107,16 @@ dependencies:
|
|
102
107
|
requirements:
|
103
108
|
- - ~>
|
104
109
|
- !ruby/object:Gem::Version
|
105
|
-
hash:
|
110
|
+
hash: 977940571
|
106
111
|
segments:
|
107
112
|
- 1
|
108
|
-
-
|
109
|
-
-
|
110
|
-
|
113
|
+
- 0
|
114
|
+
- 0
|
115
|
+
- rc6
|
116
|
+
version: 1.0.0.rc6
|
111
117
|
requirement: *id006
|
112
118
|
type: :development
|
113
|
-
name:
|
119
|
+
name: bundler
|
114
120
|
prerelease: false
|
115
121
|
- !ruby/object:Gem::Dependency
|
116
122
|
version_requirements: &id007 !ruby/object:Gem::Requirement
|
@@ -118,16 +124,15 @@ dependencies:
|
|
118
124
|
requirements:
|
119
125
|
- - ~>
|
120
126
|
- !ruby/object:Gem::Version
|
121
|
-
hash:
|
127
|
+
hash: 53
|
122
128
|
segments:
|
123
|
-
-
|
124
|
-
-
|
129
|
+
- 0
|
130
|
+
- 8
|
125
131
|
- 5
|
126
|
-
|
127
|
-
version: 2.1.5.2
|
132
|
+
version: 0.8.5
|
128
133
|
requirement: *id007
|
129
134
|
type: :development
|
130
|
-
name:
|
135
|
+
name: cucumber
|
131
136
|
prerelease: false
|
132
137
|
- !ruby/object:Gem::Dependency
|
133
138
|
version_requirements: &id008 !ruby/object:Gem::Requirement
|
@@ -151,34 +156,18 @@ dependencies:
|
|
151
156
|
requirements:
|
152
157
|
- - "="
|
153
158
|
- !ruby/object:Gem::Version
|
154
|
-
hash:
|
159
|
+
hash: 29
|
155
160
|
segments:
|
156
161
|
- 1
|
157
|
-
-
|
158
|
-
-
|
159
|
-
version: 1.
|
162
|
+
- 3
|
163
|
+
- 3
|
164
|
+
version: 1.3.3
|
160
165
|
requirement: *id009
|
161
166
|
type: :development
|
162
|
-
name:
|
167
|
+
name: webmock
|
163
168
|
prerelease: false
|
164
169
|
- !ruby/object:Gem::Dependency
|
165
170
|
version_requirements: &id010 !ruby/object:Gem::Requirement
|
166
|
-
none: false
|
167
|
-
requirements:
|
168
|
-
- - ~>
|
169
|
-
- !ruby/object:Gem::Version
|
170
|
-
hash: 49
|
171
|
-
segments:
|
172
|
-
- 0
|
173
|
-
- 8
|
174
|
-
- 7
|
175
|
-
version: 0.8.7
|
176
|
-
requirement: *id010
|
177
|
-
type: :development
|
178
|
-
name: rake
|
179
|
-
prerelease: false
|
180
|
-
- !ruby/object:Gem::Dependency
|
181
|
-
version_requirements: &id011 !ruby/object:Gem::Requirement
|
182
171
|
none: false
|
183
172
|
requirements:
|
184
173
|
- - ~>
|
@@ -189,12 +178,12 @@ dependencies:
|
|
189
178
|
- 4
|
190
179
|
- 6
|
191
180
|
version: 0.4.6
|
192
|
-
requirement: *
|
181
|
+
requirement: *id010
|
193
182
|
type: :development
|
194
183
|
name: patron
|
195
184
|
prerelease: false
|
196
185
|
- !ruby/object:Gem::Dependency
|
197
|
-
version_requirements: &
|
186
|
+
version_requirements: &id011 !ruby/object:Gem::Requirement
|
198
187
|
none: false
|
199
188
|
requirements:
|
200
189
|
- - ~>
|
@@ -205,7 +194,7 @@ dependencies:
|
|
205
194
|
- 2
|
206
195
|
- 7
|
207
196
|
version: 0.2.7
|
208
|
-
requirement: *
|
197
|
+
requirement: *id011
|
209
198
|
type: :development
|
210
199
|
name: em-http-request
|
211
200
|
prerelease: false
|
@@ -218,23 +207,95 @@ extensions: []
|
|
218
207
|
extra_rdoc_files: []
|
219
208
|
|
220
209
|
files:
|
210
|
+
- .document
|
211
|
+
- .gitignore
|
212
|
+
- CHANGELOG.md
|
213
|
+
- Gemfile
|
214
|
+
- Gemfile.lock
|
215
|
+
- LICENSE
|
216
|
+
- README.md
|
217
|
+
- Rakefile
|
218
|
+
- benchmarks/http_stubbing_libraries.rb
|
219
|
+
- features/fixtures/vcr_cassettes/1.9.1/cucumber_tags/regex_cassette.yml
|
220
|
+
- features/fixtures/vcr_cassettes/1.9.1/cucumber_tags/replay_cassette1.yml
|
221
|
+
- features/fixtures/vcr_cassettes/1.9.1/cucumber_tags/replay_cassette2.yml
|
222
|
+
- features/fixtures/vcr_cassettes/1.9.1/cucumber_tags/replay_cassette3.yml
|
223
|
+
- features/fixtures/vcr_cassettes/1.9.1/erb_cassette.yml
|
224
|
+
- features/fixtures/vcr_cassettes/1.9.1/match_requests_on.yml
|
225
|
+
- features/fixtures/vcr_cassettes/1.9.1/nested_replay_cassette.yml
|
226
|
+
- features/fixtures/vcr_cassettes/1.9.1/not_the_real_response.yml
|
227
|
+
- features/fixtures/vcr_cassettes/1.9.1/replay_localhost_cassette.yml
|
228
|
+
- features/fixtures/vcr_cassettes/not_1.9.1/cucumber_tags/regex_cassette.yml
|
229
|
+
- features/fixtures/vcr_cassettes/not_1.9.1/cucumber_tags/replay_cassette1.yml
|
230
|
+
- features/fixtures/vcr_cassettes/not_1.9.1/cucumber_tags/replay_cassette2.yml
|
231
|
+
- features/fixtures/vcr_cassettes/not_1.9.1/cucumber_tags/replay_cassette3.yml
|
232
|
+
- features/fixtures/vcr_cassettes/not_1.9.1/erb_cassette.yml
|
233
|
+
- features/fixtures/vcr_cassettes/not_1.9.1/match_requests_on.yml
|
234
|
+
- features/fixtures/vcr_cassettes/not_1.9.1/nested_replay_cassette.yml
|
235
|
+
- features/fixtures/vcr_cassettes/not_1.9.1/not_the_real_response.yml
|
236
|
+
- features/fixtures/vcr_cassettes/not_1.9.1/replay_localhost_cassette.yml
|
237
|
+
- features/http_client.feature
|
238
|
+
- features/net_http.feature
|
239
|
+
- features/record_response.feature
|
240
|
+
- features/replay_recorded_response.feature
|
241
|
+
- features/step_definitions/http_client_steps.rb
|
242
|
+
- features/step_definitions/net_http_steps.rb
|
243
|
+
- features/step_definitions/vcr_steps.rb
|
244
|
+
- features/support/env.rb
|
245
|
+
- features/webmock.feature
|
246
|
+
- lib/vcr.rb
|
221
247
|
- lib/vcr/cassette.rb
|
222
248
|
- lib/vcr/config.rb
|
223
249
|
- lib/vcr/cucumber_tags.rb
|
224
250
|
- lib/vcr/deprecations.rb
|
225
251
|
- lib/vcr/extensions/net_http.rb
|
226
252
|
- lib/vcr/extensions/net_http_response.rb
|
227
|
-
- lib/vcr/http_stubbing_adapters/
|
253
|
+
- lib/vcr/http_stubbing_adapters/common.rb
|
228
254
|
- lib/vcr/http_stubbing_adapters/fakeweb.rb
|
229
255
|
- lib/vcr/http_stubbing_adapters/webmock.rb
|
230
256
|
- lib/vcr/request_matcher.rb
|
231
257
|
- lib/vcr/structs.rb
|
232
258
|
- lib/vcr/version.rb
|
233
|
-
-
|
234
|
-
-
|
235
|
-
-
|
236
|
-
-
|
237
|
-
-
|
259
|
+
- spec/cassette_spec.rb
|
260
|
+
- spec/config_spec.rb
|
261
|
+
- spec/cucumber_tags_spec.rb
|
262
|
+
- spec/deprecations_spec.rb
|
263
|
+
- spec/extensions/net_http_response_spec.rb
|
264
|
+
- spec/extensions/net_http_spec.rb
|
265
|
+
- spec/fixtures/1.9.1/0_3_1_cassette.yml
|
266
|
+
- spec/fixtures/1.9.1/cassette_spec/erb_with_no_vars.yml
|
267
|
+
- spec/fixtures/1.9.1/cassette_spec/erb_with_vars.yml
|
268
|
+
- spec/fixtures/1.9.1/cassette_spec/example.yml
|
269
|
+
- spec/fixtures/1.9.1/cassette_spec/with_localhost_requests.yml
|
270
|
+
- spec/fixtures/1.9.1/example_net_http.yml
|
271
|
+
- spec/fixtures/1.9.1/example_net_http_request.yml
|
272
|
+
- spec/fixtures/1.9.1/example_net_http_response.yml
|
273
|
+
- spec/fixtures/1.9.1/fake_example.com_responses.yml
|
274
|
+
- spec/fixtures/1.9.1/match_requests_on.yml
|
275
|
+
- spec/fixtures/not_1.9.1/0_3_1_cassette.yml
|
276
|
+
- spec/fixtures/not_1.9.1/cassette_spec/erb_with_no_vars.yml
|
277
|
+
- spec/fixtures/not_1.9.1/cassette_spec/erb_with_vars.yml
|
278
|
+
- spec/fixtures/not_1.9.1/cassette_spec/example.yml
|
279
|
+
- spec/fixtures/not_1.9.1/cassette_spec/with_localhost_requests.yml
|
280
|
+
- spec/fixtures/not_1.9.1/example_net_http.yml
|
281
|
+
- spec/fixtures/not_1.9.1/example_net_http_request.yml
|
282
|
+
- spec/fixtures/not_1.9.1/example_net_http_response.yml
|
283
|
+
- spec/fixtures/not_1.9.1/fake_example.com_responses.yml
|
284
|
+
- spec/fixtures/not_1.9.1/match_requests_on.yml
|
285
|
+
- spec/http_stubbing_adapters/fakeweb_spec.rb
|
286
|
+
- spec/http_stubbing_adapters/webmock_spec.rb
|
287
|
+
- spec/request_matcher_spec.rb
|
288
|
+
- spec/spec_helper.rb
|
289
|
+
- spec/structs_spec.rb
|
290
|
+
- spec/support/disable_warnings.rb
|
291
|
+
- spec/support/http_library_adapters.rb
|
292
|
+
- spec/support/http_stubbing_adapter.rb
|
293
|
+
- spec/support/pending_on_heroku.rb
|
294
|
+
- spec/support/temp_cassette_library_dir.rb
|
295
|
+
- spec/support/vcr_localhost_server.rb
|
296
|
+
- spec/vcr_spec.rb
|
297
|
+
- spec/version_spec.rb
|
298
|
+
- vcr.gemspec
|
238
299
|
has_rdoc: true
|
239
300
|
homepage: http://github.com/myronmarston/vcr
|
240
301
|
licenses: []
|