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.
Files changed (70) hide show
  1. data/CHANGELOG.md +62 -0
  2. data/README.md +224 -0
  3. data/Rakefile +12 -5
  4. data/VERSION +1 -1
  5. data/benchmarks/http_stubbing_libraries.rb +59 -0
  6. data/features/fixtures/vcr_cassettes/1.8.6/cucumber_tags/replay_cassette1.yml +25 -25
  7. data/features/fixtures/vcr_cassettes/1.8.6/cucumber_tags/replay_cassette2.yml +32 -30
  8. data/features/fixtures/vcr_cassettes/1.8.6/cucumber_tags/replay_cassette3.yml +40 -40
  9. data/features/fixtures/vcr_cassettes/1.8.6/nested_replay_cassette.yml +16 -15
  10. data/features/fixtures/vcr_cassettes/1.8.6/not_the_real_response.yml +25 -25
  11. data/features/fixtures/vcr_cassettes/1.8.7/cucumber_tags/replay_cassette1.yml +23 -23
  12. data/features/fixtures/vcr_cassettes/1.8.7/cucumber_tags/replay_cassette2.yml +24 -22
  13. data/features/fixtures/vcr_cassettes/1.8.7/cucumber_tags/replay_cassette3.yml +36 -36
  14. data/features/fixtures/vcr_cassettes/1.8.7/nested_replay_cassette.yml +12 -11
  15. data/features/fixtures/vcr_cassettes/1.8.7/not_the_real_response.yml +23 -23
  16. data/features/fixtures/vcr_cassettes/1.9.1/cucumber_tags/replay_cassette1.yml +24 -24
  17. data/features/fixtures/vcr_cassettes/1.9.1/cucumber_tags/replay_cassette2.yml +26 -24
  18. data/features/fixtures/vcr_cassettes/1.9.1/cucumber_tags/replay_cassette3.yml +38 -38
  19. data/features/fixtures/vcr_cassettes/1.9.1/nested_replay_cassette.yml +13 -12
  20. data/features/fixtures/vcr_cassettes/1.9.1/not_the_real_response.yml +24 -24
  21. data/features/record_response.feature +2 -2
  22. data/features/replay_recorded_response.feature +1 -1
  23. data/features/step_definitions/vcr_steps.rb +8 -8
  24. data/features/support/env.rb +6 -0
  25. data/lib/vcr.rb +16 -3
  26. data/lib/vcr/cassette.rb +49 -46
  27. data/lib/vcr/config.rb +8 -0
  28. data/lib/vcr/extensions/fake_web.rb +12 -26
  29. data/lib/vcr/extensions/net_http.rb +9 -26
  30. data/lib/vcr/http_stubbing_adapters/base.rb +34 -0
  31. data/lib/vcr/http_stubbing_adapters/fakeweb.rb +75 -0
  32. data/lib/vcr/http_stubbing_adapters/webmock.rb +80 -0
  33. data/lib/vcr/structs.rb +44 -0
  34. data/lib/vcr/task_runner.rb +47 -0
  35. data/lib/vcr/tasks/vcr.rake +9 -0
  36. data/spec/cassette_spec.rb +70 -71
  37. data/spec/config_spec.rb +27 -0
  38. data/spec/extensions/net_http_spec.rb +21 -17
  39. data/spec/fixtures/1.8.6/0_3_1_cassette.yml +29 -0
  40. data/spec/fixtures/1.8.6/cassette_spec/example.yml +110 -108
  41. data/spec/fixtures/1.8.6/example_net_http.yml +14 -0
  42. data/spec/fixtures/1.8.6/example_net_http_request.yml +12 -0
  43. data/spec/fixtures/1.8.6/example_net_http_response.yml +25 -0
  44. data/spec/fixtures/1.8.6/fake_example.com_responses.yml +90 -0
  45. data/spec/fixtures/1.8.7/0_3_1_cassette.yml +29 -0
  46. data/spec/fixtures/1.8.7/cassette_spec/example.yml +110 -108
  47. data/spec/fixtures/1.8.7/example_net_http.yml +14 -0
  48. data/spec/fixtures/1.8.7/example_net_http_request.yml +12 -0
  49. data/spec/fixtures/1.8.7/example_net_http_response.yml +25 -0
  50. data/spec/fixtures/1.8.7/fake_example.com_responses.yml +90 -0
  51. data/spec/fixtures/1.9.1/0_3_1_cassette.yml +29 -0
  52. data/spec/fixtures/1.9.1/cassette_spec/example.yml +62 -59
  53. data/spec/fixtures/1.9.1/example_net_http.yml +14 -0
  54. data/spec/fixtures/1.9.1/example_net_http_request.yml +12 -0
  55. data/spec/fixtures/1.9.1/example_net_http_response.yml +25 -0
  56. data/spec/fixtures/1.9.1/fake_example.com_responses.yml +90 -0
  57. data/spec/http_stubbing_adapters/fakeweb_spec.rb +24 -0
  58. data/spec/http_stubbing_adapters/webmock_spec.rb +23 -0
  59. data/spec/spec_helper.rb +5 -0
  60. data/spec/structs_spec.rb +95 -0
  61. data/spec/support/http_stubbing_adapter.rb +113 -0
  62. data/spec/task_runner_spec.rb +59 -0
  63. data/spec/vcr_spec.rb +37 -0
  64. data/vcr.gemspec +45 -15
  65. metadata +67 -26
  66. data/History.rdoc +0 -31
  67. data/README.rdoc +0 -222
  68. data/lib/vcr/recorded_response.rb +0 -4
  69. data/spec/extensions/fake_web_spec.rb +0 -63
  70. data/spec/recorded_response_spec.rb +0 -25
