vcr 1.11.3 → 2.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (166) hide show
  1. data/.gitignore +2 -0
  2. data/.travis.yml +6 -2
  3. data/CHANGELOG.md +49 -1
  4. data/Gemfile +1 -5
  5. data/Guardfile +0 -5
  6. data/README.md +3 -2
  7. data/Rakefile +11 -16
  8. data/cucumber.yml +0 -4
  9. data/features/.nav +14 -2
  10. data/features/cassettes/automatic_re_recording.feature +4 -6
  11. data/features/cassettes/dynamic_erb.feature +6 -8
  12. data/features/cassettes/exclusive.feature +111 -0
  13. data/features/cassettes/format.feature +16 -14
  14. data/features/cassettes/naming.feature +4 -6
  15. data/features/cassettes/no_cassette.feature +25 -28
  16. data/features/cassettes/update_content_length_header.feature +9 -9
  17. data/features/configuration/allow_http_connections_when_no_cassette.feature +6 -8
  18. data/features/configuration/cassette_library_dir.feature +4 -6
  19. data/features/configuration/default_cassette_options.feature +12 -10
  20. data/features/configuration/filter_sensitive_data.feature +12 -17
  21. data/features/configuration/{stub_with.feature → hook_into.feature} +63 -62
  22. data/features/configuration/hooks.feature +23 -33
  23. data/features/configuration/ignore_hosts.feature +16 -17
  24. data/features/configuration/ignore_localhost.feature +33 -42
  25. data/features/http_libraries/em_http_request.feature +7 -8
  26. data/features/http_libraries/net_http.feature +26 -28
  27. data/features/middleware/faraday.feature +17 -56
  28. data/features/middleware/rack.feature +8 -11
  29. data/features/record_modes/all.feature +5 -7
  30. data/features/record_modes/new_episodes.feature +5 -7
  31. data/features/record_modes/none.feature +6 -6
  32. data/features/record_modes/once.feature +6 -8
  33. data/features/request_matching/README.md +28 -0
  34. data/features/request_matching/body.feature +81 -0
  35. data/features/request_matching/custom_matcher.feature +125 -0
  36. data/features/request_matching/headers.feature +85 -0
  37. data/features/request_matching/host.feature +85 -0
  38. data/features/request_matching/identical_request_sequence.feature +79 -0
  39. data/features/request_matching/method.feature +86 -0
  40. data/features/request_matching/path.feature +86 -0
  41. data/features/request_matching/playback_repeats.feature +87 -0
  42. data/features/request_matching/uri.feature +84 -0
  43. data/features/request_matching/uri_without_param.feature +85 -0
  44. data/features/step_definitions/cli_steps.rb +4 -28
  45. data/features/support/env.rb +11 -9
  46. data/features/support/http_lib_filters.rb +2 -11
  47. data/features/support/vcr_cucumber_helpers.rb +4 -5
  48. data/features/test_frameworks/cucumber.feature +17 -18
  49. data/features/test_frameworks/rspec.feature +8 -12
  50. data/features/test_frameworks/shoulda.feature +5 -8
  51. data/features/test_frameworks/test_unit.feature +5 -8
  52. data/lib/vcr.rb +38 -58
  53. data/lib/vcr/cassette.rb +41 -60
  54. data/lib/vcr/cassette/http_interaction_list.rb +56 -0
  55. data/lib/vcr/cassette/reader.rb +29 -31
  56. data/lib/vcr/configuration.rb +76 -0
  57. data/lib/vcr/deprecations.rb +39 -0
  58. data/lib/vcr/errors.rb +22 -0
  59. data/lib/vcr/library_hooks.rb +19 -0
  60. data/lib/vcr/library_hooks/excon.rb +136 -0
  61. data/lib/vcr/library_hooks/fakeweb.rb +110 -0
  62. data/lib/vcr/library_hooks/faraday.rb +3 -0
  63. data/lib/vcr/library_hooks/typhoeus.rb +98 -0
  64. data/lib/vcr/library_hooks/webmock.rb +100 -0
  65. data/lib/vcr/middleware/faraday.rb +43 -36
  66. data/lib/vcr/middleware/rack.rb +28 -4
  67. data/lib/vcr/request_handler.rb +43 -0
  68. data/lib/vcr/request_ignorer.rb +31 -0
  69. data/lib/vcr/request_matcher_registry.rb +86 -0
  70. data/lib/vcr/structs/http_interaction.rb +24 -18
  71. data/lib/vcr/structs/normalizers/body.rb +1 -1
  72. data/lib/vcr/structs/normalizers/header.rb +1 -1
  73. data/lib/vcr/structs/normalizers/status_message.rb +1 -1
  74. data/lib/vcr/structs/normalizers/uri.rb +1 -1
  75. data/lib/vcr/structs/request.rb +0 -13
  76. data/lib/vcr/structs/response.rb +2 -9
  77. data/lib/vcr/structs/response_status.rb +0 -4
  78. data/lib/vcr/test_frameworks/cucumber.rb +1 -1
  79. data/lib/vcr/test_frameworks/rspec.rb +1 -1
  80. data/lib/vcr/util/hooks.rb +28 -19
  81. data/lib/vcr/util/internet_connection.rb +29 -2
  82. data/lib/vcr/util/version_checker.rb +60 -0
  83. data/lib/vcr/version.rb +1 -1
  84. data/script/FullBuildRakeFile +0 -7
  85. data/script/full_build +1 -1
  86. data/spec/capture_warnings.rb +36 -31
  87. data/spec/fixtures/{1.9.1/cassette_spec → cassette_spec}/empty.yml +0 -0
  88. data/spec/fixtures/{not_1.9.1/cassette_spec → cassette_spec}/example.yml +0 -0
  89. data/spec/fixtures/{not_1.9.1/cassette_spec → cassette_spec}/with_localhost_requests.yml +0 -0
  90. data/spec/fixtures/{not_1.9.1/fake_example.com_responses.yml → fake_example.com_responses.yml} +0 -0
  91. data/spec/fixtures/{not_1.9.1/match_requests_on.yml → match_requests_on.yml} +0 -0
  92. data/spec/monkey_patches.rb +40 -11
  93. data/spec/spec_helper.rb +7 -43
  94. data/spec/support/http_library_adapters.rb +3 -13
  95. data/spec/support/shared_example_groups/{http_library.rb → hook_into_http_library.rb} +39 -111
  96. data/spec/support/shared_example_groups/version_checking.rb +9 -9
  97. data/spec/vcr/cassette/http_interaction_list_spec.rb +178 -0
  98. data/spec/vcr/cassette/reader_spec.rb +2 -2
  99. data/spec/vcr/cassette_spec.rb +121 -156
  100. data/spec/vcr/configuration_spec.rb +143 -0
  101. data/spec/vcr/deprecations_spec.rb +91 -0
  102. data/spec/vcr/{http_stubbing_adapters → library_hooks}/excon_spec.rb +6 -9
  103. data/spec/vcr/library_hooks/fakeweb_spec.rb +83 -0
  104. data/spec/vcr/{http_stubbing_adapters → library_hooks}/typhoeus_spec.rb +7 -11
  105. data/spec/vcr/library_hooks/webmock_spec.rb +17 -0
  106. data/spec/vcr/library_hooks_spec.rb +51 -0
  107. data/spec/vcr/middleware/faraday_spec.rb +17 -44
  108. data/spec/vcr/middleware/rack_spec.rb +94 -58
  109. data/spec/vcr/request_ignorer_spec.rb +54 -0
  110. data/spec/vcr/request_matcher_registry_spec.rb +223 -0
  111. data/spec/vcr/structs/request_spec.rb +0 -33
  112. data/spec/vcr/structs/response_spec.rb +0 -24
  113. data/spec/vcr/structs/response_status_spec.rb +0 -9
  114. data/spec/vcr/util/hooks_spec.rb +3 -5
  115. data/spec/vcr/version_spec.rb +1 -1
  116. data/spec/vcr_spec.rb +79 -91
  117. data/vcr.gemspec +1 -1
  118. metadata +83 -103
  119. data/features/cassettes/request_matching.feature +0 -383
  120. data/lib/vcr/config.rb +0 -84
  121. data/lib/vcr/deprecations/cassette.rb +0 -29
  122. data/lib/vcr/deprecations/config.rb +0 -18
  123. data/lib/vcr/deprecations/http_stubbing_adapters/common.rb +0 -9
  124. data/lib/vcr/deprecations/http_stubbing_adapters/fakeweb.rb +0 -11
  125. data/lib/vcr/extensions/net_http.rb +0 -32
  126. data/lib/vcr/http_stubbing_adapters/common.rb +0 -202
  127. data/lib/vcr/http_stubbing_adapters/excon.rb +0 -178
  128. data/lib/vcr/http_stubbing_adapters/fakeweb.rb +0 -107
  129. data/lib/vcr/http_stubbing_adapters/faraday.rb +0 -26
  130. data/lib/vcr/http_stubbing_adapters/multi_object_proxy.rb +0 -43
  131. data/lib/vcr/http_stubbing_adapters/typhoeus.rb +0 -115
  132. data/lib/vcr/http_stubbing_adapters/webmock.rb +0 -120
  133. data/lib/vcr/middleware/cassette_arguments.rb +0 -19
  134. data/lib/vcr/middleware/common.rb +0 -20
  135. data/lib/vcr/request_matcher.rb +0 -94
  136. data/lib/vcr/rspec.rb +0 -2
  137. data/lib/vcr/util/basic_object.rb +0 -43
  138. data/lib/vcr/util/ping.rb +0 -30
  139. data/lib/vcr/util/regexes.rb +0 -37
  140. data/spec/fixtures/1.9.1/0_3_1_cassette.yml +0 -29
  141. data/spec/fixtures/1.9.1/cassette_spec/example.yml +0 -110
  142. data/spec/fixtures/1.9.1/cassette_spec/with_localhost_requests.yml +0 -109
  143. data/spec/fixtures/1.9.1/example_net_http.yml +0 -14
  144. data/spec/fixtures/1.9.1/example_net_http_request.yml +0 -12
  145. data/spec/fixtures/1.9.1/example_net_http_response.yml +0 -25
  146. data/spec/fixtures/1.9.1/fake_example.com_responses.yml +0 -108
  147. data/spec/fixtures/1.9.1/match_requests_on.yml +0 -185
  148. data/spec/fixtures/not_1.9.1/0_3_1_cassette.yml +0 -29
  149. data/spec/fixtures/not_1.9.1/cassette_spec/empty.yml +0 -0
  150. data/spec/fixtures/not_1.9.1/example_net_http.yml +0 -14
  151. data/spec/fixtures/not_1.9.1/example_net_http_request.yml +0 -12
  152. data/spec/fixtures/not_1.9.1/example_net_http_response.yml +0 -25
  153. data/spec/support/shared_example_groups/http_stubbing_adapter.rb +0 -133
  154. data/spec/support/shared_example_groups/ignore_localhost_deprecation.rb +0 -28
  155. data/spec/vcr/config_spec.rb +0 -181
  156. data/spec/vcr/deprecations/cassette_spec.rb +0 -57
  157. data/spec/vcr/deprecations/config_spec.rb +0 -30
  158. data/spec/vcr/deprecations/http_stubbing_adapters/common_spec.rb +0 -7
  159. data/spec/vcr/deprecations/http_stubbing_adapters/fakeweb_spec.rb +0 -16
  160. data/spec/vcr/extensions/net_http_spec.rb +0 -80
  161. data/spec/vcr/http_stubbing_adapters/fakeweb_spec.rb +0 -19
  162. data/spec/vcr/http_stubbing_adapters/faraday_spec.rb +0 -76
  163. data/spec/vcr/http_stubbing_adapters/multi_object_proxy_spec.rb +0 -101
  164. data/spec/vcr/http_stubbing_adapters/webmock_spec.rb +0 -17
  165. data/spec/vcr/middleware/cassette_arguments_spec.rb +0 -32
  166. data/spec/vcr/request_matcher_spec.rb +0 -230
