vcr 0.3.1 → 0.4.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/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
@@ -1,12 +1,15 @@
|
|
1
1
|
---
|
2
|
-
- !ruby/struct:VCR::
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
body:
|
7
|
-
|
8
|
-
|
9
|
-
|
2
|
+
- !ruby/struct:VCR::HTTPInteraction
|
3
|
+
request: !ruby/struct:VCR::Request
|
4
|
+
method: :get
|
5
|
+
uri: http://example.com:80/nested
|
6
|
+
body:
|
7
|
+
headers:
|
8
|
+
response: !ruby/struct:VCR::Response
|
9
|
+
status: !ruby/struct:VCR::ResponseStatus
|
10
|
+
code: 404
|
11
|
+
message: Not Found
|
12
|
+
headers:
|
10
13
|
content-type:
|
11
14
|
- text/html; charset=iso-8859-1
|
12
15
|
connection:
|
@@ -17,7 +20,5 @@
|
|
17
20
|
- Thu, 25 Feb 2010 15:19:40 GMT
|
18
21
|
content-length:
|
19
22
|
- "280"
|
23
|
+
body: The nested response
|
20
24
|
http_version: "1.1"
|
21
|
-
message: Not Found
|
22
|
-
read: true
|
23
|
-
socket:
|
@@ -1,24 +1,15 @@
|
|
1
1
|
---
|
2
|
-
- !ruby/struct:VCR::
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
body:
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
This is not the real response from example.com
|
14
|
-
</p>
|
15
|
-
</BODY>
|
16
|
-
</HTML>
|
17
|
-
|
18
|
-
|
19
|
-
body_exist: true
|
20
|
-
code: "200"
|
21
|
-
header:
|
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:
|
22
13
|
etag:
|
23
14
|
- "\"24ec5-1b6-4059a80bfd280\""
|
24
15
|
last-modified:
|
@@ -37,7 +28,16 @@
|
|
37
28
|
- "2546"
|
38
29
|
accept-ranges:
|
39
30
|
- bytes
|
31
|
+
body: |
|
32
|
+
<HTML>
|
33
|
+
<HEAD>
|
34
|
+
<TITLE>Example Web Page</TITLE>
|
35
|
+
</HEAD>
|
36
|
+
<body>
|
37
|
+
<p>
|
38
|
+
This is not the real response from example.com
|
39
|
+
</p>
|
40
|
+
</BODY>
|
41
|
+
</HTML>
|
42
|
+
|
40
43
|
http_version: "1.1"
|
41
|
-
message: OK
|
42
|
-
read: true
|
43
|
-
socket:
|
@@ -1,24 +1,15 @@
|
|
1
1
|
---
|
2
|
-
- !ruby/struct:VCR::
|
3
|
-
:
|
4
|
-
|
5
|
-
|
6
|
-
body:
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
This is not the real response from example.com
|
14
|
-
</p>
|
15
|
-
</BODY>
|
16
|
-
</HTML>
|
17
|
-
|
18
|
-
|
19
|
-
body_exist: true
|
20
|
-
code: "200"
|
21
|
-
header:
|
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:
|
22
13
|
server:
|
23
14
|
- Apache/2.2.3 (Red Hat)
|
24
15
|
last-modified:
|
@@ -37,7 +28,16 @@
|
|
37
28
|
- "1696"
|
38
29
|
content-length:
|
39
30
|
- "438"
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
31
|
+
:body: |
|
32
|
+
<HTML>
|
33
|
+
<HEAD>
|
34
|
+
<TITLE>Example Web Page</TITLE>
|
35
|
+
</HEAD>
|
36
|
+
<body>
|
37
|
+
<p>
|
38
|
+
This is not the real response from example.com
|
39
|
+
</p>
|
40
|
+
</BODY>
|
41
|
+
</HTML>
|
42
|
+
|
43
|
+
:http_version: "1.1"
|
@@ -1,12 +1,15 @@
|
|
1
1
|
---
|
2
|
-
- !ruby/struct:VCR::
|
3
|
-
:
|
4
|
-
|
5
|
-
|
6
|
-
body:
|
7
|
-
|
8
|
-
|
9
|
-
|
2
|
+
- !ruby/struct:VCR::HTTPInteraction
|
3
|
+
:request: !ruby/struct:VCR::Request
|
4
|
+
:method: :get
|
5
|
+
:uri: http://example.com:80/before_nested
|
6
|
+
:body:
|
7
|
+
:headers:
|
8
|
+
:response: !ruby/struct:VCR::Response
|
9
|
+
:status: !ruby/struct:VCR::ResponseStatus
|
10
|
+
:code: 200
|
11
|
+
:message: OK
|
12
|
+
:headers:
|
10
13
|
server:
|
11
14
|
- Apache/2.2.3 (Red Hat)
|
12
15
|
last-modified:
|
@@ -25,18 +28,19 @@
|
|
25
28
|
- "1696"
|
26
29
|
content-length:
|
27
30
|
- "438"
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
31
|
+
:body: The before_nested response
|
32
|
+
:http_version: "1.1"
|
33
|
+
- !ruby/struct:VCR::HTTPInteraction
|
34
|
+
:request: !ruby/struct:VCR::Request
|
35
|
+
:method: :get
|
36
|
+
:uri: http://example.com:80/after_nested
|
37
|
+
:body:
|
38
|
+
:headers:
|
39
|
+
:response: !ruby/struct:VCR::Response
|
40
|
+
:status: !ruby/struct:VCR::ResponseStatus
|
41
|
+
:code: 200
|
42
|
+
:message: OK
|
43
|
+
:headers:
|
40
44
|
server:
|
41
45
|
- Apache/2.2.3 (Red Hat)
|
42
46
|
last-modified:
|
@@ -55,7 +59,5 @@
|
|
55
59
|
- "1696"
|
56
60
|
content-length:
|
57
61
|
- "438"
|
58
|
-
|
59
|
-
|
60
|
-
read: true
|
61
|
-
socket:
|
62
|
+
:body: The after_nested response
|
63
|
+
:http_version: "1.1"
|
@@ -1,24 +1,15 @@
|
|
1
1
|
---
|
2
|
-
- !ruby/struct:VCR::
|
3
|
-
:
|
4
|
-
|
5
|
-
|
6
|
-
body:
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
This is not the real response from example.com
|
14
|
-
</p>
|
15
|
-
</BODY>
|
16
|
-
</HTML>
|
17
|
-
|
18
|
-
|
19
|
-
body_exist: true
|
20
|
-
code: "200"
|
21
|
-
header:
|
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:
|
22
13
|
server:
|
23
14
|
- Apache/2.2.3 (Red Hat)
|
24
15
|
last-modified:
|
@@ -37,30 +28,30 @@
|
|
37
28
|
- "1696"
|
38
29
|
content-length:
|
39
30
|
- "438"
|
40
|
-
|
41
|
-
message: OK
|
42
|
-
read: true
|
43
|
-
socket:
|
44
|
-
- !ruby/struct:VCR::RecordedResponse
|
45
|
-
:method: :get
|
46
|
-
:uri: http://example.com:80/
|
47
|
-
:response: !ruby/object:Net::HTTPOK
|
48
|
-
body: |
|
31
|
+
:body: |
|
49
32
|
<HTML>
|
50
33
|
<HEAD>
|
51
34
|
<TITLE>Example Web Page</TITLE>
|
52
35
|
</HEAD>
|
53
36
|
<body>
|
54
37
|
<p>
|
55
|
-
This is
|
38
|
+
This is not the real response from example.com
|
56
39
|
</p>
|
57
40
|
</BODY>
|
58
41
|
</HTML>
|
59
|
-
|
60
42
|
|
61
|
-
|
62
|
-
|
63
|
-
|
43
|
+
:http_version: "1.1"
|
44
|
+
- !ruby/struct:VCR::HTTPInteraction
|
45
|
+
:request: !ruby/struct:VCR::Request
|
46
|
+
:method: :get
|
47
|
+
:uri: http://example.com:80/
|
48
|
+
:body:
|
49
|
+
:headers:
|
50
|
+
:response: !ruby/struct:VCR::Response
|
51
|
+
:status: !ruby/struct:VCR::ResponseStatus
|
52
|
+
:code: 200
|
53
|
+
:message: OK
|
54
|
+
:headers:
|
64
55
|
server:
|
65
56
|
- Apache/2.2.3 (Red Hat)
|
66
57
|
last-modified:
|
@@ -79,7 +70,16 @@
|
|
79
70
|
- "1696"
|
80
71
|
content-length:
|
81
72
|
- "438"
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
73
|
+
:body: |
|
74
|
+
<HTML>
|
75
|
+
<HEAD>
|
76
|
+
<TITLE>Example Web Page</TITLE>
|
77
|
+
</HEAD>
|
78
|
+
<body>
|
79
|
+
<p>
|
80
|
+
This is another fake response from example.com
|
81
|
+
</p>
|
82
|
+
</BODY>
|
83
|
+
</HTML>
|
84
|
+
|
85
|
+
:http_version: "1.1"
|
@@ -1,12 +1,15 @@
|
|
1
1
|
---
|
2
|
-
- !ruby/struct:VCR::
|
3
|
-
:
|
4
|
-
|
5
|
-
|
6
|
-
body:
|
7
|
-
|
8
|
-
|
9
|
-
|
2
|
+
- !ruby/struct:VCR::HTTPInteraction
|
3
|
+
:request: !ruby/struct:VCR::Request
|
4
|
+
:method: :get
|
5
|
+
:uri: http://example.com:80/nested
|
6
|
+
:body:
|
7
|
+
:headers:
|
8
|
+
:response: !ruby/struct:VCR::Response
|
9
|
+
:status: !ruby/struct:VCR::ResponseStatus
|
10
|
+
:code: 200
|
11
|
+
:message: OK
|
12
|
+
:headers:
|
10
13
|
server:
|
11
14
|
- Apache/2.2.3 (Red Hat)
|
12
15
|
last-modified:
|
@@ -25,7 +28,5 @@
|
|
25
28
|
- "1696"
|
26
29
|
content-length:
|
27
30
|
- "438"
|
28
|
-
|
29
|
-
|
30
|
-
read: true
|
31
|
-
socket:
|
31
|
+
:body: The nested response
|
32
|
+
:http_version: "1.1"
|
@@ -1,24 +1,15 @@
|
|
1
1
|
---
|
2
|
-
- !ruby/struct:VCR::
|
3
|
-
:
|
4
|
-
|
5
|
-
|
6
|
-
body:
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
This is not the real response from example.com
|
14
|
-
</p>
|
15
|
-
</BODY>
|
16
|
-
</HTML>
|
17
|
-
|
18
|
-
|
19
|
-
body_exist: true
|
20
|
-
code: "200"
|
21
|
-
header:
|
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:
|
22
13
|
server:
|
23
14
|
- Apache/2.2.3 (Red Hat)
|
24
15
|
last-modified:
|
@@ -37,7 +28,16 @@
|
|
37
28
|
- "1696"
|
38
29
|
content-length:
|
39
30
|
- "438"
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
31
|
+
:body: |
|
32
|
+
<HTML>
|
33
|
+
<HEAD>
|
34
|
+
<TITLE>Example Web Page</TITLE>
|
35
|
+
</HEAD>
|
36
|
+
<body>
|
37
|
+
<p>
|
38
|
+
This is not the real response from example.com
|
39
|
+
</p>
|
40
|
+
</BODY>
|
41
|
+
</HTML>
|
42
|
+
|
43
|
+
:http_version: "1.1"
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Feature: Record response
|
2
2
|
In order to have deterministic, fast tests that do not depend on an internet connection
|
3
3
|
As a TDD/BDD developer
|
4
|
-
I want to record responses for requests
|
4
|
+
I want to record responses for new requests so I can replay them in future test runs
|
5
5
|
|
6
6
|
Scenario: Record a response using VCR.use_cassette
|
7
7
|
Given we do not have a "temp/cassette" cassette
|
@@ -43,7 +43,7 @@ Feature: Record response
|
|
43
43
|
Scenario: Make an HTTP request in a cassette with record mode set to :none
|
44
44
|
Given we do not have a "temp/record_none_cassette" cassette
|
45
45
|
When I make an HTTP get request to "http://example.com" within the "temp/record_none_cassette" none cassette
|
46
|
-
Then the HTTP get request to "http://example.com" should result in
|
46
|
+
Then the HTTP get request to "http://example.com" should result in an error that mentions VCR
|
47
47
|
And there should not be a "temp/record_none_cassette" library file
|
48
48
|
|
49
49
|
@copy_not_the_real_response_to_temp
|
@@ -42,7 +42,7 @@ Feature: Replay recorded response
|
|
42
42
|
And we have a "temp/not_the_real_response" library file with no previously recorded response for "http://example.com/foo"
|
43
43
|
When I make HTTP get requests to "http://example.com" and "http://example.com/foo" within the "temp/not_the_real_response" none cassette
|
44
44
|
Then the response for "http://example.com" should match /This is not the real response from example\.com/
|
45
|
-
And the HTTP get request to "http://example.com/foo" should result in
|
45
|
+
And the HTTP get request to "http://example.com/foo" should result in an error that mentions VCR
|
46
46
|
|
47
47
|
@copy_not_the_real_response_to_temp
|
48
48
|
Scenario: Make an HTTP request in a cassette with record mode set to :new_episodes
|
@@ -9,10 +9,10 @@ module VCRHelpers
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
12
|
+
def recorded_interactions_for(cassette_name)
|
13
13
|
yaml_file = File.join(VCR::Config.cassette_library_dir, "#{cassette_name}.yml")
|
14
14
|
yaml = File.open(yaml_file, 'r') { |f| f.read }
|
15
|
-
|
15
|
+
interactions = YAML.load(yaml)
|
16
16
|
end
|
17
17
|
|
18
18
|
def capture_response(url)
|
@@ -112,22 +112,22 @@ When /^I make (.*HTTP (?:get|post)) requests? to "([^\"]*)"(?: and "([^\"]*)")?
|
|
112
112
|
end
|
113
113
|
|
114
114
|
Then /^the "([^\"]*)" library file should have a response for "([^\"]*)" that matches \/(.+)\/$/ do |cassette_name, url, regex_str|
|
115
|
-
|
116
|
-
|
115
|
+
interactions = recorded_interactions_for(cassette_name)
|
116
|
+
interactions.should have_expected_response(url, regex_str)
|
117
117
|
end
|
118
118
|
|
119
119
|
Then /^the "([^\"]*)" library file should have exactly (\d+) response$/ do |cassette_name, response_count|
|
120
|
-
|
121
|
-
|
120
|
+
interactions = recorded_interactions_for(cassette_name)
|
121
|
+
interactions.should have(response_count.to_i).responses
|
122
122
|
end
|
123
123
|
|
124
124
|
Then /^I can test the scenario cassette's recorded responses in the next scenario, after the cassette has been ejected$/ do
|
125
125
|
# do nothing...
|
126
126
|
end
|
127
127
|
|
128
|
-
Then /^the HTTP get request to "([^\"]*)" should result in
|
128
|
+
Then /^the HTTP get request to "([^\"]*)" should result in an error that mentions VCR$/ do |url|
|
129
129
|
result = @http_requests[url][0]
|
130
|
-
result.should
|
130
|
+
result.should be_a(StandardError)
|
131
131
|
result.message.should =~ /VCR/
|
132
132
|
end
|
133
133
|
|