vcr 0.4.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. data/CHANGELOG.md +34 -0
  2. data/README.md +89 -21
  3. data/lib/vcr.rb +12 -1
  4. data/lib/vcr/cassette.rb +50 -27
  5. data/lib/vcr/config.rb +9 -0
  6. data/lib/vcr/deprecations.rb +15 -42
  7. data/lib/vcr/extensions/net_http.rb +13 -20
  8. data/lib/vcr/extensions/net_http_response.rb +6 -13
  9. data/lib/vcr/http_stubbing_adapters/fakeweb.rb +21 -3
  10. data/lib/vcr/http_stubbing_adapters/webmock.rb +34 -4
  11. data/lib/vcr/version.rb +16 -0
  12. metadata +90 -108
  13. data/.document +0 -5
  14. data/.gitignore +0 -22
  15. data/Rakefile +0 -67
  16. data/VERSION +0 -1
  17. data/benchmarks/http_stubbing_libraries.rb +0 -59
  18. data/features/fixtures/vcr_cassettes/1.8.6/cucumber_tags/replay_cassette1.yml +0 -43
  19. data/features/fixtures/vcr_cassettes/1.8.6/cucumber_tags/replay_cassette2.yml +0 -47
  20. data/features/fixtures/vcr_cassettes/1.8.6/cucumber_tags/replay_cassette3.yml +0 -85
  21. data/features/fixtures/vcr_cassettes/1.8.6/nested_replay_cassette.yml +0 -24
  22. data/features/fixtures/vcr_cassettes/1.8.6/not_the_real_response.yml +0 -43
  23. data/features/fixtures/vcr_cassettes/1.8.7/cucumber_tags/replay_cassette1.yml +0 -43
  24. data/features/fixtures/vcr_cassettes/1.8.7/cucumber_tags/replay_cassette2.yml +0 -47
  25. data/features/fixtures/vcr_cassettes/1.8.7/cucumber_tags/replay_cassette3.yml +0 -85
  26. data/features/fixtures/vcr_cassettes/1.8.7/nested_replay_cassette.yml +0 -24
  27. data/features/fixtures/vcr_cassettes/1.8.7/not_the_real_response.yml +0 -43
  28. data/features/fixtures/vcr_cassettes/1.9.1/cucumber_tags/replay_cassette1.yml +0 -43
  29. data/features/fixtures/vcr_cassettes/1.9.1/cucumber_tags/replay_cassette2.yml +0 -63
  30. data/features/fixtures/vcr_cassettes/1.9.1/cucumber_tags/replay_cassette3.yml +0 -85
  31. data/features/fixtures/vcr_cassettes/1.9.1/nested_replay_cassette.yml +0 -32
  32. data/features/fixtures/vcr_cassettes/1.9.1/not_the_real_response.yml +0 -43
  33. data/features/record_response.feature +0 -77
  34. data/features/replay_recorded_response.feature +0 -69
  35. data/features/step_definitions/vcr_steps.rb +0 -144
  36. data/features/support/env.rb +0 -64
  37. data/lib/vcr/extensions/fake_web.rb +0 -20
  38. data/lib/vcr/extensions/net_read_adapter.rb +0 -22
  39. data/spec/cassette_spec.rb +0 -213
  40. data/spec/config_spec.rb +0 -49
  41. data/spec/cucumber_tags_spec.rb +0 -71
  42. data/spec/deprecations_spec.rb +0 -67
  43. data/spec/extensions/net_http_response_spec.rb +0 -86
  44. data/spec/extensions/net_http_spec.rb +0 -72
  45. data/spec/extensions/net_read_adapter_spec.rb +0 -10
  46. data/spec/fixtures/1.8.6/0_3_1_cassette.yml +0 -29
  47. data/spec/fixtures/1.8.6/cassette_spec/example.yml +0 -110
  48. data/spec/fixtures/1.8.6/example_net_http.yml +0 -14
  49. data/spec/fixtures/1.8.6/example_net_http_request.yml +0 -12
  50. data/spec/fixtures/1.8.6/example_net_http_response.yml +0 -25
  51. data/spec/fixtures/1.8.6/fake_example.com_responses.yml +0 -90
  52. data/spec/fixtures/1.8.7/0_3_1_cassette.yml +0 -29
  53. data/spec/fixtures/1.8.7/cassette_spec/example.yml +0 -110
  54. data/spec/fixtures/1.8.7/example_net_http.yml +0 -14
  55. data/spec/fixtures/1.8.7/example_net_http_request.yml +0 -12
  56. data/spec/fixtures/1.8.7/example_net_http_response.yml +0 -25
  57. data/spec/fixtures/1.8.7/fake_example.com_responses.yml +0 -90
  58. data/spec/fixtures/1.9.1/0_3_1_cassette.yml +0 -29
  59. data/spec/fixtures/1.9.1/cassette_spec/example.yml +0 -110
  60. data/spec/fixtures/1.9.1/example_net_http.yml +0 -14
  61. data/spec/fixtures/1.9.1/example_net_http_request.yml +0 -12
  62. data/spec/fixtures/1.9.1/example_net_http_response.yml +0 -25
  63. data/spec/fixtures/1.9.1/fake_example.com_responses.yml +0 -90
  64. data/spec/http_stubbing_adapters/fakeweb_spec.rb +0 -24
  65. data/spec/http_stubbing_adapters/webmock_spec.rb +0 -23
  66. data/spec/spec.opts +0 -2
  67. data/spec/spec_helper.rb +0 -35
  68. data/spec/structs_spec.rb +0 -95
  69. data/spec/support/deprecated.rb +0 -18
  70. data/spec/support/disable_warnings.rb +0 -12
  71. data/spec/support/http_stubbing_adapter.rb +0 -113
  72. data/spec/support/temp_cassette_library_dir.rb +0 -16
  73. data/spec/task_runner_spec.rb +0 -59
  74. data/spec/vcr_spec.rb +0 -119
  75. data/vcr.gemspec +0 -147