@@ -1,18 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe VCR::Request do
4
- describe '#matcher' do
5
- it 'returns a matcher with the given request' do
6
- req = VCR::Request.new
7
- req.matcher([:uri]).request.should eq(req)
8
- end
9
-
10
- it 'returns a matcher with the given match_attributes' do
11
- req = VCR::Request.new
12
- req.matcher([:uri, :headers]).match_attributes.to_a.should =~ [:uri, :headers]
13
- end
14
- end
15
-
16
4
  describe '#method' do
17
5
  subject { VCR::Request.new(:get) }
18
6
 
@@ -31,27 +19,6 @@ describe VCR::Request do
31
19
  end
32
20
  end
33
21
 
34
- describe '.from_net_http_request' do
35
- let(:net_http) { VCR::YAML.load_file("#{VCR::SPEC_ROOT}/fixtures/#{YAML_SERIALIZATION_VERSION}/example_net_http.yml") }
36
- let(:request) { VCR::YAML.load_file("#{VCR::SPEC_ROOT}/fixtures/#{YAML_SERIALIZATION_VERSION}/example_net_http_request.yml") }
37
- subject { described_class.from_net_http_request(net_http, request) }
38
-
39
- before(:each) do
40
- VCR.http_stubbing_adapter.should respond_to(:request_uri)
41
- VCR.http_stubbing_adapter.stub!(:request_uri)
42
- end
43
-
44
- it { should be_instance_of(VCR::Request) }
45
- its(:method) { should eq(:post) }
46
- its(:body) { should eq('id=7') }
47
- its(:headers) { should eq({ "content-type" => ["application/x-www-form-urlencoded"] }) }
48
-
49
- it 'sets the uri using the http_stubbing_adapter.request_uri' do
50
- VCR.http_stubbing_adapter.should_receive(:request_uri).with(net_http, request).and_return('foo/bar')
51
- subject.uri.should eq('foo/bar')
52
- end
53
- end
54
-
55
22
  it_performs 'uri normalization' do
