vcr 1.1.0 → 1.1.1
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/.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,85 @@
|
|
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
|
+
last-modified:
|
14
|
+
- Tue, 15 Nov 2005 13:24:10 GMT
|
15
|
+
connection:
|
16
|
+
- Keep-Alive
|
17
|
+
etag:
|
18
|
+
- "\"24ec5-1b6-4059a80bfd280\""
|
19
|
+
content-type:
|
20
|
+
- text/html; charset=UTF-8
|
21
|
+
date:
|
22
|
+
- Thu, 25 Feb 2010 15:22:32 GMT
|
23
|
+
server:
|
24
|
+
- Apache/2.2.3 (CentOS)
|
25
|
+
content-length:
|
26
|
+
- "438"
|
27
|
+
age:
|
28
|
+
- "2643"
|
29
|
+
accept-ranges:
|
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
|
+
|
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:
|
55
|
+
last-modified:
|
56
|
+
- Tue, 15 Nov 2005 13:24:10 GMT
|
57
|
+
connection:
|
58
|
+
- Keep-Alive
|
59
|
+
etag:
|
60
|
+
- "\"24ec5-1b6-4059a80bfd280\""
|
61
|
+
content-type:
|
62
|
+
- text/html; charset=UTF-8
|
63
|
+
date:
|
64
|
+
- Thu, 25 Feb 2010 15:22:32 GMT
|
65
|
+
server:
|
66
|
+
- Apache/2.2.3 (CentOS)
|
67
|
+
content-length:
|
68
|
+
- "438"
|
69
|
+
age:
|
70
|
+
- "2643"
|
71
|
+
accept-ranges:
|
72
|
+
- bytes
|
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"
|
@@ -0,0 +1,36 @@
|
|
1
|
+
---
|
2
|
+
- !ruby/struct:VCR::HTTPInteraction
|
3
|
+
request: !ruby/struct:VCR::Request
|
4
|
+
method: :get
|
5
|
+
uri: http://example.com:80/embedded_ruby_code
|
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
|
+
connection:
|
18
|
+
- Keep-Alive
|
19
|
+
content-type:
|
20
|
+
- text/html; charset=UTF-8
|
21
|
+
date:
|
22
|
+
- Thu, 25 Feb 2010 15:20:47 GMT
|
23
|
+
server:
|
24
|
+
- Apache/2.2.3 (CentOS)
|
25
|
+
content-length:
|
26
|
+
- "438"
|
27
|
+
age:
|
28
|
+
- "2546"
|
29
|
+
accept-ranges:
|
30
|
+
- bytes
|
31
|
+
body: |
|
32
|
+
Some embedded ruby code: <%= 4 + 3 %>
|
33
|
+
The value of some_variable is: <%= some_variable %>
|
34
|
+
|
35
|
+
http_version: "1.1"
|
36
|
+
|
@@ -0,0 +1,35 @@
|
|
1
|
+
---
|
2
|
+
- !ruby/struct:VCR::HTTPInteraction
|
3
|
+
request: !ruby/struct:VCR::Request
|
4
|
+
method: :post
|
5
|
+
uri: http://example.com:80/
|
6
|
+
body: foo=bar
|
7
|
+
headers:
|
8
|
+
x-http-user:
|
9
|
+
- bob
|
10
|
+
response: !ruby/struct:VCR::Response
|
11
|
+
status: !ruby/struct:VCR::ResponseStatus
|
12
|
+
code: 200
|
13
|
+
message: OK
|
14
|
+
headers:
|
15
|
+
etag:
|
16
|
+
- "\"24ec5-1b6-4059a80bfd280\""
|
17
|
+
body: foo=bar response | bob response
|
18
|
+
http_version: "1.1"
|
19
|
+
- !ruby/struct:VCR::HTTPInteraction
|
20
|
+
request: !ruby/struct:VCR::Request
|
21
|
+
method: :post
|
22
|
+
uri: http://example.com:80/
|
23
|
+
body: bar=bazz
|
24
|
+
headers:
|
25
|
+
x-http-user:
|
26
|
+
- joe
|
27
|
+
response: !ruby/struct:VCR::Response
|
28
|
+
status: !ruby/struct:VCR::ResponseStatus
|
29
|
+
code: 200
|
30
|
+
message: OK
|
31
|
+
headers:
|
32
|
+
etag:
|
33
|
+
- "\"24ec5-1b6-4059a80bfd280\""
|
34
|
+
body: bar=bazz response | joe response
|
35
|
+
http_version: "1.1"
|
@@ -0,0 +1,24 @@
|
|
1
|
+
---
|
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:
|
13
|
+
connection:
|
14
|
+
- close
|
15
|
+
content-type:
|
16
|
+
- text/html; charset=iso-8859-1
|
17
|
+
date:
|
18
|
+
- Thu, 25 Feb 2010 15:19:40 GMT
|
19
|
+
server:
|
20
|
+
- Apache/2.2.3 (CentOS)
|
21
|
+
content-length:
|
22
|
+
- "280"
|
23
|
+
body: The nested response
|
24
|
+
http_version: "1.1"
|
@@ -0,0 +1,43 @@
|
|
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
|
+
last-modified:
|
14
|
+
- Tue, 15 Nov 2005 13:24:10 GMT
|
15
|
+
connection:
|
16
|
+
- Keep-Alive
|
17
|
+
etag:
|
18
|
+
- "\"24ec5-1b6-4059a80bfd280\""
|
19
|
+
content-type:
|
20
|
+
- text/html; charset=UTF-8
|
21
|
+
date:
|
22
|
+
- Thu, 25 Feb 2010 15:20:47 GMT
|
23
|
+
server:
|
24
|
+
- Apache/2.2.3 (CentOS)
|
25
|
+
content-length:
|
26
|
+
- "438"
|
27
|
+
age:
|
28
|
+
- "2546"
|
29
|
+
accept-ranges:
|
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
|
+
|
43
|
+
http_version: "1.1"
|
@@ -0,0 +1,32 @@
|
|
1
|
+
---
|
2
|
+
- !ruby/struct:VCR::HTTPInteraction
|
3
|
+
request: !ruby/struct:VCR::Request
|
4
|
+
method: :get
|
5
|
+
uri: http://localhost/
|
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
|
+
connection:
|
18
|
+
- Keep-Alive
|
19
|
+
content-type:
|
20
|
+
- text/html; charset=UTF-8
|
21
|
+
date:
|
22
|
+
- Thu, 25 Feb 2010 15:22:32 GMT
|
23
|
+
server:
|
24
|
+
- Apache/2.2.3 (CentOS)
|
25
|
+
content-length:
|
26
|
+
- "438"
|
27
|
+
age:
|
28
|
+
- "2643"
|
29
|
+
accept-ranges:
|
30
|
+
- bytes
|
31
|
+
body: This is a fake response.
|
32
|
+
http_version: "1.1"
|
@@ -0,0 +1,16 @@
|
|
1
|
+
@httpclient
|
2
|
+
Feature: HTTPClient
|
3
|
+
In order to have deterministic, fast tests that do not depend on an internet connection
|
4
|
+
As a TDD/BDD developer
|
5
|
+
I want VCR to work with asynchronous HTTPClient requests
|
6
|
+
|
7
|
+
Scenario: Record an asynchronous request
|
8
|
+
Given we do not have a "temp/asynchronous" cassette
|
9
|
+
When I make an asynchronous HTTPClient get request to "http://example.com" within the "temp/asynchronous" cassette
|
10
|
+
Then the "temp/asynchronous" library file should have a response for "http://example.com" that matches /You have reached this web page by typing.*example\.com/
|
11
|
+
|
12
|
+
@copy_not_the_real_response_to_temp
|
13
|
+
Scenario: Replay a response for an asynchronous request
|
14
|
+
Given the "temp/not_the_real_response" library file has a response for "http://example.com" that matches /This is not the real response from example\.com/
|
15
|
+
When I make an asynchronous HTTPClient get request to "http://example.com" within the "temp/not_the_real_response" cassette
|
16
|
+
Then the response for "http://example.com" should match /This is not the real response from example\.com/
|
@@ -0,0 +1,27 @@
|
|
1
|
+
@net_http
|
2
|
+
Feature: Net::HTTP
|
3
|
+
In order to have deterministic, fast tests that do not depend on an internet connection
|
4
|
+
As a TDD/BDD developer
|
5
|
+
I want to use VCR with Net::HTTP
|
6
|
+
|
7
|
+
Scenario: Record an asynchronous request (such as for mechanize)
|
8
|
+
Given we do not have a "temp/asynchronous" cassette
|
9
|
+
When I make an asynchronous Net::HTTP get request to "http://example.com" within the "temp/asynchronous" cassette
|
10
|
+
Then the "temp/asynchronous" library file should have a response for "http://example.com" that matches /You have reached this web page by typing.*example\.com/
|
11
|
+
|
12
|
+
@copy_not_the_real_response_to_temp
|
13
|
+
Scenario: Replay a response for an asynchronous request (such as for mechanize)
|
14
|
+
Given the "temp/not_the_real_response" library file has a response for "http://example.com" that matches /This is not the real response from example\.com/
|
15
|
+
When I make a replayed asynchronous Net::HTTP get request to "http://example.com" within the "temp/not_the_real_response" cassette
|
16
|
+
Then the response for "http://example.com" should match /This is not the real response from example\.com/
|
17
|
+
|
18
|
+
Scenario: Record a recursive post request
|
19
|
+
Given we do not have a "temp/recursive_post" cassette
|
20
|
+
When I make a recursive Net::HTTP post request to "http://example.com" within the "temp/recursive_post" cassette
|
21
|
+
Then the "temp/recursive_post" library file should have a response for "http://example.com" that matches /You have reached this web page by typing.*example\.com/
|
22
|
+
And the "temp/recursive_post" library file should have exactly 1 response
|
23
|
+
|
24
|
+
Scenario: Record a request with a block with a return statement
|
25
|
+
Given we do not have a "temp/block_with_a_return" cassette
|
26
|
+
When I make a returning block Net::HTTP get request to "http://example.com" within the "temp/block_with_a_return" cassette
|
27
|
+
Then the "temp/block_with_a_return" library file should have a response for "http://example.com" that matches /You have reached this web page by typing.*example\.com/
|
@@ -0,0 +1,66 @@
|
|
1
|
+
@all_http_libs
|
2
|
+
Feature: Record response
|
3
|
+
In order to have deterministic, fast tests that do not depend on an internet connection
|
4
|
+
As a TDD/BDD developer
|
5
|
+
I want to record responses for new requests so I can replay them in future test runs
|
6
|
+
|
7
|
+
Scenario: Record a response using VCR.use_cassette
|
8
|
+
Given we do not have a "temp/cassette" cassette
|
9
|
+
When I make an HTTP get request to "http://example.com/" within the "temp/cassette" cassette
|
10
|
+
Then the "temp/cassette" library file should have a response for "http://example.com/" that matches /You have reached this web page by typing.*example\.com/
|
11
|
+
And the "temp/cassette" library file should have normalized headers for all recorded interactions
|
12
|
+
|
13
|
+
@record_cassette1
|
14
|
+
Scenario: Record a response using a tagged scenario
|
15
|
+
Given we do not have a "cucumber_tags/record_cassette1" cassette
|
16
|
+
And this scenario is tagged with the vcr cassette tag: "@record_cassette1"
|
17
|
+
When I make an HTTP get request to "http://example.com/"
|
18
|
+
Then I can test the scenario cassette's recorded responses in the next scenario, after the cassette has been ejected
|
19
|
+
|
20
|
+
Scenario: Check the recorded response for the previous scenario
|
21
|
+
Given the previous scenario was tagged with the vcr cassette tag: "@record_cassette1"
|
22
|
+
Then the "cucumber_tags/record_cassette1" library file should have a response for "http://example.com/" that matches /You have reached this web page by typing.*example\.com/
|
23
|
+
|
24
|
+
@record_cassette2
|
25
|
+
Scenario: Use both a tagged scenario cassette and a nested cassette within a single step definition
|
26
|
+
Given we do not have a "cucumber_tags/record_cassette2" cassette
|
27
|
+
And we do not have a "temp/nested" cassette
|
28
|
+
And this scenario is tagged with the vcr cassette tag: "@record_cassette2"
|
29
|
+
When I make an HTTP get request to "http://example.com/before_nested"
|
30
|
+
And I make an HTTP get request to "http://example.com/nested" within the "temp/nested" cassette
|
31
|
+
And I make an HTTP get request to "http://example.com/after_nested"
|
32
|
+
Then I can test the scenario cassette's recorded responses in the next scenario, after the cassette has been ejected
|
33
|
+
And the "temp/nested" library file should have a response for "http://example.com/nested" that matches /The requested URL \/nested was not found/
|
34
|
+
|
35
|
+
Scenario: Check the recorded response for the previous scenario
|
36
|
+
Given the previous scenario was tagged with the vcr cassette tag: "@record_cassette2"
|
37
|
+
Then the "cucumber_tags/record_cassette2" library file should have a response for "http://example.com/before_nested" that matches /The requested URL \/before_nested was not found/
|
38
|
+
And the "cucumber_tags/record_cassette2" library file should have a response for "http://example.com/after_nested" that matches /The requested URL \/after_nested was not found/
|
39
|
+
|
40
|
+
Scenario: Make an HTTP request in a cassette with record mode set to :all
|
41
|
+
Given we do not have a "temp/record_all_cassette" cassette
|
42
|
+
When I make an HTTP get request to "http://example.com/" within the "temp/record_all_cassette" cassette using cassette options: { :record => :all }
|
43
|
+
Then the "temp/record_all_cassette" library file should have a response for "http://example.com/" that matches /You have reached this web page by typing.*example\.com/
|
44
|
+
|
45
|
+
Scenario: Make an HTTP request in a cassette with record mode set to :none
|
46
|
+
Given we do not have a "temp/record_none_cassette" cassette
|
47
|
+
When I make an HTTP get request to "http://example.com/" within the "temp/record_none_cassette" cassette using cassette options: { :record => :none }
|
48
|
+
Then the HTTP get request to "http://example.com/" should result in an error that mentions VCR
|
49
|
+
And there should not be a "temp/record_none_cassette" library file
|
50
|
+
|
51
|
+
@copy_not_the_real_response_to_temp
|
52
|
+
Scenario: Make an HTTP request in a cassette with record mode set to :new_episodes
|
53
|
+
Given we have a "temp/not_the_real_response" library file with a previously recorded response for "http://example.com/"
|
54
|
+
And we have a "temp/not_the_real_response" library file with no previously recorded response for "http://example.com/foo"
|
55
|
+
When I make HTTP get requests to "http://example.com/" and "http://example.com/foo" within the "temp/not_the_real_response" cassette
|
56
|
+
Then the "temp/not_the_real_response" library file should have a response for "http://example.com/" that matches /This is not the real response from example\.com/
|
57
|
+
And the "temp/not_the_real_response" library file should have a response for "http://example.com/foo" that matches /The requested URL \/foo was not found/
|
58
|
+
|
59
|
+
@spawns_localhost_server
|
60
|
+
Scenario: Ignore localhost setting allows localhost requests and does not record them
|
61
|
+
Given we do not have a "temp/localhost" cassette
|
62
|
+
And the ignore_localhost config setting is set to true
|
63
|
+
And a rack app is running on localhost that returns "hello world" for all requests
|
64
|
+
When I make an HTTP get request to the localhost rack app within the "temp/localhost" cassette
|
65
|
+
Then the response for the localhost rack app should match /hello world/
|
66
|
+
And there should not be a "temp/localhost" library file
|
@@ -0,0 +1,96 @@
|
|
1
|
+
@all_http_libs
|
2
|
+
Feature: Replay recorded response
|
3
|
+
In order to have deterministic, fast tests that do not depend on an internet connection
|
4
|
+
As a TDD/BDD developer
|
5
|
+
I want to replay responses for requests I have previously recorded
|
6
|
+
|
7
|
+
Scenario: Replay recorded response for a request in a VCR.use_cassette block
|
8
|
+
Given the "not_the_real_response" library file has a response for "http://example.com/" that matches /This is not the real response from example\.com/
|
9
|
+
When I make an HTTP get request to "http://example.com/" within the "not_the_real_response" cassette
|
10
|
+
Then the response for "http://example.com/" should match /This is not the real response from example\.com/
|
11
|
+
|
12
|
+
@replay_cassette1
|
13
|
+
Scenario: Replay recorded response for a request within a tagged scenario
|
14
|
+
Given this scenario is tagged with the vcr cassette tag: "@replay_cassette1"
|
15
|
+
And the "cucumber_tags/replay_cassette1" library file has a response for "http://example.com/" that matches /This is not the real response from example\.com/
|
16
|
+
When I make an HTTP get request to "http://example.com/"
|
17
|
+
Then the response for "http://example.com/" should match /This is not the real response from example\.com/
|
18
|
+
|
19
|
+
@replay_cassette2
|
20
|
+
Scenario: Use both a tagged scenario cassette and a nested cassette within a single step definition
|
21
|
+
Given this scenario is tagged with the vcr cassette tag: "@replay_cassette2"
|
22
|
+
And the "cucumber_tags/replay_cassette2" library file has a response for "http://example.com/before_nested" that matches /The before_nested response/
|
23
|
+
And the "nested_replay_cassette" library file has a response for "http://example.com/nested" that matches /The nested response/
|
24
|
+
And the "cucumber_tags/replay_cassette2" library file has a response for "http://example.com/after_nested" that matches /The after_nested response/
|
25
|
+
When I make an HTTP get request to "http://example.com/before_nested"
|
26
|
+
And I make an HTTP get request to "http://example.com/nested" within the "nested_replay_cassette" cassette
|
27
|
+
And I make an HTTP get request to "http://example.com/after_nested"
|
28
|
+
Then the response for "http://example.com/before_nested" should match /The before_nested response/
|
29
|
+
And the response for "http://example.com/nested" should match /The nested response/
|
30
|
+
And the response for "http://example.com/after_nested" should match /The after_nested response/
|
31
|
+
|
32
|
+
@copy_not_the_real_response_to_temp
|
33
|
+
Scenario: Make an HTTP request in a cassette with record mode set to :all
|
34
|
+
Given we have a "temp/not_the_real_response" library file with a previously recorded response for "http://example.com/"
|
35
|
+
And we have a "temp/not_the_real_response" library file with no previously recorded response for "http://example.com/foo"
|
36
|
+
When I make HTTP get requests to "http://example.com/" and "http://example.com/foo" within the "temp/not_the_real_response" cassette using cassette options: { :record => :all }
|
37
|
+
Then the response for "http://example.com/" should match /You have reached this web page by typing.*example\.com/
|
38
|
+
And the response for "http://example.com/foo" should match /The requested URL \/foo was not found/
|
39
|
+
|
40
|
+
@copy_not_the_real_response_to_temp
|
41
|
+
Scenario: Make an HTTP request in a cassette with record mode set to :none
|
42
|
+
Given we have a "temp/not_the_real_response" library file with a previously recorded response for "http://example.com/"
|
43
|
+
And we have a "temp/not_the_real_response" library file with no previously recorded response for "http://example.com/foo"
|
44
|
+
When I make HTTP get requests to "http://example.com/" and "http://example.com/foo" within the "temp/not_the_real_response" cassette using cassette options: { :record => :none }
|
45
|
+
Then the response for "http://example.com/" should match /This is not the real response from example\.com/
|
46
|
+
And the HTTP get request to "http://example.com/foo" should result in an error that mentions VCR
|
47
|
+
|
48
|
+
@copy_not_the_real_response_to_temp
|
49
|
+
Scenario: Make an HTTP request in a cassette with record mode set to :new_episodes
|
50
|
+
Given we have a "temp/not_the_real_response" library file with a previously recorded response for "http://example.com/"
|
51
|
+
And we have a "temp/not_the_real_response" library file with no previously recorded response for "http://example.com/foo"
|
52
|
+
When I make HTTP get requests to "http://example.com/" and "http://example.com/foo" within the "temp/not_the_real_response" cassette
|
53
|
+
Then the response for "http://example.com/" should match /This is not the real response from example\.com/
|
54
|
+
And the response for "http://example.com/foo" should match /The requested URL \/foo was not found/
|
55
|
+
|
56
|
+
@replay_cassette3
|
57
|
+
Scenario: Replay multiple different recorded responses for requests to the same URL
|
58
|
+
Given this scenario is tagged with the vcr cassette tag: "@replay_cassette3"
|
59
|
+
And the "cucumber_tags/replay_cassette3" library file has a response for "http://example.com/" that matches /This is not the real response from example\.com/
|
60
|
+
And the "cucumber_tags/replay_cassette3" library file has a response for "http://example.com/" that matches /This is another fake response from example\.com/
|
61
|
+
When I make an HTTP get request to "http://example.com/"
|
62
|
+
And I make an HTTP get request to "http://example.com/"
|
63
|
+
Then response 1 for "http://example.com/" should match /This is not the real response from example\.com/
|
64
|
+
And response 2 for "http://example.com/" should match /This is another fake response from example\.com/
|
65
|
+
|
66
|
+
@regex_cassette
|
67
|
+
Scenario: Replay a cassette with a regex URI
|
68
|
+
Given this scenario is tagged with the vcr cassette tag: "@regex_cassette"
|
69
|
+
And the "cucumber_tags/regex_cassette" library file has a response for /example\.com\/reg/ that matches /This is the response from the regex cassette/
|
70
|
+
When I make an HTTP get request to "http://example.com/regex1"
|
71
|
+
And I make an HTTP get request to "http://example.com/regex2"
|
72
|
+
And I make an HTTP get request to "http://example.com/something_else"
|
73
|
+
Then the response for "http://example.com/regex1" should match /This is the response from the regex cassette/
|
74
|
+
And the response for "http://example.com/regex2" should match /This is the response from the regex cassette/
|
75
|
+
And the HTTP get request to "http://example.com/something_else" should result in an error that mentions VCR
|
76
|
+
|
77
|
+
Scenario: Replay recorded erb response
|
78
|
+
Given the "erb_cassette" library file has a response for "http://example.com/embedded_ruby_code" that matches /Some embedded ruby code[\S\s]*The value of some_variable is/
|
79
|
+
When I make an HTTP get request to "http://example.com/embedded_ruby_code" within the "erb_cassette" cassette using cassette options: { :record => :none, :erb => { :some_variable => 'foo-bar' } }
|
80
|
+
Then the response for "http://example.com/embedded_ruby_code" should match /Some embedded ruby code: 7[\S\s]*The value of some_variable is: foo-bar/
|
81
|
+
|
82
|
+
@create_replay_localhost_cassette @spawns_localhost_server
|
83
|
+
Scenario: Replay recorded localhost response with ignore_localhost = false
|
84
|
+
Given the ignore_localhost config setting is set to false
|
85
|
+
And the "temp/replay_localhost_cassette" library file has a response for localhost that matches /This is a fake response/
|
86
|
+
And a rack app is running on localhost that returns "localhost response" for all requests
|
87
|
+
When I make an HTTP get request to the localhost rack app within the "temp/replay_localhost_cassette" cassette
|
88
|
+
Then the response for the localhost rack app should match /This is a fake response/
|
89
|
+
|
90
|
+
@create_replay_localhost_cassette @spawns_localhost_server
|
91
|
+
Scenario: Replay recorded localhost response with ignore_localhost = true
|
92
|
+
Given the ignore_localhost config setting is set to true
|
93
|
+
And the "temp/replay_localhost_cassette" library file has a response for localhost that matches /This is a fake response/
|
94
|
+
And a rack app is running on localhost that returns "localhost response" for all requests
|
95
|
+
When I make an HTTP get request to the localhost rack app within the "temp/replay_localhost_cassette" cassette
|
96
|
+
Then the response for the localhost rack app should match /localhost response/
|