vcr 0.4.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +34 -0
- data/README.md +89 -21
- data/lib/vcr.rb +12 -1
- data/lib/vcr/cassette.rb +50 -27
- data/lib/vcr/config.rb +9 -0
- data/lib/vcr/deprecations.rb +15 -42
- data/lib/vcr/extensions/net_http.rb +13 -20
- data/lib/vcr/extensions/net_http_response.rb +6 -13
- data/lib/vcr/http_stubbing_adapters/fakeweb.rb +21 -3
- data/lib/vcr/http_stubbing_adapters/webmock.rb +34 -4
- data/lib/vcr/version.rb +16 -0
- metadata +90 -108
- data/.document +0 -5
- data/.gitignore +0 -22
- data/Rakefile +0 -67
- data/VERSION +0 -1
- data/benchmarks/http_stubbing_libraries.rb +0 -59
- data/features/fixtures/vcr_cassettes/1.8.6/cucumber_tags/replay_cassette1.yml +0 -43
- data/features/fixtures/vcr_cassettes/1.8.6/cucumber_tags/replay_cassette2.yml +0 -47
- data/features/fixtures/vcr_cassettes/1.8.6/cucumber_tags/replay_cassette3.yml +0 -85
- data/features/fixtures/vcr_cassettes/1.8.6/nested_replay_cassette.yml +0 -24
- data/features/fixtures/vcr_cassettes/1.8.6/not_the_real_response.yml +0 -43
- data/features/fixtures/vcr_cassettes/1.8.7/cucumber_tags/replay_cassette1.yml +0 -43
- data/features/fixtures/vcr_cassettes/1.8.7/cucumber_tags/replay_cassette2.yml +0 -47
- data/features/fixtures/vcr_cassettes/1.8.7/cucumber_tags/replay_cassette3.yml +0 -85
- data/features/fixtures/vcr_cassettes/1.8.7/nested_replay_cassette.yml +0 -24
- data/features/fixtures/vcr_cassettes/1.8.7/not_the_real_response.yml +0 -43
- data/features/fixtures/vcr_cassettes/1.9.1/cucumber_tags/replay_cassette1.yml +0 -43
- data/features/fixtures/vcr_cassettes/1.9.1/cucumber_tags/replay_cassette2.yml +0 -63
- data/features/fixtures/vcr_cassettes/1.9.1/cucumber_tags/replay_cassette3.yml +0 -85
- data/features/fixtures/vcr_cassettes/1.9.1/nested_replay_cassette.yml +0 -32
- data/features/fixtures/vcr_cassettes/1.9.1/not_the_real_response.yml +0 -43
- data/features/record_response.feature +0 -77
- data/features/replay_recorded_response.feature +0 -69
- data/features/step_definitions/vcr_steps.rb +0 -144
- data/features/support/env.rb +0 -64
- data/lib/vcr/extensions/fake_web.rb +0 -20
- data/lib/vcr/extensions/net_read_adapter.rb +0 -22
- data/spec/cassette_spec.rb +0 -213
- data/spec/config_spec.rb +0 -49
- data/spec/cucumber_tags_spec.rb +0 -71
- data/spec/deprecations_spec.rb +0 -67
- data/spec/extensions/net_http_response_spec.rb +0 -86
- data/spec/extensions/net_http_spec.rb +0 -72
- data/spec/extensions/net_read_adapter_spec.rb +0 -10
- data/spec/fixtures/1.8.6/0_3_1_cassette.yml +0 -29
- data/spec/fixtures/1.8.6/cassette_spec/example.yml +0 -110
- data/spec/fixtures/1.8.6/example_net_http.yml +0 -14
- data/spec/fixtures/1.8.6/example_net_http_request.yml +0 -12
- data/spec/fixtures/1.8.6/example_net_http_response.yml +0 -25
- data/spec/fixtures/1.8.6/fake_example.com_responses.yml +0 -90
- data/spec/fixtures/1.8.7/0_3_1_cassette.yml +0 -29
- data/spec/fixtures/1.8.7/cassette_spec/example.yml +0 -110
- data/spec/fixtures/1.8.7/example_net_http.yml +0 -14
- data/spec/fixtures/1.8.7/example_net_http_request.yml +0 -12
- data/spec/fixtures/1.8.7/example_net_http_response.yml +0 -25
- data/spec/fixtures/1.8.7/fake_example.com_responses.yml +0 -90
- data/spec/fixtures/1.9.1/0_3_1_cassette.yml +0 -29
- data/spec/fixtures/1.9.1/cassette_spec/example.yml +0 -110
- data/spec/fixtures/1.9.1/example_net_http.yml +0 -14
- data/spec/fixtures/1.9.1/example_net_http_request.yml +0 -12
- data/spec/fixtures/1.9.1/example_net_http_response.yml +0 -25
- data/spec/fixtures/1.9.1/fake_example.com_responses.yml +0 -90
- data/spec/http_stubbing_adapters/fakeweb_spec.rb +0 -24
- data/spec/http_stubbing_adapters/webmock_spec.rb +0 -23
- data/spec/spec.opts +0 -2
- data/spec/spec_helper.rb +0 -35
- data/spec/structs_spec.rb +0 -95
- data/spec/support/deprecated.rb +0 -18
- data/spec/support/disable_warnings.rb +0 -12
- data/spec/support/http_stubbing_adapter.rb +0 -113
- data/spec/support/temp_cassette_library_dir.rb +0 -16
- data/spec/task_runner_spec.rb +0 -59
- data/spec/vcr_spec.rb +0 -119
- data/vcr.gemspec +0 -147
@@ -1,110 +0,0 @@
|
|
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
|
-
server:
|
14
|
-
- Apache/2.2.3 (Red Hat)
|
15
|
-
last-modified:
|
16
|
-
- Tue, 15 Nov 2005 13:24:10 GMT
|
17
|
-
etag:
|
18
|
-
- "\"b300b4-1b6-4059a80bfd280\""
|
19
|
-
accept-ranges:
|
20
|
-
- bytes
|
21
|
-
content-type:
|
22
|
-
- text/html; charset=UTF-8
|
23
|
-
connection:
|
24
|
-
- Keep-Alive
|
25
|
-
date:
|
26
|
-
- Mon, 25 Jan 2010 18:00:32 GMT
|
27
|
-
age:
|
28
|
-
- "2090"
|
29
|
-
content-length:
|
30
|
-
- "438"
|
31
|
-
:body: |
|
32
|
-
<HTML>
|
33
|
-
<HEAD>
|
34
|
-
<TITLE>Example Web Page</TITLE>
|
35
|
-
</HEAD>
|
36
|
-
<body>
|
37
|
-
<p>You have reached this web page by typing "example.com",
|
38
|
-
"example.net",
|
39
|
-
or "example.org" into your web browser.</p>
|
40
|
-
<p>These domain names are reserved for use in documentation and are not available
|
41
|
-
for registration. See <a href="http://www.rfc-editor.org/rfc/rfc2606.txt">RFC
|
42
|
-
2606</a>, Section 3.</p>
|
43
|
-
</BODY>
|
44
|
-
</HTML>
|
45
|
-
|
46
|
-
:http_version: "1.1"
|
47
|
-
- !ruby/struct:VCR::HTTPInteraction
|
48
|
-
:request: !ruby/struct:VCR::Request
|
49
|
-
:method: :get
|
50
|
-
:uri: http://example.com:80/foo
|
51
|
-
:body:
|
52
|
-
:headers:
|
53
|
-
:response: !ruby/struct:VCR::Response
|
54
|
-
:status: !ruby/struct:VCR::ResponseStatus
|
55
|
-
:code: 404
|
56
|
-
:message: Not Found
|
57
|
-
:headers:
|
58
|
-
date:
|
59
|
-
- Mon, 25 Jan 2010 18:00:32 GMT
|
60
|
-
server:
|
61
|
-
- Apache/2.2.3 (CentOS)
|
62
|
-
content-length:
|
63
|
-
- "277"
|
64
|
-
connection:
|
65
|
-
- close
|
66
|
-
content-type:
|
67
|
-
- text/html; charset=iso-8859-1
|
68
|
-
:body: |
|
69
|
-
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
|
70
|
-
<html><head>
|
71
|
-
<title>404 Not Found</title>
|
72
|
-
</head><body>
|
73
|
-
<h1>Not Found</h1>
|
74
|
-
<p>The requested URL /foo was not found on this server.</p>
|
75
|
-
<hr>
|
76
|
-
<address>Apache/2.2.3 (CentOS) Server at example.com Port 80</address>
|
77
|
-
</body></html>
|
78
|
-
|
79
|
-
:http_version: "1.1"
|
80
|
-
- !ruby/struct:VCR::HTTPInteraction
|
81
|
-
:request: !ruby/struct:VCR::Request
|
82
|
-
:method: :get
|
83
|
-
:uri: http://example.com:80/
|
84
|
-
:body:
|
85
|
-
:headers:
|
86
|
-
:response: !ruby/struct:VCR::Response
|
87
|
-
:status: !ruby/struct:VCR::ResponseStatus
|
88
|
-
:code: 200
|
89
|
-
:message: OK
|
90
|
-
:headers:
|
91
|
-
server:
|
92
|
-
- Apache/2.2.3 (Red Hat)
|
93
|
-
last-modified:
|
94
|
-
- Tue, 15 Nov 2005 13:24:10 GMT
|
95
|
-
etag:
|
96
|
-
- "\"b300b4-1b6-4059a80bfd280\""
|
97
|
-
accept-ranges:
|
98
|
-
- bytes
|
99
|
-
content-type:
|
100
|
-
- text/html; charset=UTF-8
|
101
|
-
connection:
|
102
|
-
- Keep-Alive
|
103
|
-
date:
|
104
|
-
- Mon, 25 Jan 2010 18:00:32 GMT
|
105
|
-
age:
|
106
|
-
- "2090"
|
107
|
-
content-length:
|
108
|
-
- "438"
|
109
|
-
:body: Another example.com response
|
110
|
-
:http_version: "1.1"
|
@@ -1,14 +0,0 @@
|
|
1
|
-
--- !ruby/object:Net::HTTP
|
2
|
-
address: example.com
|
3
|
-
close_on_empty_response: false
|
4
|
-
curr_http_version: "1.1"
|
5
|
-
debug_output:
|
6
|
-
newimpl: true
|
7
|
-
open_timeout:
|
8
|
-
port: 80
|
9
|
-
read_timeout: 60
|
10
|
-
seems_1_0_server: false
|
11
|
-
socket:
|
12
|
-
ssl_context:
|
13
|
-
started: true
|
14
|
-
use_ssl: false
|
@@ -1,25 +0,0 @@
|
|
1
|
-
--- !ruby/object:Net::HTTPOK
|
2
|
-
body: The response from example.com
|
3
|
-
body_exist: true
|
4
|
-
code: "200"
|
5
|
-
header:
|
6
|
-
last-modified:
|
7
|
-
- Tue, 15 Nov 2005 13:24:10 GMT
|
8
|
-
connection:
|
9
|
-
- close
|
10
|
-
date:
|
11
|
-
- Wed, 31 Mar 2010 02:43:26 GMT
|
12
|
-
content-type:
|
13
|
-
- text/html; charset=UTF-8
|
14
|
-
etag:
|
15
|
-
- "\"24ec5-1b6-4059a80bfd280\""
|
16
|
-
server:
|
17
|
-
- Apache/2.2.3 (CentOS)
|
18
|
-
content-length:
|
19
|
-
- "438"
|
20
|
-
accept-ranges:
|
21
|
-
- bytes
|
22
|
-
http_version: "1.1"
|
23
|
-
message: OK
|
24
|
-
read: true
|
25
|
-
socket:
|
@@ -1,90 +0,0 @@
|
|
1
|
-
---
|
2
|
-
- !ruby/struct:VCR::HTTPInteraction
|
3
|
-
:request: !ruby/struct:VCR::Request
|
4
|
-
:method: :post
|
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
|
-
content-type:
|
18
|
-
- text/html; charset=UTF-8
|
19
|
-
connection:
|
20
|
-
- close
|
21
|
-
server:
|
22
|
-
- Apache/2.2.3 (CentOS)
|
23
|
-
date:
|
24
|
-
- Wed, 31 Mar 2010 02:43:26 GMT
|
25
|
-
content-length:
|
26
|
-
- "438"
|
27
|
-
accept-ranges:
|
28
|
-
- bytes
|
29
|
-
:body: example.com post response with id=7
|
30
|
-
:http_version: "1.1"
|
31
|
-
- !ruby/struct:VCR::HTTPInteraction
|
32
|
-
:request: !ruby/struct:VCR::Request
|
33
|
-
:method: :get
|
34
|
-
:uri: http://example.com:80/foo
|
35
|
-
:body:
|
36
|
-
:headers:
|
37
|
-
:response: !ruby/struct:VCR::Response
|
38
|
-
:status: !ruby/struct:VCR::ResponseStatus
|
39
|
-
:code: 200
|
40
|
-
:message: OK
|
41
|
-
:headers:
|
42
|
-
etag:
|
43
|
-
- "\"24ec5-1b6-4059a80bfd280\""
|
44
|
-
last-modified:
|
45
|
-
- Tue, 15 Nov 2005 13:24:10 GMT
|
46
|
-
connection:
|
47
|
-
- Keep-Alive
|
48
|
-
content-type:
|
49
|
-
- text/html; charset=UTF-8
|
50
|
-
date:
|
51
|
-
- Wed, 31 Mar 2010 02:43:23 GMT
|
52
|
-
server:
|
53
|
-
- Apache/2.2.3 (CentOS)
|
54
|
-
content-length:
|
55
|
-
- "438"
|
56
|
-
age:
|
57
|
-
- "3285"
|
58
|
-
accept-ranges:
|
59
|
-
- bytes
|
60
|
-
:body: example.com get response with path=foo
|
61
|
-
:http_version: "1.1"
|
62
|
-
- !ruby/struct:VCR::HTTPInteraction
|
63
|
-
:request: !ruby/struct:VCR::Request
|
64
|
-
:method: :post
|
65
|
-
:uri: http://example.com:80/
|
66
|
-
:body:
|
67
|
-
:headers:
|
68
|
-
:response: !ruby/struct:VCR::Response
|
69
|
-
:status: !ruby/struct:VCR::ResponseStatus
|
70
|
-
:code: 200
|
71
|
-
:message: OK
|
72
|
-
:headers:
|
73
|
-
etag:
|
74
|
-
- "\"24ec5-1b6-4059a80bfd280\""
|
75
|
-
last-modified:
|
76
|
-
- Tue, 15 Nov 2005 13:24:10 GMT
|
77
|
-
content-type:
|
78
|
-
- text/html; charset=UTF-8
|
79
|
-
connection:
|
80
|
-
- close
|
81
|
-
server:
|
82
|
-
- Apache/2.2.3 (CentOS)
|
83
|
-
date:
|
84
|
-
- Wed, 31 Mar 2010 02:43:26 GMT
|
85
|
-
content-length:
|
86
|
-
- "438"
|
87
|
-
accept-ranges:
|
88
|
-
- bytes
|
89
|
-
:body: example.com post response with id=3
|
90
|
-
:http_version: "1.1"
|
@@ -1,24 +0,0 @@
|
|
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
|
@@ -1,23 +0,0 @@
|
|
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.opts
DELETED
data/spec/spec_helper.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
-
require 'rubygems'
|
4
|
-
require 'vcr'
|
5
|
-
require 'spec'
|
6
|
-
require 'spec/autorun'
|
7
|
-
|
8
|
-
begin
|
9
|
-
require 'ruby-debug'
|
10
|
-
Debugger.start
|
11
|
-
Debugger.settings[:autoeval] = true if Debugger.respond_to?(:settings)
|
12
|
-
rescue LoadError
|
13
|
-
# ruby-debug wasn't available so neither can the debugging be
|
14
|
-
end
|
15
|
-
|
16
|
-
# Requires supporting files with custom matchers and macros, etc,
|
17
|
-
# in ./support/ and its subdirectories.
|
18
|
-
Dir[File.expand_path(File.join(File.dirname(__FILE__),'support','**','*.rb'))].each {|f| require f}
|
19
|
-
|
20
|
-
Spec::Runner.configure do |config|
|
21
|
-
config.extend TempCassetteLibraryDir
|
22
|
-
config.extend DisableWarnings
|
23
|
-
config.extend Deprecated
|
24
|
-
|
25
|
-
config.before(:each) do
|
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
|
-
|
32
|
-
FakeWeb.allow_net_connect = true
|
33
|
-
FakeWeb.clean_registry
|
34
|
-
end
|
35
|
-
end
|
data/spec/structs_spec.rb
DELETED
@@ -1,95 +0,0 @@
|
|
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
|
data/spec/support/deprecated.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
module Deprecated
|
2
|
-
def deprecated(old_method, new_method, message)
|
3
|
-
describe "##{old_method}" do
|
4
|
-
disable_warnings
|
5
|
-
|
6
|
-
it "delegates to ##{new_method}" do
|
7
|
-
subject.should_receive(new_method).with(:arg1, :arg2).and_return(:return_value)
|
8
|
-
subject.send(old_method, :arg1, :arg2).should == :return_value
|
9
|
-
end
|
10
|
-
|
11
|
-
it "prints a warning: #{message}" do
|
12
|
-
subject.stub!(new_method)
|
13
|
-
subject.should_receive(:warn).with(message)
|
14
|
-
subject.send(old_method)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|