56
23
  def instance(uri)
57
24
  VCR::Request.new(:get, uri, '', {})
@@ -1,30 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe VCR::Response do
4
- describe '.from_net_http_response' do
5
- let(:response) { VCR::YAML.load_file("#{VCR::SPEC_ROOT}/fixtures/#{YAML_SERIALIZATION_VERSION}/example_net_http_response.yml") }
6
- subject { described_class.from_net_http_response(response) }
7
-
8
- it { should be_instance_of(described_class) }
9
- its(:body) { should eq('The response from example.com') }
10
- its(:http_version) { should eq('1.1') }
11
- its(:headers) { should eq({
12
- "last-modified" => ['Tue, 15 Nov 2005 13:24:10 GMT'],
13
- "etag" => ["\"24ec5-1b6-4059a80bfd280\""],
14
- "content-type" => ["text/html; charset=UTF-8"],
15
- "date" => ['Wed, 31 Mar 2010 02:43:26 GMT'],
16
- "server" => ['Apache/2.2.3 (CentOS)'],
17
- "content-length" => ['438'],
18
- "accept-ranges" => ['bytes']
19
- }) }
20
-
21
- it 'assigns the status using VCR::ResponseStatus.from_net_http_response' do
22
- VCR::ResponseStatus.should respond_to(:from_net_http_response)
23
- VCR::ResponseStatus.should_receive(:from_net_http_response).with(response).and_return(:the_status)
24
- subject.status.should eq(:the_status)
25
- end
26
- end
27
-
28
4
  it_performs 'header normalization' do
29
5
  def with_headers(headers)
30
6
  described_class.new(:status, headers, nil, '1.1')
@@ -1,15 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe VCR::ResponseStatus do
4
- describe '.from_net_http_response' do
5
- let(:response) { VCR::YAML.load_file("#{VCR::SPEC_ROOT}/fixtures/#{YAML_SERIALIZATION_VERSION}/example_net_http_response.yml") }
6
- subject { described_class.from_net_http_response(response) }
7
-
8
- it { should be_instance_of(described_class) }
9
- its(:code) { should eq(200) }
10
- its(:message) { should eq('OK') }
11
- end
12
-
13
4
  it_performs 'status message normalization' do
14
5
  def instance(message)
15
6
  described_class.new(200, message)
@@ -1,15 +1,13 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe VCR::Hooks do
4
- class HooksClass
5
- include VCR::Hooks
6
- end
4
+ let(:hooks_class) { Class.new { include VCR::Hooks } }
7
5
 
8
- subject { HooksClass.new }
6
+ subject { hooks_class.new }
9
7
  let(:invocations) { [] }
10
8
 
11
9
  before(:each) do
12
- subject.instance_eval do
10
+ hooks_class.instance_eval do
13
11
  define_hook :before_foo
14
12
  define_hook :before_bar
15
13
  end
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe "VCR.version" do
4
4
  subject { VCR.version }
5
5
 
6
- it { should =~ /\A\d+\.\d+\.\d+\z/ }
6
+ it { should =~ /\A\d+\.\d+\.\d+(\.\w+)?\z/ }
7
7
  its(:parts) { should be_instance_of(Array) }
8
8
  its(:major) { should be_instance_of(Fixnum) }
9
9
  its(:minor) { should be_instance_of(Fixnum) }
data/spec/vcr_spec.rb CHANGED
@@ -86,105 +86,110 @@ describe VCR do
86
86
  end
87
87
  end
88
88
 
89
- describe '.config' do
90
- it 'yields the configuration object' do
91
- yielded_object = nil
92
- VCR.config do |obj|
93
- yielded_object = obj
94
- end
95
- yielded_object.should eq(VCR::Config)
89
+ describe '.http_interactions' do
90
+ it 'returns the current_cassette.http_interactions when there is a current cassette' do
91
+ cassette = VCR.insert_cassette("a cassette")
92
+ VCR.http_interactions.should be(cassette.http_interactions)
96
93
  end
