vcr 0.2.0 → 0.3.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/History.rdoc +11 -0
- data/LICENSE +1 -1
- data/README.rdoc +34 -35
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/features/record_response.feature +22 -22
- data/features/replay_recorded_response.feature +22 -16
- data/features/step_definitions/vcr_steps.rb +54 -33
- data/features/support/env.rb +8 -8
- data/lib/vcr.rb +7 -6
- data/lib/vcr/cassette.rb +11 -12
- data/lib/vcr/config.rb +4 -9
- data/lib/vcr/cucumber_tags.rb +2 -2
- data/lib/vcr/deprecations.rb +54 -0
- data/spec/cassette_spec.rb +37 -37
- data/spec/config_spec.rb +3 -28
- data/spec/cucumber_tags_spec.rb +7 -7
- data/spec/deprecations_spec.rb +67 -0
- data/spec/spec_helper.rb +3 -2
- data/spec/support/deprecated.rb +18 -0
- data/spec/support/{temp_cache_dir.rb → temp_cassette_library_dir.rb} +3 -3
- data/spec/vcr_spec.rb +27 -31
- data/vcr.gemspec +10 -5
- metadata +11 -6
data/spec/cucumber_tags_spec.rb
CHANGED
@@ -24,9 +24,9 @@ describe VCR::CucumberTags do
|
|
24
24
|
@args[hook].should == [['@tag_test']]
|
25
25
|
|
26
26
|
if hook == :before
|
27
|
-
VCR.should_receive(:
|
27
|
+
VCR.should_receive(:insert_cassette).with('cucumber_tags/tag_test', {})
|
28
28
|
else
|
29
|
-
VCR.should_receive(:
|
29
|
+
VCR.should_receive(:eject_cassette)
|
30
30
|
end
|
31
31
|
@blocks[hook].should have(1).block
|
32
32
|
@blocks[hook].first.call
|
@@ -37,10 +37,10 @@ describe VCR::CucumberTags do
|
|
37
37
|
@args[hook].should == [['@tag_test1'], ['@tag_test2']]
|
38
38
|
|
39
39
|
if hook == :before
|
40
|
-
VCR.should_receive(:
|
41
|
-
VCR.should_receive(:
|
40
|
+
VCR.should_receive(:insert_cassette).with('cucumber_tags/tag_test1', { :record => :none }).once
|
41
|
+
VCR.should_receive(:insert_cassette).with('cucumber_tags/tag_test2', { :record => :none }).once
|
42
42
|
else
|
43
|
-
VCR.should_receive(:
|
43
|
+
VCR.should_receive(:eject_cassette).twice
|
44
44
|
end
|
45
45
|
@blocks[hook].should have(2).blocks
|
46
46
|
@blocks[hook].each { |b| b.call }
|
@@ -51,9 +51,9 @@ describe VCR::CucumberTags do
|
|
51
51
|
@args[hook].should == [['@tag_test']]
|
52
52
|
|
53
53
|
if hook == :before
|
54
|
-
VCR.should_receive(:
|
54
|
+
VCR.should_receive(:insert_cassette).with('cucumber_tags/tag_test', {})
|
55
55
|
else
|
56
|
-
VCR.should_receive(:
|
56
|
+
VCR.should_receive(:eject_cassette)
|
57
57
|
end
|
58
58
|
@blocks[hook].should have(1).block
|
59
59
|
@blocks[hook].first.call
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Deprecations' do
|
4
|
+
describe VCR do
|
5
|
+
subject { VCR }
|
6
|
+
deprecated :create_cassette!, :insert_cassette, "WARNING: VCR.create_cassette! is deprecated. Instead, use: VCR.insert_cassette."
|
7
|
+
deprecated :destroy_cassette!, :eject_cassette, "WARNING: VCR.destroy_cassette! is deprecated. Instead, use: VCR.eject_cassette."
|
8
|
+
deprecated :with_cassette, :use_cassette, "WARNING: VCR.with_cassette is deprecated. Instead, use: VCR.use_cassette."
|
9
|
+
end
|
10
|
+
|
11
|
+
describe VCR::Cassette do
|
12
|
+
disable_warnings
|
13
|
+
subject { VCR::Cassette.new('cassette name') }
|
14
|
+
deprecated :destroy!, :eject, "WARNING: VCR::Cassette#destroy! is deprecated. Instead, use: VCR::Cassette#eject."
|
15
|
+
deprecated :cache_file, :file, "WARNING: VCR::Cassette#cache_file is deprecated. Instead, use: VCR::Cassette#file."
|
16
|
+
|
17
|
+
it 'delegates the :unregistered record option to :new_episodes' do
|
18
|
+
cassette = VCR::Cassette.new('cassette name', :record => :unregistered)
|
19
|
+
cassette.record_mode.should == :new_episodes
|
20
|
+
end
|
21
|
+
|
22
|
+
it "prints a warning: WARNING: VCR's :unregistered record mode is deprecated. Instead, use: :new_episodes." do
|
23
|
+
Kernel.should_receive(:warn).with("WARNING: VCR's :unregistered record mode is deprecated. Instead, use: :new_episodes.")
|
24
|
+
VCR::Cassette.new('cassette name', :record => :unregistered)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe VCR::Config do
|
29
|
+
disable_warnings
|
30
|
+
subject { VCR::Config }
|
31
|
+
deprecated :cache_dir, :cassette_library_dir, "WARNING: VCR::Config.cache_dir is deprecated. Instead, use: VCR::Config.cassette_library_dir."
|
32
|
+
|
33
|
+
it 'delegates #cache_dir= to #cassette_library_dir=' do
|
34
|
+
subject.should_receive(:cassette_library_dir=).with(:value)
|
35
|
+
subject.cache_dir = :value
|
36
|
+
end
|
37
|
+
|
38
|
+
it "prints a warning: WARNING: VCR::Config.cache_dir= is deprecated. Instead, use: VCR::Config.cassette_library_dir=." do
|
39
|
+
subject.stub!(:cassette_library_dir=)
|
40
|
+
subject.should_receive(:warn).with("WARNING: VCR::Config.cache_dir= is deprecated. Instead, use: VCR::Config.cassette_library_dir=.")
|
41
|
+
subject.cache_dir = :value
|
42
|
+
end
|
43
|
+
|
44
|
+
describe '#default_cassette_record_mode=' do
|
45
|
+
it 'sets the default_cassette_options[:record] option' do
|
46
|
+
VCR::Cassette::VALID_RECORD_MODES.each do |mode|
|
47
|
+
VCR::Config.default_cassette_options = nil
|
48
|
+
VCR::Config.default_cassette_record_mode = mode
|
49
|
+
VCR::Config.default_cassette_options[:record].should == mode
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'merges the :record option with the existing default_cassette_record options' do
|
54
|
+
VCR::Config.default_cassette_options = { :an => :option }
|
55
|
+
VCR::Config.default_cassette_record_mode = :all
|
56
|
+
VCR::Config.default_cassette_options.should == { :an => :option, :record => :all }
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'warns the user that it is deprecated' do
|
60
|
+
VCR::Cassette::VALID_RECORD_MODES.each do |mode|
|
61
|
+
VCR::Config.should_receive(:warn).with(%Q{WARNING: #default_cassette_record_mode is deprecated. Instead, use: "default_cassette_options = { :record => :#{mode.to_s} }"})
|
62
|
+
VCR::Config.default_cassette_record_mode = mode
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -18,11 +18,12 @@ end
|
|
18
18
|
Dir[File.expand_path(File.join(File.dirname(__FILE__),'support','**','*.rb'))].each {|f| require f}
|
19
19
|
|
20
20
|
Spec::Runner.configure do |config|
|
21
|
-
config.extend
|
21
|
+
config.extend TempCassetteLibraryDir
|
22
22
|
config.extend DisableWarnings
|
23
|
+
config.extend Deprecated
|
23
24
|
|
24
25
|
config.before(:each) do
|
25
|
-
VCR::Config.default_cassette_options = { :record => :
|
26
|
+
VCR::Config.default_cassette_options = { :record => :new_episodes }
|
26
27
|
FakeWeb.allow_net_connect = true
|
27
28
|
FakeWeb.clean_registry
|
28
29
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Deprecated
|
2
|
+
def deprecated(old_method, new_method, message)
|
3
|
+
describe "##{old_method}" do
|
4
|
+
disable_warnings
|
5
|
+
|
6
|
+
it "delegates to ##{new_method}" do
|
7
|
+
subject.should_receive(new_method).with(:arg1, :arg2).and_return(:return_value)
|
8
|
+
subject.send(old_method, :arg1, :arg2).should == :return_value
|
9
|
+
end
|
10
|
+
|
11
|
+
it "prints a warning: #{message}" do
|
12
|
+
subject.stub!(new_method)
|
13
|
+
subject.should_receive(:warn).with(message)
|
14
|
+
subject.send(old_method)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -1,11 +1,11 @@
|
|
1
|
-
module
|
1
|
+
module TempCassetteLibraryDir
|
2
2
|
def temp_dir(dir, options = {})
|
3
3
|
before(:each) do
|
4
4
|
@temp_dir = dir
|
5
5
|
@dir_remover = lambda { FileUtils.rm_rf(@temp_dir) if File.exist?(@temp_dir) }
|
6
6
|
@dir_remover.call
|
7
|
-
if options[:
|
8
|
-
VCR::Config.
|
7
|
+
if options[:assign_to_cassette_library_dir]
|
8
|
+
VCR::Config.cassette_library_dir = @temp_dir
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
data/spec/vcr_spec.rb
CHANGED
@@ -1,66 +1,62 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
2
|
|
3
3
|
describe VCR do
|
4
|
-
def
|
5
|
-
VCR.
|
4
|
+
def insert_cassette
|
5
|
+
VCR.insert_cassette(:cassette_test)
|
6
6
|
end
|
7
7
|
|
8
|
-
describe '
|
8
|
+
describe 'insert_cassette' do
|
9
9
|
it 'creates a new cassette' do
|
10
|
-
|
10
|
+
insert_cassette.should be_instance_of(VCR::Cassette)
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'takes over as the #current_cassette' do
|
14
14
|
orig_cassette = VCR.current_cassette
|
15
|
-
new_cassette =
|
15
|
+
new_cassette = insert_cassette
|
16
16
|
new_cassette.should_not == orig_cassette
|
17
17
|
VCR.current_cassette.should == new_cassette
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
describe '
|
22
|
-
|
23
|
-
|
21
|
+
describe 'eject_cassette' do
|
22
|
+
it 'ejects the current cassette' do
|
23
|
+
cassette = insert_cassette
|
24
|
+
cassette.should_receive(:eject)
|
25
|
+
VCR.eject_cassette
|
24
26
|
end
|
25
27
|
|
26
|
-
it '
|
27
|
-
cassette =
|
28
|
-
cassette
|
29
|
-
VCR.destroy_cassette!
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'returns the destroyed cassette' do
|
33
|
-
cassette = create_cassette
|
34
|
-
VCR.destroy_cassette!.should == cassette
|
28
|
+
it 'returns the ejected cassette' do
|
29
|
+
cassette = insert_cassette
|
30
|
+
VCR.eject_cassette.should == cassette
|
35
31
|
end
|
36
32
|
|
37
33
|
it 'returns the #current_cassette to the previous one' do
|
38
|
-
cassette1, cassette2 =
|
39
|
-
lambda { VCR.
|
34
|
+
cassette1, cassette2 = insert_cassette, insert_cassette
|
35
|
+
lambda { VCR.eject_cassette }.should change(VCR, :current_cassette).from(cassette2).to(cassette1)
|
40
36
|
end
|
41
37
|
end
|
42
38
|
|
43
|
-
describe '
|
44
|
-
it '
|
45
|
-
new_cassette = VCR::Cassette.new(:
|
46
|
-
VCR.should_receive(:
|
47
|
-
VCR.
|
39
|
+
describe 'use_cassette' do
|
40
|
+
it 'inserts a new cassette' do
|
41
|
+
new_cassette = VCR::Cassette.new(:use_cassette_test)
|
42
|
+
VCR.should_receive(:insert_cassette).and_return(new_cassette)
|
43
|
+
VCR.use_cassette(:cassette_test) { }
|
48
44
|
end
|
49
45
|
|
50
46
|
it 'yields' do
|
51
47
|
yielded = false
|
52
|
-
VCR.
|
48
|
+
VCR.use_cassette(:cassette_test) { yielded = true }
|
53
49
|
yielded.should be_true
|
54
50
|
end
|
55
51
|
|
56
|
-
it '
|
57
|
-
VCR.should_receive(:
|
58
|
-
VCR.
|
52
|
+
it 'ejects the cassette' do
|
53
|
+
VCR.should_receive(:eject_cassette)
|
54
|
+
VCR.use_cassette(:cassette_test) { }
|
59
55
|
end
|
60
56
|
|
61
|
-
it '
|
62
|
-
VCR.should_receive(:
|
63
|
-
lambda { VCR.
|
57
|
+
it 'ejects the cassette even if there is an error' do
|
58
|
+
VCR.should_receive(:eject_cassette)
|
59
|
+
lambda { VCR.use_cassette(:cassette_test) { raise StandardError } }.should raise_error
|
64
60
|
end
|
65
61
|
end
|
66
62
|
|
data/vcr.gemspec
CHANGED
@@ -5,12 +5,12 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{vcr}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.3.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Myron Marston"]
|
12
|
-
s.date = %q{2010-03-
|
13
|
-
s.description = %q{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
|
12
|
+
s.date = %q{2010-03-24}
|
13
|
+
s.description = %q{VCR provides helpers to record HTTP requests for URIs that are not registered with fakeweb, and replay them later. It works with any ruby testing framework, and provides built-in support for cucumber.}
|
14
14
|
s.email = %q{myron.marston@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE",
|
@@ -47,6 +47,7 @@ Gem::Specification.new do |s|
|
|
47
47
|
"lib/vcr/cassette.rb",
|
48
48
|
"lib/vcr/config.rb",
|
49
49
|
"lib/vcr/cucumber_tags.rb",
|
50
|
+
"lib/vcr/deprecations.rb",
|
50
51
|
"lib/vcr/extensions/fake_web.rb",
|
51
52
|
"lib/vcr/extensions/net_http.rb",
|
52
53
|
"lib/vcr/extensions/net_read_adapter.rb",
|
@@ -54,6 +55,7 @@ Gem::Specification.new do |s|
|
|
54
55
|
"spec/cassette_spec.rb",
|
55
56
|
"spec/config_spec.rb",
|
56
57
|
"spec/cucumber_tags_spec.rb",
|
58
|
+
"spec/deprecations_spec.rb",
|
57
59
|
"spec/extensions/fake_web_spec.rb",
|
58
60
|
"spec/extensions/net_http_spec.rb",
|
59
61
|
"spec/extensions/net_read_adapter_spec.rb",
|
@@ -63,8 +65,9 @@ Gem::Specification.new do |s|
|
|
63
65
|
"spec/recorded_response_spec.rb",
|
64
66
|
"spec/spec.opts",
|
65
67
|
"spec/spec_helper.rb",
|
68
|
+
"spec/support/deprecated.rb",
|
66
69
|
"spec/support/disable_warnings.rb",
|
67
|
-
"spec/support/
|
70
|
+
"spec/support/temp_cassette_library_dir.rb",
|
68
71
|
"spec/vcr_spec.rb",
|
69
72
|
"vcr.gemspec"
|
70
73
|
]
|
@@ -77,13 +80,15 @@ Gem::Specification.new do |s|
|
|
77
80
|
"spec/cassette_spec.rb",
|
78
81
|
"spec/config_spec.rb",
|
79
82
|
"spec/cucumber_tags_spec.rb",
|
83
|
+
"spec/deprecations_spec.rb",
|
80
84
|
"spec/extensions/fake_web_spec.rb",
|
81
85
|
"spec/extensions/net_http_spec.rb",
|
82
86
|
"spec/extensions/net_read_adapter_spec.rb",
|
83
87
|
"spec/recorded_response_spec.rb",
|
84
88
|
"spec/spec_helper.rb",
|
89
|
+
"spec/support/deprecated.rb",
|
85
90
|
"spec/support/disable_warnings.rb",
|
86
|
-
"spec/support/
|
91
|
+
"spec/support/temp_cassette_library_dir.rb",
|
87
92
|
"spec/vcr_spec.rb"
|
88
93
|
]
|
89
94
|
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
7
|
+
- 3
|
8
8
|
- 0
|
9
|
-
version: 0.
|
9
|
+
version: 0.3.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Myron Marston
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-03-
|
17
|
+
date: 2010-03-24 00:00:00 -07:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -59,7 +59,7 @@ dependencies:
|
|
59
59
|
version: 0.6.1
|
60
60
|
type: :development
|
61
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
|
62
|
+
description: VCR provides helpers to record HTTP requests for URIs that are not registered with fakeweb, and replay them later. It works with any ruby testing framework, and provides built-in support for cucumber.
|
63
63
|
email: myron.marston@gmail.com
|
64
64
|
executables: []
|
65
65
|
|
@@ -99,6 +99,7 @@ files:
|
|
99
99
|
- lib/vcr/cassette.rb
|
100
100
|
- lib/vcr/config.rb
|
101
101
|
- lib/vcr/cucumber_tags.rb
|
102
|
+
- lib/vcr/deprecations.rb
|
102
103
|
- lib/vcr/extensions/fake_web.rb
|
103
104
|
- lib/vcr/extensions/net_http.rb
|
104
105
|
- lib/vcr/extensions/net_read_adapter.rb
|
@@ -106,6 +107,7 @@ files:
|
|
106
107
|
- spec/cassette_spec.rb
|
107
108
|
- spec/config_spec.rb
|
108
109
|
- spec/cucumber_tags_spec.rb
|
110
|
+
- spec/deprecations_spec.rb
|
109
111
|
- spec/extensions/fake_web_spec.rb
|
110
112
|
- spec/extensions/net_http_spec.rb
|
111
113
|
- spec/extensions/net_read_adapter_spec.rb
|
@@ -115,8 +117,9 @@ files:
|
|
115
117
|
- spec/recorded_response_spec.rb
|
116
118
|
- spec/spec.opts
|
117
119
|
- spec/spec_helper.rb
|
120
|
+
- spec/support/deprecated.rb
|
118
121
|
- spec/support/disable_warnings.rb
|
119
|
-
- spec/support/
|
122
|
+
- spec/support/temp_cassette_library_dir.rb
|
120
123
|
- spec/vcr_spec.rb
|
121
124
|
- vcr.gemspec
|
122
125
|
has_rdoc: true
|
@@ -153,11 +156,13 @@ test_files:
|
|
153
156
|
- spec/cassette_spec.rb
|
154
157
|
- spec/config_spec.rb
|
155
158
|
- spec/cucumber_tags_spec.rb
|
159
|
+
- spec/deprecations_spec.rb
|
156
160
|
- spec/extensions/fake_web_spec.rb
|
157
161
|
- spec/extensions/net_http_spec.rb
|
158
162
|
- spec/extensions/net_read_adapter_spec.rb
|
159
163
|
- spec/recorded_response_spec.rb
|
160
164
|
- spec/spec_helper.rb
|
165
|
+
- spec/support/deprecated.rb
|
161
166
|
- spec/support/disable_warnings.rb
|
162
|
-
- spec/support/
|
167
|
+
- spec/support/temp_cassette_library_dir.rb
|
163
168
|
- spec/vcr_spec.rb
|