vcr 1.6.0 → 1.7.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.
- data/.gemtest +0 -0
- data/.gitignore +5 -0
- data/.travis.yml +1 -0
- data/CHANGELOG.md +29 -2
- data/Gemfile +3 -3
- data/README.md +55 -11
- data/Rakefile +45 -4
- data/features/.nav +6 -0
- data/features/{README.md → about_the_cucumber_features.md} +1 -1
- data/features/cassettes/update_content_length_header.feature +106 -0
- data/features/configuration/default_cassette_options.feature +20 -2
- data/features/configuration/filter_sensitive_data.feature +154 -0
- data/features/getting_started.md +67 -0
- data/features/record_modes/all.feature +4 -2
- data/features/record_modes/new_episodes.feature +8 -2
- data/features/record_modes/none.feature +4 -2
- data/features/record_modes/once.feature +92 -0
- data/features/step_definitions/cli_steps.rb +18 -0
- data/lib/vcr.rb +13 -6
- data/lib/vcr/cassette.rb +36 -15
- data/lib/vcr/config.rb +14 -2
- data/lib/vcr/deprecations/cassette.rb +29 -0
- data/lib/vcr/deprecations/config.rb +18 -0
- data/lib/vcr/deprecations/http_stubbing_adapters/common.rb +9 -0
- data/lib/vcr/deprecations/http_stubbing_adapters/fakeweb.rb +11 -0
- data/lib/vcr/http_stubbing_adapters/common.rb +1 -1
- data/lib/vcr/http_stubbing_adapters/fakeweb.rb +2 -7
- data/lib/vcr/http_stubbing_adapters/multi_object_proxy.rb +1 -1
- data/lib/vcr/middleware/common.rb +3 -5
- data/lib/vcr/rspec.rb +1 -38
- data/lib/vcr/structs/http_interaction.rb +29 -0
- data/lib/vcr/structs/request.rb +6 -0
- data/lib/vcr/structs/response.rb +4 -0
- data/lib/vcr/{cucumber_tags.rb → test_frameworks/cucumber.rb} +10 -2
- data/lib/vcr/test_frameworks/rspec.rb +37 -0
- data/lib/vcr/util/basic_object.rb +32 -28
- data/lib/vcr/{hooks.rb → util/hooks.rb} +3 -6
- data/lib/vcr/util/internet_connection.rb +1 -1
- data/lib/vcr/util/ping.rb +21 -17
- data/lib/vcr/util/variable_args_block_caller.rb +12 -0
- data/lib/vcr/util/yaml.rb +11 -0
- data/lib/vcr/version.rb +1 -1
- data/script/FullBuildRakeFile +7 -0
- data/spec/monkey_patches.rb +0 -7
- data/spec/spec_helper.rb +40 -8
- data/spec/support/http_library_adapters.rb +0 -262
- data/spec/support/shared_example_groups/http_library.rb +256 -0
- data/spec/support/{http_stubbing_adapter.rb → shared_example_groups/http_stubbing_adapter.rb} +15 -3
- data/spec/support/shared_example_groups/ignore_localhost_deprecation.rb +28 -0
- data/spec/support/{normalizers.rb → shared_example_groups/normalizers.rb} +3 -3
- data/spec/support/{version_checker.rb → shared_example_groups/version_checking.rb} +1 -1
- data/spec/vcr/cassette_spec.rb +80 -28
- data/spec/vcr/config_spec.rb +55 -8
- data/spec/vcr/deprecations/cassette_spec.rb +57 -0
- data/spec/vcr/deprecations/config_spec.rb +30 -0
- data/spec/vcr/deprecations/http_stubbing_adapters/common_spec.rb +7 -0
- data/spec/vcr/deprecations/http_stubbing_adapters/fakeweb_spec.rb +16 -0
- data/spec/vcr/extensions/net_http_response_spec.rb +1 -3
- data/spec/vcr/extensions/net_http_spec.rb +1 -3
- data/spec/vcr/http_stubbing_adapters/fakeweb_spec.rb +1 -4
- data/spec/vcr/http_stubbing_adapters/faraday_spec.rb +1 -4
- data/spec/vcr/http_stubbing_adapters/typhoeus_spec.rb +1 -4
- data/spec/vcr/http_stubbing_adapters/webmock_spec.rb +1 -3
- data/spec/vcr/middleware/faraday_spec.rb +4 -4
- data/spec/vcr/middleware/rack_spec.rb +4 -4
- data/spec/vcr/structs/http_interaction_spec.rb +61 -0
- data/spec/vcr/structs/request_spec.rb +20 -2
- data/spec/vcr/structs/response_spec.rb +23 -1
- data/spec/vcr/structs/response_status_spec.rb +1 -1
- data/spec/vcr/{cucumber_tags_spec.rb → test_frameworks/cucumber_spec.rb} +12 -8
- data/spec/vcr/{rspec_spec.rb → test_frameworks/rspec_spec.rb} +0 -0
- data/spec/vcr/{hooks_spec.rb → util/hooks_spec.rb} +3 -3
- data/spec/vcr/util/internet_connection_spec.rb +3 -3
- data/spec/vcr_spec.rb +3 -3
- data/vcr.gemspec +5 -5
- metadata +149 -131
- data/Gemfile.lock +0 -155
- data/lib/vcr/deprecations.rb +0 -54
- data/spec/support/disable_warnings.rb +0 -12
- data/spec/support/temp_cassette_library_dir.rb +0 -16
- data/spec/support/webmock_macros.rb +0 -14
- data/spec/vcr/deprecations_spec.rb +0 -139
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe VCR::Config, 'deprecations', :disable_warnings => true do
|
4
|
+
describe '.http_stubbing_library' do
|
5
|
+
before(:each) { described_class.stub_with :webmock, :typhoeus }
|
6
|
+
|
7
|
+
it 'returns the first configured stubbing library' do
|
8
|
+
described_class.http_stubbing_library.should == :webmock
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'prints a warning: WARNING: VCR::Config.http_stubbing_library is deprecated. Use VCR::Config.http_stubbing_libraries instead' do
|
12
|
+
described_class.should_receive(:warn).with("WARNING: `VCR::Config.http_stubbing_library` is deprecated. Use `VCR::Config.http_stubbing_libraries` instead.")
|
13
|
+
described_class.http_stubbing_library
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '.http_stubbing_library=' do
|
18
|
+
it 'sets http_stubbing_libraries to an array of the given value' do
|
19
|
+
described_class.http_stubbing_library = :webmock
|
20
|
+
described_class.http_stubbing_libraries.should == [:webmock]
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'prints a warning: WARNING: VCR::Config.http_stubbing_library= is deprecated. Use VCR::Config.stub_with instead' do
|
24
|
+
described_class.should_receive(:warn).with("WARNING: `VCR::Config.http_stubbing_library = :webmock` is deprecated. Use `VCR::Config.stub_with :webmock` instead.")
|
25
|
+
described_class.http_stubbing_library = :webmock
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
it_behaves_like '.ignore_localhost? deprecation'
|
30
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe VCR::HttpStubbingAdapters::FakeWeb, 'deprecations', :disable_warnings => true do
|
4
|
+
describe 'LOCALHOST_REGEX constant' do
|
5
|
+
subject { described_class::LOCALHOST_REGEX }
|
6
|
+
|
7
|
+
it 'refers to the expected regex' do
|
8
|
+
should == %r|\Ahttps?://((\w+:)?\w+@)?(#{VCR::LOCALHOST_ALIASES.sort.map { |a| Regexp.escape(a) }.join('|')})(:\d+)?/|i
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'prints a warning: WARNING: `VCR::HttpStubbingAdapters::FakeWeb::LOCALHOST_REGEX` is deprecated.' do
|
12
|
+
described_class.should_receive(:warn).with("WARNING: `VCR::HttpStubbingAdapters::FakeWeb::LOCALHOST_REGEX` is deprecated.")
|
13
|
+
subject
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -1,8 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe VCR::Net::HTTPResponse do
|
4
|
-
without_monkey_patches :all
|
5
|
-
|
3
|
+
describe VCR::Net::HTTPResponse, :without_monkey_patches => :all do
|
6
4
|
def self.it_allows_the_body_to_be_read(expected_regex)
|
7
5
|
it 'allows the body to be read using #body' do
|
8
6
|
response.body.to_s.should =~ expected_regex
|
@@ -1,8 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe "Net::HTTP Extensions" do
|
4
|
-
without_webmock_callbacks
|
5
|
-
|
3
|
+
describe "Net::HTTP Extensions", :without_webmock_callbacks => true do
|
6
4
|
before(:all) { VCR::SinatraApp.port } # ensure the server is started before instantiating any Net::HTTP instances
|
7
5
|
|
8
6
|
let(:uri) { URI.parse("http://localhost:#{VCR::SinatraApp.port}/") }
|
@@ -1,8 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe VCR::HttpStubbingAdapters::FakeWeb do
|
4
|
-
without_webmock_callbacks
|
5
|
-
|
3
|
+
describe VCR::HttpStubbingAdapters::FakeWeb, :without_webmock_callbacks => true do
|
6
4
|
it_behaves_like 'an http stubbing adapter', ['net/http'], [:method, :uri, :host, :path], :needs_net_http_extension
|
7
5
|
|
8
6
|
it_performs('version checking',
|
@@ -10,7 +8,6 @@ describe VCR::HttpStubbingAdapters::FakeWeb do
|
|
10
8
|
:too_low => %w[ 1.2.8 1.1.30 0.30.30 ],
|
11
9
|
:too_high => %w[ 1.4.0 1.10.0 2.0.0 ]
|
12
10
|
) do
|
13
|
-
disable_warnings
|
14
11
|
before(:each) { @orig_version = FakeWeb::VERSION }
|
15
12
|
after(:each) { FakeWeb::VERSION = @orig_version }
|
16
13
|
|
@@ -1,8 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe VCR::HttpStubbingAdapters::Faraday do
|
4
|
-
without_monkey_patches :all
|
5
|
-
|
3
|
+
describe VCR::HttpStubbingAdapters::Faraday, :without_monkey_patches => :all do
|
6
4
|
it_behaves_like 'an http stubbing adapter',
|
7
5
|
%w[ faraday-typhoeus faraday-net_http faraday-patron ],
|
8
6
|
[:method, :uri, :host, :path, :body, :headers],
|
@@ -13,7 +11,6 @@ describe VCR::HttpStubbingAdapters::Faraday do
|
|
13
11
|
:too_low => %w[ 0.5.2 0.4.99 ],
|
14
12
|
:too_high => %w[ 0.6.0 1.0.0 ]
|
15
13
|
) do
|
16
|
-
disable_warnings
|
17
14
|
before(:each) { @orig_version = Faraday::VERSION }
|
18
15
|
after(:each) { Faraday::VERSION = @orig_version }
|
19
16
|
|
@@ -1,8 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe VCR::HttpStubbingAdapters::Typhoeus do
|
4
|
-
without_monkey_patches :vcr
|
5
|
-
|
3
|
+
describe VCR::HttpStubbingAdapters::Typhoeus, :without_monkey_patches => :vcr do
|
6
4
|
before(:each) do
|
7
5
|
::Typhoeus::Hydra.stubs = []
|
8
6
|
::Typhoeus::Hydra.allow_net_connect = true
|
@@ -15,7 +13,6 @@ describe VCR::HttpStubbingAdapters::Typhoeus do
|
|
15
13
|
:too_low => %w[ 0.1.0 0.1.31 0.2.0 ],
|
16
14
|
:too_high => %w[ 0.3.0 1.0.0 ]
|
17
15
|
) do
|
18
|
-
disable_warnings
|
19
16
|
before(:each) { @orig_version = Typhoeus::VERSION }
|
20
17
|
after(:each) { Typhoeus::VERSION = @orig_version }
|
21
18
|
|
@@ -1,8 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe VCR::HttpStubbingAdapters::WebMock do
|
4
|
-
without_monkey_patches :vcr
|
5
|
-
|
3
|
+
describe VCR::HttpStubbingAdapters::WebMock, :without_monkey_patches => :vcr do
|
6
4
|
it_behaves_like 'an http stubbing adapter',
|
7
5
|
%w[net/http patron httpclient em-http-request curb],
|
8
6
|
[:method, :uri, :host, :path, :body, :headers]
|
@@ -32,19 +32,19 @@ describe VCR::Middleware::Faraday do
|
|
32
32
|
|
33
33
|
it 'sets the cassette options based on the provided block' do
|
34
34
|
app = lambda { |env| VCR.current_cassette.erb.should == { :foo => :bar } }
|
35
|
-
instance = described_class.new(app
|
35
|
+
instance = described_class.new(app, &lambda do |c|
|
36
36
|
c.name 'c'
|
37
37
|
c.options :erb => { :foo => :bar }
|
38
|
-
end
|
38
|
+
end)
|
39
39
|
|
40
40
|
instance.call(env_hash)
|
41
41
|
end
|
42
42
|
|
43
43
|
it 'yields the env to the provided block when the block accepts 2 arguments' do
|
44
|
-
instance = described_class.new(lambda { |env| }
|
44
|
+
instance = described_class.new(lambda { |env| }, &lambda do |c, env|
|
45
45
|
env.should == env_hash
|
46
46
|
c.name 'c'
|
47
|
-
end
|
47
|
+
end)
|
48
48
|
|
49
49
|
instance.call(env_hash)
|
50
50
|
end
|
@@ -34,19 +34,19 @@ describe VCR::Middleware::Rack do
|
|
34
34
|
|
35
35
|
it 'sets the cassette options based on the provided block' do
|
36
36
|
rack_app = lambda { |env| VCR.current_cassette.erb.should == { :foo => :bar } }
|
37
|
-
instance = described_class.new(rack_app
|
37
|
+
instance = described_class.new(rack_app, &lambda do |c|
|
38
38
|
c.name 'c'
|
39
39
|
c.options :erb => { :foo => :bar }
|
40
|
-
end
|
40
|
+
end)
|
41
41
|
|
42
42
|
instance.call({})
|
43
43
|
end
|
44
44
|
|
45
45
|
it 'yields the rack env to the provided block when the block accepts 2 arguments' do
|
46
|
-
instance = described_class.new(lambda { |env| }
|
46
|
+
instance = described_class.new(lambda { |env| }, &lambda do |c, env|
|
47
47
|
env.should == env_hash
|
48
48
|
c.name 'c'
|
49
|
-
end
|
49
|
+
end)
|
50
50
|
|
51
51
|
instance.call(env_hash)
|
52
52
|
end
|
@@ -20,4 +20,65 @@ describe VCR::HTTPInteraction do
|
|
20
20
|
should be_ignored
|
21
21
|
end
|
22
22
|
end
|
23
|
+
|
24
|
+
describe '#filter!' do
|
25
|
+
let(:response_status) { VCR::ResponseStatus.new(200, "OK foo") }
|
26
|
+
let(:body) { "The body foo this is (foo-Foo)" }
|
27
|
+
let(:headers) do {
|
28
|
+
'x-http-foo' => ['bar23', '23foo'],
|
29
|
+
'x-http-bar' => ['foo23', '18']
|
30
|
+
} end
|
31
|
+
|
32
|
+
let(:response) do
|
33
|
+
VCR::Response.new(
|
34
|
+
response_status,
|
35
|
+
headers.dup,
|
36
|
+
body.dup,
|
37
|
+
'1.1'
|
38
|
+
)
|
39
|
+
end
|
40
|
+
|
41
|
+
let(:request) do
|
42
|
+
VCR::Request.new(
|
43
|
+
:get,
|
44
|
+
'http://example-foo.com:80/foo/',
|
45
|
+
body.dup,
|
46
|
+
headers.dup
|
47
|
+
)
|
48
|
+
end
|
49
|
+
|
50
|
+
let(:interaction) { VCR::HTTPInteraction.new(request, response) }
|
51
|
+
|
52
|
+
subject { interaction.filter!('foo', 'AAA') }
|
53
|
+
|
54
|
+
it 'does nothing when given a blank argument' do
|
55
|
+
expect {
|
56
|
+
interaction.filter!(nil, 'AAA')
|
57
|
+
interaction.filter!('foo', nil)
|
58
|
+
interaction.filter!("", 'AAA')
|
59
|
+
interaction.filter!('foo', "")
|
60
|
+
}.not_to change { interaction }
|
61
|
+
end
|
62
|
+
|
63
|
+
[:request, :response].each do |part|
|
64
|
+
it "replaces the sensitive text in the #{part} header keys and values" do
|
65
|
+
subject.send(part).headers.should == {
|
66
|
+
'x-http-AAA' => ['bar23', '23AAA'],
|
67
|
+
'x-http-bar' => ['AAA23', '18']
|
68
|
+
}
|
69
|
+
end
|
70
|
+
|
71
|
+
it "replaces the sensitive text in the #{part} body" do
|
72
|
+
subject.send(part).body.should == "The body AAA this is (AAA-Foo)"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'replaces the sensitive text in the response status' do
|
77
|
+
subject.response.status.message.should == 'OK AAA'
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'replaces sensitive text in the request URI' do
|
81
|
+
subject.request.uri.should == 'http://example-AAA.com:80/AAA/'
|
82
|
+
end
|
83
|
+
end
|
23
84
|
end
|
@@ -13,9 +13,27 @@ describe VCR::Request do
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
+
describe '#method' do
|
17
|
+
subject { VCR::Request.new(:get) }
|
18
|
+
|
19
|
+
context 'when given no arguments' do
|
20
|
+
it 'returns the HTTP method' do
|
21
|
+
subject.method.should == :get
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'when given an argument' do
|
26
|
+
it 'returns the method object for the named method' do
|
27
|
+
m = subject.method(:class)
|
28
|
+
m.should be_a(Method)
|
29
|
+
m.call.should == described_class
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
16
34
|
describe '.from_net_http_request' do
|
17
|
-
let(:net_http) { YAML.
|
18
|
-
let(:request) { YAML.
|
35
|
+
let(:net_http) { VCR::YAML.load_file("#{VCR::SPEC_ROOT}/fixtures/#{YAML_SERIALIZATION_VERSION}/example_net_http.yml") }
|
36
|
+
let(:request) { VCR::YAML.load_file("#{VCR::SPEC_ROOT}/fixtures/#{YAML_SERIALIZATION_VERSION}/example_net_http_request.yml") }
|
19
37
|
subject { described_class.from_net_http_request(net_http, request) }
|
20
38
|
|
21
39
|
before(:each) do
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe VCR::Response do
|
4
4
|
describe '.from_net_http_response' do
|
5
|
-
let(:response) { YAML.
|
5
|
+
let(:response) { VCR::YAML.load_file("#{VCR::SPEC_ROOT}/fixtures/#{YAML_SERIALIZATION_VERSION}/example_net_http_response.yml") }
|
6
6
|
subject { described_class.from_net_http_response(response) }
|
7
7
|
|
8
8
|
it { should be_instance_of(described_class) }
|
@@ -36,4 +36,26 @@ describe VCR::Response do
|
|
36
36
|
described_class.new(:status, {}, body, '1.1')
|
37
37
|
end
|
38
38
|
end
|
39
|
+
|
40
|
+
describe '#update_content_length_header' do
|
41
|
+
def instance(body, content_length = nil)
|
42
|
+
headers = { 'content-type' => 'text' }
|
43
|
+
headers.merge!('content-length' => content_length) if content_length
|
44
|
+
described_class.new(VCR::ResponseStatus.new, headers, body)
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'does nothing when the response lacks a content_length header' do
|
48
|
+
inst = instance('the body')
|
49
|
+
expect {
|
50
|
+
inst.update_content_length_header
|
51
|
+
}.not_to change { inst.headers['content-length'] }
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'sets the content_length header to the response body length when the header is present' do
|
55
|
+
inst = instance('the body', '3')
|
56
|
+
expect {
|
57
|
+
inst.update_content_length_header
|
58
|
+
}.to change { inst.headers['content-length'] }.from(['3']).to(['8'])
|
59
|
+
end
|
60
|
+
end
|
39
61
|
end
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe VCR::ResponseStatus do
|
4
4
|
describe '.from_net_http_response' do
|
5
|
-
let(:response) { YAML.
|
5
|
+
let(:response) { VCR::YAML.load_file("#{VCR::SPEC_ROOT}/fixtures/#{YAML_SERIALIZATION_VERSION}/example_net_http_response.yml") }
|
6
6
|
subject { described_class.from_net_http_response(response) }
|
7
7
|
|
8
8
|
it { should be_instance_of(described_class) }
|
@@ -2,20 +2,24 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe VCR::CucumberTags do
|
4
4
|
subject { described_class.new(self) }
|
5
|
-
let(:
|
5
|
+
let(:before_blocks_for_tags) { {} }
|
6
|
+
let(:after_blocks_for_tags) { {} }
|
6
7
|
|
7
|
-
# define our own
|
8
|
-
def
|
9
|
-
|
8
|
+
# define our own Before/After so we can test this in isolation from cucumber's implementation.
|
9
|
+
def Before(tag, &block)
|
10
|
+
before_blocks_for_tags[tag.sub('@', '')] = block
|
11
|
+
end
|
12
|
+
|
13
|
+
def After(tag, &block)
|
14
|
+
after_blocks_for_tags[tag.sub('@', '')] = block
|
10
15
|
end
|
11
16
|
|
12
17
|
def test_tag(cassette_attribute, tag, expected_value)
|
13
18
|
VCR.current_cassette.should be_nil
|
14
19
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
cassette_during_scenario.send(cassette_attribute).should == expected_value
|
20
|
+
before_blocks_for_tags[tag].call
|
21
|
+
VCR.current_cassette.send(cassette_attribute).should == expected_value
|
22
|
+
after_blocks_for_tags[tag].call
|
19
23
|
|
20
24
|
VCR.current_cassette.should be_nil
|
21
25
|
end
|
File without changes
|
@@ -73,19 +73,19 @@ describe VCR::Hooks do
|
|
73
73
|
end
|
74
74
|
|
75
75
|
it 'passes along the provided arguments to the callback' do
|
76
|
-
subject.before_foo { |a, b| invocations << [a, b] }
|
76
|
+
subject.before_foo &lambda { |a, b| invocations << [a, b] }
|
77
77
|
subject.invoke_hook(:before_foo, nil, :arg1, :arg2)
|
78
78
|
invocations.flatten.should == [:arg1, :arg2]
|
79
79
|
end
|
80
80
|
|
81
81
|
it 'only passes along 1 argument when the block accepts only 1 arguments' do
|
82
|
-
subject.before_foo { |a| invocations << a }
|
82
|
+
subject.before_foo &lambda { |a| invocations << a }
|
83
83
|
subject.invoke_hook(:before_foo, nil, :arg1, :arg2)
|
84
84
|
invocations.flatten.should == [:arg1]
|
85
85
|
end
|
86
86
|
|
87
87
|
it 'passes along all arguments when the block accepts a variable number of args' do
|
88
|
-
subject.before_foo { |*a| invocations << a }
|
88
|
+
subject.before_foo &lambda { |*a| invocations << a }
|
89
89
|
subject.invoke_hook(:before_foo, nil, :arg1, :arg2)
|
90
90
|
invocations.flatten.should == [:arg1, :arg2]
|
91
91
|
end
|
@@ -7,7 +7,7 @@ describe VCR::InternetConnection do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def stub_pingecho_with(value)
|
10
|
-
Ping.stub(:pingecho).with("example.com", anything, anything).and_return(value)
|
10
|
+
VCR::Ping.stub(:pingecho).with("example.com", anything, anything).and_return(value)
|
11
11
|
end
|
12
12
|
|
13
13
|
context 'when pinging example.com succeeds' do
|
@@ -17,7 +17,7 @@ describe VCR::InternetConnection do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'memoizes the value so no extra pings are made' do
|
20
|
-
Ping.should_receive(:pingecho).once.and_return(true)
|
20
|
+
VCR::Ping.should_receive(:pingecho).once.and_return(true)
|
21
21
|
3.times { described_class.available? }
|
22
22
|
end
|
23
23
|
end
|
@@ -29,7 +29,7 @@ describe VCR::InternetConnection do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'memoizes the value so no extra pings are made' do
|
32
|
-
Ping.should_receive(:pingecho).once.and_return(false)
|
32
|
+
VCR::Ping.should_receive(:pingecho).once.and_return(false)
|
33
33
|
3.times { described_class.available? }
|
34
34
|
end
|
35
35
|
end
|
data/spec/vcr_spec.rb
CHANGED
@@ -52,14 +52,14 @@ describe VCR do
|
|
52
52
|
|
53
53
|
it 'yields' do
|
54
54
|
yielded = false
|
55
|
-
VCR.use_cassette(:cassette_test
|
55
|
+
VCR.use_cassette(:cassette_test, &lambda { yielded = true })
|
56
56
|
yielded.should be_true
|
57
57
|
end
|
58
58
|
|
59
59
|
it 'yields the cassette instance if the block expects an argument' do
|
60
|
-
VCR.use_cassette('name', :record => :new_episodes
|
60
|
+
VCR.use_cassette('name', :record => :new_episodes, &lambda do |cassette|
|
61
61
|
cassette.should equal(VCR.current_cassette)
|
62
|
-
end
|
62
|
+
end)
|
63
63
|
end
|
64
64
|
|
65
65
|
it 'yields the cassette instance if the block expects a variable number of args' do
|
data/vcr.gemspec
CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |s|
|
|
6
6
|
s.homepage = "http://github.com/myronmarston/vcr"
|
7
7
|
s.authors = ["Myron Marston"]
|
8
8
|
s.summary = "Record your test suite's HTTP interactions and replay them during future test runs for fast, deterministic, accurate tests."
|
9
|
-
s.description = "VCR provides
|
9
|
+
s.description = "VCR provides a simple API to record and replay your test suite's HTTP interactions. It works with a variety of HTTP client libraries, HTTP stubbing libraries and testing frameworks."
|
10
10
|
s.email = "myron.marston@gmail.com"
|
11
11
|
s.require_path = "lib"
|
12
12
|
s.files = `git ls-files`.split("\n")
|
@@ -21,9 +21,9 @@ Gem::Specification.new do |s|
|
|
21
21
|
'bundler' => '~> 1.0.7',
|
22
22
|
'rake' => '~> 0.8.7',
|
23
23
|
|
24
|
-
'rspec' => '~> 2.
|
24
|
+
'rspec' => '~> 2.5',
|
25
25
|
'cucumber' => '~> 0.9.4',
|
26
|
-
'aruba' => '
|
26
|
+
'aruba' => '0.2.4',
|
27
27
|
'shoulda' => '~> 2.9.2',
|
28
28
|
|
29
29
|
'fakeweb' => '~> 1.3.0',
|
@@ -40,9 +40,9 @@ Gem::Specification.new do |s|
|
|
40
40
|
end
|
41
41
|
|
42
42
|
{
|
43
|
-
'patron' => '
|
43
|
+
'patron' => '0.4.9',
|
44
44
|
'em-http-request' => '~> 0.2.7',
|
45
|
-
'curb' => '
|
45
|
+
'curb' => '0.7.8',
|
46
46
|
'typhoeus' => '~> 0.2.1'
|
47
47
|
}.each do |lib, version|
|
48
48
|
s.add_development_dependency lib, version
|