97
94
 
98
- it "sets http_stubbing_adapter.http_connections_allowed to the configured default" do
99
- VCR.http_stubbing_adapter.should respond_to(:set_http_connections_allowed_to_default)
100
- VCR.http_stubbing_adapter.should_receive(:set_http_connections_allowed_to_default)
101
- VCR.config { }
95
+ it 'returns a null list when there is no current cassette' do
96
+ VCR.current_cassette.should be_nil
97
+ VCR.http_interactions.should be_a(VCR::Cassette::HTTPInteractionList::NullList)
102
98
  end
99
+ end
100
+
101
+ describe '.real_http_connections_allowed?' do
102
+ context 'when a cassette is inserted' do
103
+ it 'returns true if the cassette is recording' do
104
+ VCR.insert_cassette('foo', :record => :all)
105
+ VCR.current_cassette.should be_recording
106
+ VCR.real_http_connections_allowed?.should be_true
107
+ end
103
108
 
104
- it "checks the adapted library's version to make sure it's compatible with VCR" do
105
- VCR.http_stubbing_adapter.should respond_to(:check_version!)
106
- VCR.http_stubbing_adapter.should_receive(:check_version!)
107
- VCR.config { }
109
+ it 'returns false if the cassette is not recording' do
110
+ VCR.insert_cassette('foo', :record => :none)
111
+ VCR.current_cassette.should_not be_recording
112
+ VCR.real_http_connections_allowed?.should be_false
113
+ end
108
114
  end
109
115
 
110
- it "sets http_stubbing_adapter.ignored_hosts to the configured hosts when the block completes" do
111
- VCR::Config.reset!(nil)
112
- VCR::HttpStubbingAdapters::FakeWeb.send(:ignored_hosts).should be_empty
116
+ context 'when no cassette is inserted' do
117
+ before(:each) { VCR.current_cassette.should be_nil }
113
118
 
114
- VCR.config do |c|
115
- c.stub_with :fakeweb
116
- c.ignore_hosts 'example.com', 'example.org'
119
+ it 'returns true if the allow_http_connections_when_no_cassette option is set to true' do
120
+ VCR.should be_turned_on
121
+ VCR.configure { |c| c.allow_http_connections_when_no_cassette = true }
122
+ VCR.real_http_connections_allowed?.should be_true
117
123
  end
118
124
 
119
- VCR::HttpStubbingAdapters::FakeWeb.send(:ignored_hosts).should eq(%w[example.com example.org])
120
- end
121
- end
125
+ it 'returns true if VCR is turned off' do
126
+ VCR.turn_off!
127
+ VCR.configure { |c| c.allow_http_connections_when_no_cassette = false }
128
+ VCR.real_http_connections_allowed?.should be_true
129
+ end
122
130
 
123
- describe '.cucumber_tags' do
124
- it 'yields a cucumber tags object' do
125
- yielded_object = nil
126
- VCR.cucumber_tags do |obj|
127
- yielded_object = obj
131
+ it 'returns false if the allow_http_connections_when_no_cassette option is set to false and VCR is turned on' do
132
+ VCR.should be_turned_on
133
+ VCR.configure { |c| c.allow_http_connections_when_no_cassette = false }
134
+ VCR.real_http_connections_allowed?.should be_false
128
135
  end
129
- yielded_object.should be_instance_of(VCR::CucumberTags)
130
136
  end
131
137
  end
132
138
 
133
- describe '.http_stubbing_adapter' do
134
- subject { VCR.http_stubbing_adapter }
135
- before(:each) do
136
- VCR.instance_variable_set(:@http_stubbing_adapter, nil)
137
- end
138
-
139
- it 'returns a multi object proxy for the configured stubbing libraries when multiple libs are configured', :unless => RUBY_PLATFORM == 'java' do
140
- VCR::Config.stub_with :fakeweb, :typhoeus
141
- VCR.http_stubbing_adapter.proxied_objects.should eq([
142
- VCR::HttpStubbingAdapters::FakeWeb,
143
- VCR::HttpStubbingAdapters::Typhoeus
144
- ])
145
- end
146
-
147
- {
148
- :fakeweb => VCR::HttpStubbingAdapters::FakeWeb,
149
- :webmock => VCR::HttpStubbingAdapters::WebMock,
150
- :faraday => VCR::HttpStubbingAdapters::Faraday,
151
- :excon => VCR::HttpStubbingAdapters::Excon
152
- }.each do |symbol, klass|
153
- it "returns #{klass} for :#{symbol}" do
154
- VCR::Config.stub_with symbol
155
- VCR.http_stubbing_adapter.should eq(klass)
156
- end
139
+ describe '.request_matchers' do
140
+ it 'always returns the same memoized request matcher registry instance' do
141
+ VCR.request_matchers.should be_a(VCR::RequestMatcherRegistry)
142
+ VCR.request_matchers.should be(VCR.request_matchers)
157
143
  end
144
+ end
158
145
 
159
- it 'calls #after_adapters_loaded on the configured stubbing adapter' do
160
- VCR::HttpStubbingAdapters::FakeWeb.should_receive(:after_adapters_loaded)
161
- VCR::Config.stub_with :fakeweb
162
- VCR.http_stubbing_adapter
146
+ describe '.request_ignorer' do
147
+ it 'always returns the same memoized request ignorer instance' do
148
+ VCR.request_ignorer.should be_a(VCR::RequestIgnorer)
149
+ VCR.request_ignorer.should be(VCR.request_ignorer)
163
150
  end
151
+ end
164
152
 
165
- it 'raises an error if both :fakeweb and :webmock are configured' do
166
- VCR::Config.stub_with :fakeweb, :webmock
167
-
168
- expect { VCR.http_stubbing_adapter }.to raise_error(ArgumentError, /cannot use both/)
153
+ describe '.library_hooks' do
154
+ it 'always returns the same memoized LibraryHooks instance' do
155
+ VCR.library_hooks.should be_a(VCR::LibraryHooks)
156
+ VCR.library_hooks.should be(VCR.library_hooks)
169
157
  end
