vcr 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. data/.document +5 -0
  2. data/.gitignore +22 -0
  3. data/LICENSE +20 -0
  4. data/README.rdoc +156 -0
  5. data/Rakefile +60 -0
  6. data/VERSION +1 -0
  7. data/features/fixtures/vcr_cassettes/1.8.6/cucumber_tags/replay_cassette1.yml +43 -0
  8. data/features/fixtures/vcr_cassettes/1.8.6/cucumber_tags/replay_cassette2.yml +45 -0
  9. data/features/fixtures/vcr_cassettes/1.8.6/nested_replay_cassette.yml +23 -0
  10. data/features/fixtures/vcr_cassettes/1.8.6/not_the_real_response.yml +43 -0
  11. data/features/fixtures/vcr_cassettes/1.8.7/cucumber_tags/replay_cassette1.yml +43 -0
  12. data/features/fixtures/vcr_cassettes/1.8.7/cucumber_tags/replay_cassette2.yml +45 -0
  13. data/features/fixtures/vcr_cassettes/1.8.7/nested_replay_cassette.yml +23 -0
  14. data/features/fixtures/vcr_cassettes/1.8.7/not_the_real_response.yml +43 -0
  15. data/features/fixtures/vcr_cassettes/1.9.1/cucumber_tags/replay_cassette1.yml +43 -0
  16. data/features/fixtures/vcr_cassettes/1.9.1/cucumber_tags/replay_cassette2.yml +61 -0
  17. data/features/fixtures/vcr_cassettes/1.9.1/nested_replay_cassette.yml +31 -0
  18. data/features/fixtures/vcr_cassettes/1.9.1/not_the_real_response.yml +43 -0
  19. data/features/record_response.feature +55 -0
  20. data/features/replay_recorded_response.feature +53 -0
  21. data/features/step_definitions/vcr_steps.rb +88 -0
  22. data/features/support/env.rb +55 -0
  23. data/lib/vcr.rb +48 -0
  24. data/lib/vcr/cassette.rb +89 -0
  25. data/lib/vcr/config.rb +19 -0
  26. data/lib/vcr/cucumber_tags.rb +38 -0
  27. data/lib/vcr/fake_web_extensions.rb +18 -0
  28. data/lib/vcr/net_http_extensions.rb +39 -0
  29. data/lib/vcr/recorded_response.rb +4 -0
  30. data/spec/cassette_spec.rb +185 -0
  31. data/spec/config_spec.rb +27 -0
  32. data/spec/cucumber_tags_spec.rb +71 -0
  33. data/spec/fake_web_extensions_spec.rb +26 -0
  34. data/spec/fixtures/1.8.6/cassette_spec/example.yml +78 -0
  35. data/spec/fixtures/1.8.7/cassette_spec/example.yml +78 -0
  36. data/spec/fixtures/1.9.1/cassette_spec/example.yml +77 -0
  37. data/spec/net_http_extensions_spec.rb +40 -0
  38. data/spec/recorded_response_spec.rb +25 -0
  39. data/spec/spec.opts +2 -0
  40. data/spec/spec_helper.rb +22 -0
  41. data/spec/support/temp_cache_dir.rb +16 -0
  42. data/spec/vcr_spec.rb +95 -0
  43. metadata +154 -0