data/.document DELETED
@@ -1,5 +0,0 @@
1
- README.rdoc
2
- lib/**/*.rb
3
- bin/*
4
- features/**/*.feature
5
- LICENSE
data/.gitignore DELETED
@@ -1,22 +0,0 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## PROJECT::GENERAL
17
- coverage
18
- rdoc
19
- pkg
20
-
21
- ## PROJECT::SPECIFIC
22
- features/fixtures/vcr_cassettes/**/temp/
data/Rakefile DELETED
@@ -1,67 +0,0 @@
1
- require 'rubygems'
2
- require 'rake'
3
-
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "vcr"
8
- gem.summary = %Q{Record your test suite's HTTP interactions and replay them during future test runs for fast, deterministic, accurate tests.}
9
- gem.description = %Q{VCR provides helpers to record your test suite's HTTP interactions and replay them during future test runs for fast, deterministic, accurate tests. It works with any ruby testing framework, and provides built-in support for cucumber.}
10
- gem.email = "myron.marston@gmail.com"
11
- gem.homepage = "http://github.com/myronmarston/vcr"
12
- gem.authors = ["Myron Marston"]
13
-
14
- gem.add_development_dependency "rspec", ">= 1.2.9"
15
- gem.add_development_dependency "cucumber", ">= 0.6.1"
16
- gem.add_development_dependency "fakeweb", ">= 1.2.8"
17
- gem.add_development_dependency "webmock", ">= 1.1.0"
18
-
19
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
20
- end
21
- Jeweler::GemcutterTasks.new
22
- rescue LoadError
23
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
24
- end
25
-
26
- require 'spec/rake/spectask'
27
- Spec::Rake::SpecTask.new(:spec) do |spec|
28
- spec.libs << 'lib' << 'spec'
29
- spec.spec_files = FileList['spec/**/*_spec.rb']
30
- end
31
-
32
- Spec::Rake::SpecTask.new(:rcov) do |spec|
33
- spec.libs << 'lib' << 'spec'
34
- spec.pattern = 'spec/**/*_spec.rb'
35
- spec.rcov = true
36
- end
37
-
38
- task :spec => :check_dependencies if defined?(Jeweler)
39
-
40
- begin
41
- require 'cucumber/rake/task'
42
- Cucumber::Rake::Task.new(:features)
43
-
44
- task :features => :check_dependencies
45
- rescue LoadError
46
- task :features do
47
- abort "Cucumber is not available. In order to run features, you must: sudo gem install cucumber"
48
- end
49
- end
50
-
51
- task :default => :spec do
52
- %w( webmock fakeweb ).each do |http_stubbing_adapter|
53
- puts "\n\n-------------- Running features using #{http_stubbing_adapter} http_stubbing_adapter -----------------\n"
54
- ENV['HTTP_STUBBING_ADAPTER'] = http_stubbing_adapter
55
- Rake::Task[:features].execute
56
- end
57
- end
58
-
59
- require 'rake/rdoctask'
60
- Rake::RDocTask.new do |rdoc|
61
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
62
-
63
- rdoc.rdoc_dir = 'rdoc'
64
- rdoc.title = "vcr #{version}"
65
- rdoc.rdoc_files.include('README*')
66
- rdoc.rdoc_files.include('lib/**/*.rb')
67
- end
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.4.1
@@ -1,59 +0,0 @@
1
- require 'rubygems'
2
- require 'benchmark'
3
- require 'net/http'
4
-
5
- def http_request
6
- res = Net::HTTP.get_response(URI.parse('http://example.com'))
7
- raise "Body should be 'Hello'" unless res.body == 'Hello'
8
- end
9
-
10
- def fakeweb
11
- FakeWeb.register_uri(:get, 'http://example.com', :body => 'Hello')
12
- yield
13
- ensure
14
- FakeWeb.clean_registry
15
- end
16
-
17
- def webmock
18
- WebMock.stub_request(:get, 'http://example.com').to_return(:body => 'Hello')
19
- yield
20
- ensure
21
- WebMock.reset_webmock
22
- end
23
-
24
- def perform_benchmark(name)
25
- puts "\n\nBenchmarking #{name}:"
26
- Benchmark.benchmark do |b|
27
- %w(webmock fakeweb).each do |type|
28
- b.report(type) do
29
- # this is a bit convoluted, but we want to ensure that each benchmark runs without the other library loaded,
30
- # so we fork off a sub-process before requiring the libraries.
31
- Process.fork do
32
- require type
33
- yield type
34
- end
35
- Process.wait
36
- end
37
- end
38
- end
39
- end
40
-
41
- n = 5000
42
- perform_benchmark("Single setup/teardown") do |type|
43
- send(type) { n.times { http_request } }
44
- end
45
-
46
- perform_benchmark("Setup/teardown for each http request") do |type|
47
- n.times { send(type) { http_request } }
48
- end
49
-
50
- # Output on my machine:
51
- #
52
- # Benchmarking Single setup/teardown:
53
- # webmock 0.000000 0.000000 18.830000 ( 19.350281)
54
- # fakeweb 0.000000 0.000000 1.930000 ( 2.049569)
55
- #
56
- #
57
- # Benchmarking Setup/teardown for each http request:
58
- # webmock 0.000000 0.000000 21.350000 ( 21.795557)
59
- # fakeweb 0.000000 0.000000 2.490000 ( 2.707574)
@@ -1,43 +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
- 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"
@@ -1,47 +0,0 @@
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:
13
- connection:
14
- - close
15
- content-type:
16
- - text/html; charset=iso-8859-1
17
- date:
18
- - Thu, 25 Feb 2010 15:23:39 GMT
19
- server:
20
- - Apache/2.2.3 (CentOS)
21
- content-length:
22
- - "287"
23
- body: The before_nested response
24
- http_version: "1.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:
36
- connection:
37
- - close
38
- content-type:
39
- - text/html; charset=iso-8859-1
40
- date:
41
- - Thu, 25 Feb 2010 15:23:39 GMT
42
- server:
43
- - Apache/2.2.3 (CentOS)
44
- content-length:
45
- - "286"
46
- body: The after_nested response
47
- http_version: "1.1"
@@ -1,85 +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
- 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"
@@ -1,24 +0,0 @@
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"
@@ -1,43 +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
- 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"
@@ -1,43 +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
- 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: |
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"