158
+ end
170
159
 
171
- it 'raises an error for unsupported stubbing libraries' do
172
- VCR::Config.stub_with :unsupported_library
160
+ describe '.configuration' do
161
+ it 'returns the configuration object' do
162
+ VCR.configuration.should be_a(VCR::Configuration)
163
+ end
173
164
 
174
- expect { VCR.http_stubbing_adapter }.to raise_error(ArgumentError, /unsupported_library is not a supported HTTP stubbing library/i)
165
+ it 'memoizes the instance' do
166
+ VCR.configuration.should be(VCR.configuration)
175
167
  end
168
+ end
176
169
 
177
- it 'raises an error when no stubbing libraries are configured' do
178
- VCR::Config.stub_with
170
+ describe '.configure' do
171
+ it 'yields the configuration object' do
172
+ yielded_object = nil
173
+ VCR.configure do |obj|
174
+ yielded_object = obj
175
+ end
176
+ yielded_object.should eq(VCR.configuration)
177
+ end
178
+ end
179
179
 
180
- expect { VCR.http_stubbing_adapter }.to raise_error(ArgumentError, /the http stubbing library is not configured/i)
180
+ describe '.cucumber_tags' do
181
+ it 'yields a cucumber tags object' do
182
+ yielded_object = nil
183
+ VCR.cucumber_tags do |obj|
184
+ yielded_object = obj
185
+ end
186
+ yielded_object.should be_instance_of(VCR::CucumberTags)
181
187
  end
182
188
  end
183
189
 
184
190
  describe '.record_http_interaction' do
185
191
  before(:each) { VCR.stub(:current_cassette => current_cassette) }
186
- let(:uri) { 'http://some-host.com/' }
187
- let(:interaction) { stub(:uri => uri) }
192
+ let(:interaction) { stub(:request => stub) }
188
193
 
189
194
  context 'when there is not a current cassette' do
190
195
  let(:current_cassette) { nil }
@@ -192,7 +197,6 @@ describe VCR do
192
197
  it 'does not record a request' do
193
198
  # we can't set a message expectation on nil, but there is no place to record it to...
194
199
  # this mostly tests that there is no error.
195
- VCR::Config.stub(:uri_should_be_ignored? => false)
196
200
  VCR.record_http_interaction(interaction)
197
201
  end
198
202
  end
@@ -200,14 +204,14 @@ describe VCR do
200
204
  context 'when there is a current cassette' do
201
205
  let(:current_cassette) { mock('current cassette') }
202
206
 
203
- it 'records the request when the uri should not be ignored' do
204
- VCR::Config.stub(:uri_should_be_ignored?).with(uri).and_return(false)
207
+ it 'records the request when it should not be ignored' do
208
+ VCR.request_ignorer.stub(:ignore?).with(interaction.request).and_return(false)
205
209
  current_cassette.should_receive(:record_http_interaction).with(interaction)
206
210
  VCR.record_http_interaction(interaction)
207
211
  end
208
212
 
209
- it 'does not record the request when the uri should be ignored' do
210
- VCR::Config.stub(:uri_should_be_ignored?).with(uri).and_return(true)
213
+ it 'does not record the request when it should be ignored' do
214
+ VCR.request_ignorer.stub(:ignore?).with(interaction.request).and_return(true)
211
215
  current_cassette.should_not_receive(:record_http_interaction)
212
216
  VCR.record_http_interaction(interaction)
213
217
  end
@@ -215,21 +219,11 @@ describe VCR do
215
219
  end
216
220
 
217
221
  describe '.turn_off!' do
218
- before(:each) { VCR.http_stubbing_adapter.http_connections_allowed = false }
219
-
220
222
  it 'indicates it is turned off' do
221
223
  VCR.turn_off!
222
224
  VCR.should_not be_turned_on
223
225
  end
224
226
 
225
- it 'allows http requests' do
226
- expect {
227
- VCR.turn_off!
228
- }.to change {
229
- VCR.http_stubbing_adapter.http_connections_allowed?
230
- }.from(false).to(true)
231
- end
232
-
233
227
  it 'raises an error if a cassette is in use' do
234
228
  VCR.insert_cassette('foo')