@@ -1,45 +1,47 @@
1
1
  ---
2
- - !ruby/struct:VCR::RecordedResponse
3
- method: :get
4
- uri: http://example.com:80/before_nested
5
- response: !ruby/object:Net::HTTPNotFound
6
- body: The before_nested response
7
- body_exist: true
8
- code: "404"
9
- header:
10
- content-type:
11
- - text/html; charset=iso-8859-1
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: 404
11
+ message: Not Found
12
+ headers:
12
13
  connection:
13
14
  - close
14
- server:
15
- - Apache/2.2.3 (CentOS)
15
+ content-type:
16
+ - text/html; charset=iso-8859-1
16
17
  date:
17
18
  - Thu, 25 Feb 2010 15:23:39 GMT
19
+ server:
20
+ - Apache/2.2.3 (CentOS)
18
21
  content-length:
19
22
  - "287"
23
+ body: The before_nested response
20
24
  http_version: "1.1"
21
- message: Not Found
22
- read: true
23
- socket:
24
- - !ruby/struct:VCR::RecordedResponse
25
- method: :get
26
- uri: http://example.com:80/after_nested
27
- response: !ruby/object:Net::HTTPNotFound
28
- body: The after_nested response
29
- body_exist: true
30
- code: "404"
31
- header:
32
- content-type:
33
- - text/html; charset=iso-8859-1
25
+ - !ruby/struct:VCR::HTTPInteraction
26
+ request: !ruby/struct:VCR::Request
27
+ method: :get
28
+ uri: http://example.com:80/after_nested
29
+ body:
30
+ headers:
31
+ response: !ruby/struct:VCR::Response
32
+ status: !ruby/struct:VCR::ResponseStatus
33
+ code: 404
34
+ message: Not Found
35
+ headers:
34
36
  connection:
35
37
  - close
36
- server:
37
- - Apache/2.2.3 (CentOS)
38
+ content-type:
39
+ - text/html; charset=iso-8859-1
38
40
  date:
39
41
  - Thu, 25 Feb 2010 15:23:39 GMT
42
+ server:
43
+ - Apache/2.2.3 (CentOS)
40
44
  content-length:
41
45
  - "286"
46
+ body: The after_nested response
42
47
  http_version: "1.1"
43
- message: Not Found
44
- read: true
45
- socket:
@@ -1,30 +1,21 @@
1
1
  ---
2
- - !ruby/struct:VCR::RecordedResponse
3
- method: :get
4
- uri: http://example.com:80/
5
- response: !ruby/object:Net::HTTPOK
6
- body: |
7
- <HTML>
8
- <HEAD>
9
- <TITLE>Example Web Page</TITLE>
10
- </HEAD>
11
- <body>
12
- <p>
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:
22
- etag:
23
- - "\"24ec5-1b6-4059a80bfd280\""
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:
24
13
  last-modified:
25
14
  - Tue, 15 Nov 2005 13:24:10 GMT
26
15
  connection:
27
16
  - Keep-Alive
17
+ etag:
18
+ - "\"24ec5-1b6-4059a80bfd280\""
28
19
  content-type:
29
20
  - text/html; charset=UTF-8
30
21
  date:
@@ -37,14 +28,6 @@
37
28
  - "2643"
38
29
  accept-ranges:
39
30
  - bytes
40
- http_version: "1.1"
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
31
  body: |
49
32
  <HTML>
50
33
  <HEAD>
@@ -52,21 +35,29 @@
52
35
  </HEAD>
53
36
  <body>
54
37
  <p>
55
- This is another fake response from example.com
38
+ This is not the real response from example.com
56
39
  </p>
57
40
  </BODY>
58
41
  </HTML>
59
-
60
42
 
61
- body_exist: true
62
- code: "200"
63
- header:
64
- etag:
65
- - "\"24ec5-1b6-4059a80bfd280\""
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:
66
55
  last-modified:
67
56
  - Tue, 15 Nov 2005 13:24:10 GMT
68
57
  connection:
69
58
  - Keep-Alive
59
+ etag:
60
+ - "\"24ec5-1b6-4059a80bfd280\""
70
61
  content-type:
71
62
  - text/html; charset=UTF-8
72
63
  date:
@@ -79,7 +70,16 @@
79
70
  - "2643"
80
71
  accept-ranges:
81
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
+
82
85
  http_version: "1.1"
83
- message: OK
84
- read: true
85
- socket:
@@ -1,23 +1,24 @@
1
1
  ---