@@ -0,0 +1,16 @@
1
+ module TempCacheDir
2
+ def temp_dir(dir, options = {})
3
+ before(:each) do
4
+ @temp_dir = dir
5
+ @dir_remover = lambda { FileUtils.rm_rf(@temp_dir) if File.exist?(@temp_dir) }
6
+ @dir_remover.call
7
+ if options[:assign_to_cache_dir]
8
+ VCR::Config.cache_dir = @temp_dir
9
+ end
10
+ end
11
+
12
+ after(:each) do
13
+ @dir_remover.call
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,95 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe VCR do
4
+ before(:all) do
5
+ @orig_default_cassette_record_mode = VCR::Config.default_cassette_record_mode
6
+ VCR::Config.default_cassette_record_mode = :unregistered
7
+ end
8
+
9
+ after(:all) do
10
+ VCR::Config.default_cassette_record_mode = :unregistered
11
+ end
12
+
13
+ def create_cassette
14
+ VCR.create_cassette!(:cassette_test)
15
+ end
16
+
17
+ describe 'create_cassette!' do
18
+ it 'creates a new cassette' do
19
+ create_cassette.should be_instance_of(VCR::Cassette)
20
+ end
21
+
22
+ it 'takes over as the #current_cassette' do
23
+ orig_cassette = VCR.current_cassette
24
+ new_cassette = create_cassette
25
+ new_cassette.should_not == orig_cassette
26
+ VCR.current_cassette.should == new_cassette
27
+ end
28
+ end
29
+
30
+ describe 'destroy_cassette!' do
31
+ def destroy_cassette
32
+ VCR.destroy_cassette!
33
+ end
34
+
35
+ it 'destroys the current sandbo' do
36
+ cassette = create_cassette
37
+ cassette.should_receive(:destroy!)
38
+ VCR.destroy_cassette!
39
+ end
40
+
41
+ it 'returns the destroyed cassette' do
42
+ cassette = create_cassette
43
+ VCR.destroy_cassette!.should == cassette
44
+ end
45
+
46
+ it 'returns the #current_cassette to the previous one' do
47
+ cassette1, cassette2 = create_cassette, create_cassette
48
+ lambda { VCR.destroy_cassette! }.should change(VCR, :current_cassette).from(cassette2).to(cassette1)
49
+ end
50
+ end
51
+
52
+ describe 'with_cassette' do
53
+ it 'creates a new cassette' do
54
+ new_cassette = VCR::Cassette.new(:with_cassette_test)
55
+ VCR.should_receive(:create_cassette!).and_return(new_cassette)
56
+ VCR.with_cassette(:cassette_test) { }
57
+ end
58
+
59
+ it 'yields' do
60
+ yielded = false
61
+ VCR.with_cassette(:cassette_test) { yielded = true }
62
+ yielded.should be_true
63
+ end
64
+
65
+ it 'destroys the cassette' do
66
+ VCR.should_receive(:destroy_cassette!)
67
+ VCR.with_cassette(:cassette_test) { }
68
+ end
69
+
70
+ it 'destroys the cassette even if there is an error' do
71
+ VCR.should_receive(:destroy_cassette!)
72
+ lambda { VCR.with_cassette(:cassette_test) { raise StandardError } }.should raise_error
73
+ end
74
+ end
75
+
76
+ describe 'config' do
77
+ it 'yields the configuration object' do
78
+ yielded_object = nil
79
+ VCR.config do |obj|
80
+ yielded_object = obj
81
+ end
82
+ yielded_object.should == VCR::Config
83
+ end
84
+ end
85
+
86
+ describe 'cucumber_tags' do
87
+ it 'yields a cucumber tags object' do
88
+ yielded_object = nil
89
+ VCR.cucumber_tags do |obj|
90
+ yielded_object = obj
91
+ end
92
+ yielded_object.should be_instance_of(VCR::CucumberTags)
93
+ end
94
+ end
95
+ end
metadata ADDED
@@ -0,0 +1,154 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vcr
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
10
+ platform: ruby
11
+ authors:
12
+ - Myron Marston
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-02-25 00:00:00 -08:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: fakeweb
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 1
29
+ - 2
30
+ - 8
31
+ version: 1.2.8
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: rspec
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 1
43
+ - 2
44
+ - 9
45
+ version: 1.2.9
46
+ type: :development
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ name: cucumber
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ segments:
56
+ - 0
57
+ - 6
58
+ - 1
59
+ version: 0.6.1
60
+ type: :development
61
+ version_requirements: *id003
62
+ description: VCR provides helpers to record HTTP requests for URIs that are not registered with fakeweb, and replay them later. It provides built-in support for cucumber, but works with any ruby testing framework.
63
+ email: myron.marston@gmail.com
64
+ executables: []
65
+
66
+ extensions: []
67
+
68
+ extra_rdoc_files:
69
+ - LICENSE
70
+ - README.rdoc
71
+ files:
72
+ - .document
73
+ - .gitignore
74
+ - LICENSE
75
+ - README.rdoc
76
+ - Rakefile
77
+ - VERSION
78
+ - features/fixtures/vcr_cassettes/1.8.6/cucumber_tags/replay_cassette1.yml
79
+ - features/fixtures/vcr_cassettes/1.8.6/cucumber_tags/replay_cassette2.yml
80
+ - features/fixtures/vcr_cassettes/1.8.6/nested_replay_cassette.yml
81
+ - features/fixtures/vcr_cassettes/1.8.6/not_the_real_response.yml
82
+ - features/fixtures/vcr_cassettes/1.8.6/temp/not_the_real_response.yml
83
+ - features/fixtures/vcr_cassettes/1.8.7/cucumber_tags/replay_cassette1.yml
84
+ - features/fixtures/vcr_cassettes/1.8.7/cucumber_tags/replay_cassette2.yml
85
+ - features/fixtures/vcr_cassettes/1.8.7/nested_replay_cassette.yml
86
+ - features/fixtures/vcr_cassettes/1.8.7/not_the_real_response.yml
87
+ - features/fixtures/vcr_cassettes/1.9.1/cucumber_tags/replay_cassette1.yml
88
+ - features/fixtures/vcr_cassettes/1.9.1/cucumber_tags/replay_cassette2.yml
89
+ - features/fixtures/vcr_cassettes/1.9.1/nested_replay_cassette.yml
90
+ - features/fixtures/vcr_cassettes/1.9.1/not_the_real_response.yml
91
+ - features/record_response.feature
92
+ - features/replay_recorded_response.feature
93
+ - features/step_definitions/vcr_steps.rb
94
+ - features/support/env.rb
95
+ - lib/vcr.rb
96
+ - lib/vcr/cassette.rb
97
+ - lib/vcr/config.rb
98
+ - lib/vcr/cucumber_tags.rb
99
+ - lib/vcr/fake_web_extensions.rb
100
+ - lib/vcr/net_http_extensions.rb
101
+ - lib/vcr/recorded_response.rb
102
+ - spec/cassette_spec.rb
103
+ - spec/config_spec.rb
104
+ - spec/cucumber_tags_spec.rb
105
+ - spec/fake_web_extensions_spec.rb
106
+ - spec/fixtures/1.8.6/cassette_spec/example.yml
107
+ - spec/fixtures/1.8.7/cassette_spec/example.yml
108
+ - spec/fixtures/1.9.1/cassette_spec/example.yml
109
+ - spec/net_http_extensions_spec.rb
110
+ - spec/recorded_response_spec.rb
111
+ - spec/spec.opts
112
+ - spec/spec_helper.rb
113
+ - spec/support/temp_cache_dir.rb
114
+ - spec/vcr_spec.rb
115
+ has_rdoc: true
116
+ homepage: http://github.com/myronmarston/vcr
117
+ licenses: []
118
+
119
+ post_install_message:
120
+ rdoc_options:
121
+ - --charset=UTF-8
122
+ require_paths:
123
+ - lib
124
+ required_ruby_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ segments:
129
+ - 0
130
+ version: "0"
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ segments:
136
+ - 0
137
+ version: "0"
138
+ requirements: []
139
+
140
+ rubyforge_project:
141
+ rubygems_version: 1.3.6
142
+ signing_key:
143
+ specification_version: 3
144
+ summary: Use VCR to record HTTP responses and replay them using fakeweb.
145
+ test_files:
146
+ - spec/cassette_spec.rb
147
+ - spec/config_spec.rb
148
+ - spec/cucumber_tags_spec.rb
149
+ - spec/fake_web_extensions_spec.rb
150
+ - spec/net_http_extensions_spec.rb
151
+ - spec/recorded_response_spec.rb
152
+ - spec/spec_helper.rb
153
+ - spec/support/temp_cache_dir.rb
154
+ - spec/vcr_spec.rb