235
229
  expect {
@@ -278,12 +272,6 @@ describe VCR do
278
272
  VCR.turn_on!
279
273
  VCR.should be_turned_on
280
274
  end
281
-
282
- it 'sets http_connections_allowed to the default' do
283
- VCR.http_stubbing_adapter.should respond_to(:set_http_connections_allowed_to_default)
284
- VCR.http_stubbing_adapter.should_receive(:set_http_connections_allowed_to_default)
285
- VCR.turn_on!
286
- end
287
275
  end
288
276
 
289
277
  describe '.turned_off' do
data/vcr.gemspec CHANGED
@@ -41,7 +41,7 @@ Gem::Specification.new do |s|
41
41
 
42
42
  # Cucumber 1.0.2 seems to have issues installing on 1.8.6 :(.
43
43
  {
44
- 'cucumber' => '~> 1.0.2',
44
+ 'cucumber' => '~> 1.0.3',
45
45
  'aruba' => '~> 0.4.6',
46
46
  }.each do |lib, version|
47
47
  s.add_development_dependency lib, version
metadata CHANGED
@@ -1,13 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vcr
3
3
  version: !ruby/object:Gem::Version
4
- hash: 61
5
- prerelease:
4
+ hash: 62196449
5
+ prerelease: 6
6
6
  segments:
7
+ - 2
8
+ - 0
9
+ - 0
10
+ - beta
7
11
  - 1
8
- - 11
9
- - 3
10
- version: 1.11.3
12
+ version: 2.0.0.beta1
11
13
  platform: ruby
12
14
  authors:
13
15
  - Myron Marston
@@ -15,7 +17,7 @@ autorequire:
15
17
  bindir: bin
16
18
  cert_chain: []
17
19
 
18
- date: 2011-09-01 00:00:00 Z
20
+ date: 2011-10-09 00:00:00 Z
19
21
  dependencies:
20
22
  - !ruby/object:Gem::Dependency
21
23
  version_requirements: &id001 !ruby/object:Gem::Requirement
@@ -247,12 +249,12 @@ dependencies:
247
249
  requirements:
248
250
  - - ~>
249
251
  - !ruby/object:Gem::Version
250
- hash: 19
252
+ hash: 17
251
253
  segments:
252
254
  - 1
253
255
  - 0
254
- - 2
255
- version: 1.0.2
256
+ - 3
257
+ version: 1.0.3
256
258
  name: cucumber
257
259
  type: :development
258
260
  prerelease: false
@@ -348,19 +350,19 @@ files:
348
350
  - features/about_these_examples.md
349
351
  - features/cassettes/automatic_re_recording.feature
350
352
  - features/cassettes/dynamic_erb.feature
353
+ - features/cassettes/exclusive.feature
351
354
  - features/cassettes/format.feature
352
355
  - features/cassettes/naming.feature
353
356
  - features/cassettes/no_cassette.feature
354
- - features/cassettes/request_matching.feature
355
357
  - features/cassettes/update_content_length_header.feature
356
358
  - features/configuration/allow_http_connections_when_no_cassette.feature
357
359
  - features/configuration/cassette_library_dir.feature
358
360
  - features/configuration/default_cassette_options.feature
359
361
  - features/configuration/filter_sensitive_data.feature
362
+ - features/configuration/hook_into.feature
360
363
  - features/configuration/hooks.feature
361
364
  - features/configuration/ignore_hosts.feature
362
365
  - features/configuration/ignore_localhost.feature
363
- - features/configuration/stub_with.feature
364
366
  - features/getting_started.md
365
367
  - features/http_libraries/em_http_request.feature
366
368
  - features/http_libraries/net_http.feature
@@ -370,6 +372,17 @@ files:
370
372
  - features/record_modes/new_episodes.feature
371
373
  - features/record_modes/none.feature
372
374
  - features/record_modes/once.feature
375
+ - features/request_matching/README.md
376
+ - features/request_matching/body.feature
377
+ - features/request_matching/custom_matcher.feature
378
+ - features/request_matching/headers.feature
379
+ - features/request_matching/host.feature
380
+ - features/request_matching/identical_request_sequence.feature
381
+ - features/request_matching/method.feature
382
+ - features/request_matching/path.feature
383
+ - features/request_matching/playback_repeats.feature
384
+ - features/request_matching/uri.feature
385
+ - features/request_matching/uri_without_param.feature
373
386
  - features/step_definitions/cli_steps.rb
374
387
  - features/support/env.rb
375
388
  - features/support/http_lib_filters.rb
@@ -380,27 +393,23 @@ files:
380
393
  - features/test_frameworks/test_unit.feature
381
394
  - lib/vcr.rb
382
395
  - lib/vcr/cassette.rb
396
+ - lib/vcr/cassette/http_interaction_list.rb
383
397
  - lib/vcr/cassette/reader.rb
384
- - lib/vcr/config.rb
385
- - lib/vcr/deprecations/cassette.rb
386
- - lib/vcr/deprecations/config.rb
387
- - lib/vcr/deprecations/http_stubbing_adapters/common.rb
388
- - lib/vcr/deprecations/http_stubbing_adapters/fakeweb.rb
389
- - lib/vcr/extensions/net_http.rb
398
+ - lib/vcr/configuration.rb
399
+ - lib/vcr/deprecations.rb
400
+ - lib/vcr/errors.rb
390
401
  - lib/vcr/extensions/net_http_response.rb
391
- - lib/vcr/http_stubbing_adapters/common.rb
392
- - lib/vcr/http_stubbing_adapters/excon.rb
393
- - lib/vcr/http_stubbing_adapters/fakeweb.rb
394
- - lib/vcr/http_stubbing_adapters/faraday.rb
395
- - lib/vcr/http_stubbing_adapters/multi_object_proxy.rb
396
- - lib/vcr/http_stubbing_adapters/typhoeus.rb
397
- - lib/vcr/http_stubbing_adapters/webmock.rb
398
- - lib/vcr/middleware/cassette_arguments.rb
399
- - lib/vcr/middleware/common.rb
402
+ - lib/vcr/library_hooks.rb
403
+ - lib/vcr/library_hooks/excon.rb
404
+ - lib/vcr/library_hooks/fakeweb.rb
405
+ - lib/vcr/library_hooks/faraday.rb
406
+ - lib/vcr/library_hooks/typhoeus.rb
407
+ - lib/vcr/library_hooks/webmock.rb
400
408
  - lib/vcr/middleware/faraday.rb
401
409
  - lib/vcr/middleware/rack.rb
402
- - lib/vcr/request_matcher.rb
403
- - lib/vcr/rspec.rb
410
+ - lib/vcr/request_handler.rb
411
+ - lib/vcr/request_ignorer.rb
412
+ - lib/vcr/request_matcher_registry.rb
404
413
  - lib/vcr/structs/http_interaction.rb
405
414
  - lib/vcr/structs/normalizers/body.rb
406
415
  - lib/vcr/structs/normalizers/header.rb
@@ -411,67 +420,46 @@ files:
411
420
  - lib/vcr/structs/response_status.rb
412
421
  - lib/vcr/test_frameworks/cucumber.rb
413
422
  - lib/vcr/test_frameworks/rspec.rb
414
- - lib/vcr/util/basic_object.rb
415
423
  - lib/vcr/util/hooks.rb
416
424
  - lib/vcr/util/internet_connection.rb
417
- - lib/vcr/util/ping.rb
418
- - lib/vcr/util/regexes.rb
419
425
  - lib/vcr/util/variable_args_block_caller.rb
426
+ - lib/vcr/util/version_checker.rb
420
427
  - lib/vcr/util/yaml.rb
421
428
  - lib/vcr/version.rb
422
429
  - script/FullBuildRakeFile
423
430
  - script/full_build
424
431
  - script/spec
425
432
  - spec/capture_warnings.rb
426
- - spec/fixtures/1.9.1/0_3_1_cassette.yml
427
- - spec/fixtures/1.9.1/cassette_spec/empty.yml
428
- - spec/fixtures/1.9.1/cassette_spec/example.yml
429
- - spec/fixtures/1.9.1/cassette_spec/with_localhost_requests.yml
430
- - spec/fixtures/1.9.1/example_net_http.yml
431
- - spec/fixtures/1.9.1/example_net_http_request.yml
432
- - spec/fixtures/1.9.1/example_net_http_response.yml
433
- - spec/fixtures/1.9.1/fake_example.com_responses.yml
434
- - spec/fixtures/1.9.1/match_requests_on.yml
435
- - spec/fixtures/not_1.9.1/0_3_1_cassette.yml
436
- - spec/fixtures/not_1.9.1/cassette_spec/empty.yml
437
- - spec/fixtures/not_1.9.1/cassette_spec/example.yml
438
- - spec/fixtures/not_1.9.1/cassette_spec/with_localhost_requests.yml
439
- - spec/fixtures/not_1.9.1/example_net_http.yml
440
- - spec/fixtures/not_1.9.1/example_net_http_request.yml
441
- - spec/fixtures/not_1.9.1/example_net_http_response.yml
442
- - spec/fixtures/not_1.9.1/fake_example.com_responses.yml
443
- - spec/fixtures/not_1.9.1/match_requests_on.yml
433
+ - spec/fixtures/cassette_spec/empty.yml
434
+ - spec/fixtures/cassette_spec/example.yml
435
+ - spec/fixtures/cassette_spec/with_localhost_requests.yml
436
+ - spec/fixtures/fake_example.com_responses.yml
437
+ - spec/fixtures/match_requests_on.yml
444
438
  - spec/monkey_patches.rb
445
439
  - spec/spec_helper.rb
446
440
  - spec/support/fixnum_extension.rb
447
441
  - spec/support/http_library_adapters.rb
448
442
  - spec/support/ruby_interpreter.rb
449
- - spec/support/shared_example_groups/http_library.rb
450
- - spec/support/shared_example_groups/http_stubbing_adapter.rb
451
- - spec/support/shared_example_groups/ignore_localhost_deprecation.rb
443
+ - spec/support/shared_example_groups/hook_into_http_library.rb
452
444
  - spec/support/shared_example_groups/normalizers.rb
453
445
  - spec/support/shared_example_groups/version_checking.rb
454
446
  - spec/support/sinatra_app.rb
455
447
  - spec/support/vcr_localhost_server.rb
448
+ - spec/vcr/cassette/http_interaction_list_spec.rb
456
449
  - spec/vcr/cassette/reader_spec.rb
457
450
  - spec/vcr/cassette_spec.rb
458
- - spec/vcr/config_spec.rb
459
- - spec/vcr/deprecations/cassette_spec.rb
460
- - spec/vcr/deprecations/config_spec.rb
461
- - spec/vcr/deprecations/http_stubbing_adapters/common_spec.rb
462
- - spec/vcr/deprecations/http_stubbing_adapters/fakeweb_spec.rb
451
+ - spec/vcr/configuration_spec.rb
452
+ - spec/vcr/deprecations_spec.rb
463
453
  - spec/vcr/extensions/net_http_response_spec.rb
464
- - spec/vcr/extensions/net_http_spec.rb
465
- - spec/vcr/http_stubbing_adapters/excon_spec.rb
466
- - spec/vcr/http_stubbing_adapters/fakeweb_spec.rb
467
- - spec/vcr/http_stubbing_adapters/faraday_spec.rb
468
- - spec/vcr/http_stubbing_adapters/multi_object_proxy_spec.rb
469
- - spec/vcr/http_stubbing_adapters/typhoeus_spec.rb
470
- - spec/vcr/http_stubbing_adapters/webmock_spec.rb
471
- - spec/vcr/middleware/cassette_arguments_spec.rb
454
+ - spec/vcr/library_hooks/excon_spec.rb
455
+ - spec/vcr/library_hooks/fakeweb_spec.rb
456
+ - spec/vcr/library_hooks/typhoeus_spec.rb
457
+ - spec/vcr/library_hooks/webmock_spec.rb
458
+ - spec/vcr/library_hooks_spec.rb
472
459
  - spec/vcr/middleware/faraday_spec.rb
473
460
  - spec/vcr/middleware/rack_spec.rb
474
- - spec/vcr/request_matcher_spec.rb
461
+ - spec/vcr/request_ignorer_spec.rb
462
+ - spec/vcr/request_matcher_registry_spec.rb
475
463
  - spec/vcr/structs/http_interaction_spec.rb
476
464
  - spec/vcr/structs/request_spec.rb
477
465
  - spec/vcr/structs/response_spec.rb
@@ -524,19 +512,19 @@ test_files:
524
512
  - features/about_these_examples.md
525
513
  - features/cassettes/automatic_re_recording.feature
526
514
  - features/cassettes/dynamic_erb.feature
515
+ - features/cassettes/exclusive.feature
527
516
  - features/cassettes/format.feature
528
517
  - features/cassettes/naming.feature
529
518
  - features/cassettes/no_cassette.feature
530
- - features/cassettes/request_matching.feature
531
519
  - features/cassettes/update_content_length_header.feature
532
520
  - features/configuration/allow_http_connections_when_no_cassette.feature
533
521
  - features/configuration/cassette_library_dir.feature
534
522
  - features/configuration/default_cassette_options.feature
535
523
  - features/configuration/filter_sensitive_data.feature
524
+ - features/configuration/hook_into.feature
536
525
  - features/configuration/hooks.feature
537
526
  - features/configuration/ignore_hosts.feature
538
527
  - features/configuration/ignore_localhost.feature
539
- - features/configuration/stub_with.feature
540
528
  - features/getting_started.md
541
529
  - features/http_libraries/em_http_request.feature
542
530
  - features/http_libraries/net_http.feature
@@ -546,6 +534,17 @@ test_files:
546
534
  - features/record_modes/new_episodes.feature
547
535
  - features/record_modes/none.feature
548
536
  - features/record_modes/once.feature
537
+ - features/request_matching/README.md
538
+ - features/request_matching/body.feature
539
+ - features/request_matching/custom_matcher.feature
540
+ - features/request_matching/headers.feature
541
+ - features/request_matching/host.feature
542
+ - features/request_matching/identical_request_sequence.feature
543
+ - features/request_matching/method.feature
544
+ - features/request_matching/path.feature
545
+ - features/request_matching/playback_repeats.feature
546
+ - features/request_matching/uri.feature
547
+ - features/request_matching/uri_without_param.feature
549
548
  - features/step_definitions/cli_steps.rb
550
549
  - features/support/env.rb
551
550
  - features/support/http_lib_filters.rb
@@ -555,55 +554,36 @@ test_files:
555
554
  - features/test_frameworks/shoulda.feature
556
555
  - features/test_frameworks/test_unit.feature
557
556
  - spec/capture_warnings.rb
558
- - spec/fixtures/1.9.1/0_3_1_cassette.yml
559
- - spec/fixtures/1.9.1/cassette_spec/empty.yml
560
- - spec/fixtures/1.9.1/cassette_spec/example.yml
561
- - spec/fixtures/1.9.1/cassette_spec/with_localhost_requests.yml
562
- - spec/fixtures/1.9.1/example_net_http.yml
563
- - spec/fixtures/1.9.1/example_net_http_request.yml
564
- - spec/fixtures/1.9.1/example_net_http_response.yml
565
- - spec/fixtures/1.9.1/fake_example.com_responses.yml
566
- - spec/fixtures/1.9.1/match_requests_on.yml
567
- - spec/fixtures/not_1.9.1/0_3_1_cassette.yml
568
- - spec/fixtures/not_1.9.1/cassette_spec/empty.yml
569
- - spec/fixtures/not_1.9.1/cassette_spec/example.yml
570
- - spec/fixtures/not_1.9.1/cassette_spec/with_localhost_requests.yml
571
- - spec/fixtures/not_1.9.1/example_net_http.yml
572
- - spec/fixtures/not_1.9.1/example_net_http_request.yml
573
- - spec/fixtures/not_1.9.1/example_net_http_response.yml
574
- - spec/fixtures/not_1.9.1/fake_example.com_responses.yml
575
- - spec/fixtures/not_1.9.1/match_requests_on.yml
557
+ - spec/fixtures/cassette_spec/empty.yml
558
+ - spec/fixtures/cassette_spec/example.yml
559
+ - spec/fixtures/cassette_spec/with_localhost_requests.yml
560
+ - spec/fixtures/fake_example.com_responses.yml
561
+ - spec/fixtures/match_requests_on.yml
576
562
  - spec/monkey_patches.rb
577
563
  - spec/spec_helper.rb
578
564
  - spec/support/fixnum_extension.rb
579
565
  - spec/support/http_library_adapters.rb
580
566
  - spec/support/ruby_interpreter.rb
581
- - spec/support/shared_example_groups/http_library.rb
582
- - spec/support/shared_example_groups/http_stubbing_adapter.rb
583
- - spec/support/shared_example_groups/ignore_localhost_deprecation.rb
567
+ - spec/support/shared_example_groups/hook_into_http_library.rb
584
568
  - spec/support/shared_example_groups/normalizers.rb
585
569
  - spec/support/shared_example_groups/version_checking.rb
586
570
  - spec/support/sinatra_app.rb
587
571
  - spec/support/vcr_localhost_server.rb
572
+ - spec/vcr/cassette/http_interaction_list_spec.rb
588
573
  - spec/vcr/cassette/reader_spec.rb
589
574
  - spec/vcr/cassette_spec.rb
590
- - spec/vcr/config_spec.rb
591
- - spec/vcr/deprecations/cassette_spec.rb
592
- - spec/vcr/deprecations/config_spec.rb
593
- - spec/vcr/deprecations/http_stubbing_adapters/common_spec.rb
594
- - spec/vcr/deprecations/http_stubbing_adapters/fakeweb_spec.rb
575
+ - spec/vcr/configuration_spec.rb
576
+ - spec/vcr/deprecations_spec.rb
595
577
  - spec/vcr/extensions/net_http_response_spec.rb
596
- - spec/vcr/extensions/net_http_spec.rb
597
- - spec/vcr/http_stubbing_adapters/excon_spec.rb
598
- - spec/vcr/http_stubbing_adapters/fakeweb_spec.rb
599
- - spec/vcr/http_stubbing_adapters/faraday_spec.rb
600
- - spec/vcr/http_stubbing_adapters/multi_object_proxy_spec.rb
601
- - spec/vcr/http_stubbing_adapters/typhoeus_spec.rb
602
- - spec/vcr/http_stubbing_adapters/webmock_spec.rb
603
- - spec/vcr/middleware/cassette_arguments_spec.rb
578
+ - spec/vcr/library_hooks/excon_spec.rb
579
+ - spec/vcr/library_hooks/fakeweb_spec.rb
580
+ - spec/vcr/library_hooks/typhoeus_spec.rb
581
+ - spec/vcr/library_hooks/webmock_spec.rb
582
+ - spec/vcr/library_hooks_spec.rb
604
583
  - spec/vcr/middleware/faraday_spec.rb
605
584
  - spec/vcr/middleware/rack_spec.rb
606
- - spec/vcr/request_matcher_spec.rb
585
+ - spec/vcr/request_ignorer_spec.rb
586
+ - spec/vcr/request_matcher_registry_spec.rb
607
587
  - spec/vcr/structs/http_interaction_spec.rb
608
588
  - spec/vcr/structs/request_spec.rb
609
589
  - spec/vcr/structs/response_spec.rb