2
- - !ruby/struct:VCR::RecordedResponse
3
- method: :get
4
- uri: http://example.com:80/nested
5
- response: !ruby/object:Net::HTTPNotFound
6
- body: The nested response
7
- body_exist: true
8
- code: "404"
9
- header:
10
- content-type:
11
- - text/html; charset=iso-8859-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:
12
13
  connection:
13
14
  - close
14
- server:
15
- - Apache/2.2.3 (CentOS)
15
+ content-type:
16
+ - text/html; charset=iso-8859-1
16
17
  date:
17
18
  - Thu, 25 Feb 2010 15:19:40 GMT
19
+ server:
20
+ - Apache/2.2.3 (CentOS)
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,30 +1,21 @@
1
1
  ---
2
- - !ruby/struct:VCR::RecordedResponse
3
- method: :get
4
- uri: http://example.com:80/
5
- response: !ruby/object:Net::HTTPOK
6
- body: |
7
- <HTML>
8
- <HEAD>
9
- <TITLE>Example Web Page</TITLE>
10
- </HEAD>
11
- <body>
12
- <p>
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:
22
- etag:
23
- - "\"24ec5-1b6-4059a80bfd280\""
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:
24
13
  last-modified:
25
14
  - Tue, 15 Nov 2005 13:24:10 GMT
26
15
  connection:
27
16
  - Keep-Alive
17
+ etag:
18
+ - "\"24ec5-1b6-4059a80bfd280\""
28
19
  content-type:
29
20
  - text/html; charset=UTF-8
30
21
  date:
@@ -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::RecordedResponse
3
- method: :get
4
- uri: http://example.com:80/
5
- response: !ruby/object:Net::HTTPOK
6
- body: |
7
- <HTML>
8
- <HEAD>
9
- <TITLE>Example Web Page</TITLE>
10
- </HEAD>
11
- <body>
12
- <p>
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
  - "2643"
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,12 +1,15 @@
1
1
  ---
2
- - !ruby/struct:VCR::RecordedResponse
3
- method: :get
4
- uri: http://example.com:80/before_nested
5
- response: !ruby/object:Net::HTTPNotFound
6
- body: The before_nested response
7
- body_exist: true
8
- code: "404"
9
- header:
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: 404
11
+ message: Not Found
12
+ headers:
10
13
  content-type:
11
14
  - text/html; charset=iso-8859-1
12
15
  connection:
@@ -17,18 +20,19 @@
17
20
  - Thu, 25 Feb 2010 15:23:39 GMT
18
21
  content-length:
19
22
  - "287"
23
+ body: The before_nested response
20
24
  http_version: "1.1"
21
- message: Not Found
22
- read: true
23
- socket:
24
- - !ruby/struct:VCR::RecordedResponse
25
- method: :get
26
- uri: http://example.com:80/after_nested
27
- response: !ruby/object:Net::HTTPNotFound
28
- body: The after_nested response
29
- body_exist: true
30
- code: "404"
31
- header:
25
+ - !ruby/struct:VCR::HTTPInteraction
26
+ request: !ruby/struct:VCR::Request
27
+ method: :get
28
+ uri: http://example.com:80/after_nested
29
+ body:
30
+ headers:
31
+ response: !ruby/struct:VCR::Response
32
+ status: !ruby/struct:VCR::ResponseStatus
33
+ code: 404
34
+ message: Not Found
35
+ headers:
32
36
  content-type:
33
37
  - text/html; charset=iso-8859-1
34
38
  connection:
@@ -39,7 +43,5 @@
39
43
  - Thu, 25 Feb 2010 15:23:39 GMT
40
44
  content-length:
41
45
  - "286"
46
+ body: The after_nested response
42
47
  http_version: "1.1"
43
- message: Not Found
44
- read: true
45
- socket:
@@ -1,24 +1,15 @@
1
1
  ---
2
- - !ruby/struct:VCR::RecordedResponse
3
- method: :get
4
- uri: http://example.com:80/
5
- response: !ruby/object:Net::HTTPOK
6
- body: |
7
- <HTML>
8
- <HEAD>
9
- <TITLE>Example Web Page</TITLE>
10
- </HEAD>
11
- <body>
12
- <p>
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,14 +28,6 @@
37
28
  - "2643"
38
29
  accept-ranges:
39
30
  - bytes
40
- http_version: "1.1"
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
31
  body: |
49
32
  <HTML>
50
33
  <HEAD>
@@ -52,15 +35,23 @@
52
35
  </HEAD>
53
36
  <body>
54
37
  <p>
55
- This is another fake response from example.com
38
+ This is not the real response from example.com
56
39
  </p>
57
40
  </BODY>
58
41
  </HTML>
59
-
60
42
 
61
- body_exist: true
62
- code: "200"
63
- header:
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
  etag:
65
56
  - "\"24ec5-1b6-4059a80bfd280\""
66
57
  last-modified:
@@ -79,7 +70,16 @@
79
70
  - "2643"
80
71
  accept-ranges:
81
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
+
82
85
  http_version: "1.1"
83
- message: OK
84
- read: true
85
- socket: