vcr 1.11.1 → 1.11.2

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 (81) hide show
  1. data/.travis.yml +3 -0
  2. data/CHANGELOG.md +11 -4
  3. data/Gemfile +5 -4
  4. data/Rakefile +23 -4
  5. data/cucumber.yml +2 -2
  6. data/features/cassettes/automatic_re_recording.feature +2 -2
  7. data/features/cassettes/dynamic_erb.feature +2 -2
  8. data/features/cassettes/format.feature +1 -1
  9. data/features/cassettes/naming.feature +1 -1
  10. data/features/cassettes/no_cassette.feature +4 -4
  11. data/features/cassettes/request_matching.feature +5 -5
  12. data/features/cassettes/update_content_length_header.feature +3 -3
  13. data/features/configuration/allow_http_connections_when_no_cassette.feature +3 -3
  14. data/features/configuration/cassette_library_dir.feature +1 -1
  15. data/features/configuration/default_cassette_options.feature +5 -5
  16. data/features/configuration/filter_sensitive_data.feature +6 -6
  17. data/features/configuration/hooks.feature +6 -6
  18. data/features/configuration/ignore_hosts.feature +1 -1
  19. data/features/configuration/ignore_localhost.feature +2 -2
  20. data/features/configuration/stub_with.feature +4 -4
  21. data/features/http_libraries/em_http_request.feature +4 -4
  22. data/features/http_libraries/net_http.feature +10 -10
  23. data/features/middleware/faraday.feature +2 -2
  24. data/features/middleware/rack.feature +2 -2
  25. data/features/record_modes/all.feature +2 -2
  26. data/features/record_modes/new_episodes.feature +2 -2
  27. data/features/record_modes/none.feature +2 -2
  28. data/features/record_modes/once.feature +3 -3
  29. data/features/step_definitions/cli_steps.rb +6 -2
  30. data/features/support/env.rb +5 -8
  31. data/features/support/http_lib_filters.rb +6 -1
  32. data/features/test_frameworks/cucumber.feature +2 -2
  33. data/features/test_frameworks/rspec.feature +2 -2
  34. data/features/test_frameworks/shoulda.feature +13 -10
  35. data/features/test_frameworks/test_unit.feature +12 -9
  36. data/lib/vcr.rb +6 -0
  37. data/lib/vcr/config.rb +7 -1
  38. data/lib/vcr/deprecations/cassette.rb +16 -16
  39. data/lib/vcr/extensions/net_http_response.rb +4 -0
  40. data/lib/vcr/http_stubbing_adapters/common.rb +1 -1
  41. data/lib/vcr/http_stubbing_adapters/fakeweb.rb +6 -0
  42. data/lib/vcr/http_stubbing_adapters/webmock.rb +7 -0
  43. data/lib/vcr/middleware/cassette_arguments.rb +1 -0
  44. data/lib/vcr/structs/http_interaction.rb +1 -0
  45. data/lib/vcr/version.rb +1 -1
  46. data/spec/capture_warnings.rb +42 -0
  47. data/spec/monkey_patches.rb +5 -1
  48. data/spec/spec_helper.rb +2 -1
  49. data/spec/support/shared_example_groups/http_library.rb +19 -19
  50. data/spec/support/shared_example_groups/http_stubbing_adapter.rb +6 -6
  51. data/spec/support/shared_example_groups/ignore_localhost_deprecation.rb +1 -1
  52. data/spec/support/shared_example_groups/normalizers.rb +13 -15
  53. data/spec/support/sinatra_app.rb +2 -0
  54. data/spec/support/vcr_localhost_server.rb +4 -3
  55. data/spec/vcr/cassette/reader_spec.rb +4 -4
  56. data/spec/vcr/cassette_spec.rb +28 -28
  57. data/spec/vcr/config_spec.rb +11 -11
  58. data/spec/vcr/deprecations/cassette_spec.rb +4 -4
  59. data/spec/vcr/deprecations/config_spec.rb +2 -2
  60. data/spec/vcr/deprecations/http_stubbing_adapters/fakeweb_spec.rb +1 -1
  61. data/spec/vcr/extensions/net_http_response_spec.rb +3 -3
  62. data/spec/vcr/extensions/net_http_spec.rb +4 -4
  63. data/spec/vcr/http_stubbing_adapters/excon_spec.rb +5 -5
  64. data/spec/vcr/http_stubbing_adapters/faraday_spec.rb +4 -4
  65. data/spec/vcr/http_stubbing_adapters/multi_object_proxy_spec.rb +4 -4
  66. data/spec/vcr/middleware/cassette_arguments_spec.rb +5 -5
  67. data/spec/vcr/middleware/faraday_spec.rb +3 -3
  68. data/spec/vcr/middleware/rack_spec.rb +4 -4
  69. data/spec/vcr/request_matcher_spec.rb +13 -13
  70. data/spec/vcr/structs/http_interaction_spec.rb +6 -6
  71. data/spec/vcr/structs/request_spec.rb +7 -7
  72. data/spec/vcr/structs/response_spec.rb +5 -5
  73. data/spec/vcr/structs/response_status_spec.rb +2 -2
  74. data/spec/vcr/test_frameworks/cucumber_spec.rb +2 -2
  75. data/spec/vcr/test_frameworks/rspec_spec.rb +6 -7
  76. data/spec/vcr/util/hooks_spec.rb +9 -9
  77. data/spec/vcr_spec.rb +11 -17
  78. data/vcr.gemspec +11 -5
  79. metadata +47 -49
  80. data/features/support/aruba_workaround/aruba_patches.rb +0 -36
  81. data/features/support/aruba_workaround/background_process.rb +0 -4
data/lib/vcr.rb CHANGED
@@ -166,4 +166,10 @@ module VCR
166
166
  def cassettes
167
167
  @cassettes ||= []
168
168
  end
169
+
170
+ def initialize_ivars
171
+ @turned_off = false
172
+ end
173
+
174
+ initialize_ivars # to avoid warnings
169
175
  end
data/lib/vcr/config.rb CHANGED
@@ -44,7 +44,7 @@ module VCR
44
44
 
45
45
  def ignore_localhost=(value)
46
46
  if value
47
- ignore_hosts *VCR::LOCALHOST_ALIASES
47
+ ignore_hosts(*VCR::LOCALHOST_ALIASES)
48
48
  else
49
49
  ignored_hosts.reject! { |h| VCR::LOCALHOST_ALIASES.include?(h) }
50
50
  end
@@ -73,6 +73,12 @@ module VCR
73
73
  uri = URI.parse(uri) unless uri.respond_to?(:host)
74
74
  ignored_hosts.include?(uri.host)
75
75
  end
76
+
77
+ def initialize_ivars
78
+ @allow_http_connections_when_no_cassette = nil
79
+ end
80
+
81
+ initialize_ivars # to avoid warnings
76
82
  end
77
83
  end
78
84
 
@@ -5,25 +5,25 @@ module VCR
5
5
  VCR::Config.uri_should_be_ignored?(uri.to_s)
6
6
  end
7
7
 
8
- private
8
+ private
9
9
 
10
- def deprecate_old_cassette_options(options)
11
- message = "VCR's :allow_real_http cassette option is deprecated. Instead, use the ignore_localhost configuration option."
12
- if options[:allow_real_http] == :localhost
13
- @original_ignored_hosts = VCR::Config.ignored_hosts.dup
14
- VCR::Config.ignored_hosts.clear
15
- VCR::Config.ignore_hosts *VCR::LOCALHOST_ALIASES
16
- Kernel.warn "WARNING: #{message}"
17
- elsif options[:allow_real_http]
18
- raise ArgumentError.new(message)
19
- end
10
+ def deprecate_old_cassette_options(options)
11
+ message = "VCR's :allow_real_http cassette option is deprecated. Instead, use the ignore_localhost configuration option."
12
+ if options[:allow_real_http] == :localhost
13
+ @original_ignored_hosts = VCR::Config.ignored_hosts.dup
14
+ VCR::Config.ignored_hosts.clear
15
+ VCR::Config.ignore_hosts(*VCR::LOCALHOST_ALIASES)
16
+ Kernel.warn "WARNING: #{message}"
17
+ elsif options[:allow_real_http]
18
+ raise ArgumentError.new(message)
20
19
  end
20
+ end
21
21
 
22
- def restore_ignore_localhost_for_deprecation
23
- if defined?(@original_ignored_hosts)
24
- VCR::Config.ignored_hosts.clear
25
- VCR::Config.ignore_hosts *@original_ignored_hosts
26
- end
22
+ def restore_ignore_localhost_for_deprecation
23
+ if defined?(@original_ignored_hosts)
24
+ VCR::Config.ignored_hosts.clear
25
+ VCR::Config.ignore_hosts(*@original_ignored_hosts)
27
26
  end
28
27
  end
28
+ end
29
29
  end
@@ -12,6 +12,10 @@
12
12
  module VCR
13
13
  module Net
14
14
  module HTTPResponse
15
+ def self.extended(response)
16
+ response.instance_variable_set(:@__read_body_previously_called, false)
17
+ end
18
+
15
19
  def read_body(dest = nil, &block)
16
20
  return super if @__read_body_previously_called
17
21
  return @body if dest.nil? && block.nil?
@@ -75,7 +75,7 @@ module VCR
75
75
  attr_writer :http_connections_allowed
76
76
 
77
77
  def http_connections_allowed?
78
- !!@http_connections_allowed
78
+ defined?(@http_connections_allowed) && !!@http_connections_allowed
79
79
  end
80
80
 
81
81
  def ignored_hosts=(hosts)
@@ -93,6 +93,12 @@ module VCR
93
93
  raise UnsupportedRequestMatchAttributeError.new("FakeWeb does not support matching requests on #{invalid_attributes.join(' or ')}")
94
94
  end
95
95
  end
96
+
97
+ def initialize_ivars
98
+ @http_connections_allowed = nil
99
+ end
100
+
101
+ initialize_ivars # to avoid warnings
96
102
  end
97
103
  end
98
104
  end
@@ -78,6 +78,12 @@ module VCR
78
78
  def checkpoints
79
79
  @checkpoints ||= {}
80
80
  end
81
+
82
+ def initialize_ivars
83
+ @http_connections_allowed = nil
84
+ end
85
+
86
+ initialize_ivars # to avoid warnings
81
87
  end
82
88
  end
83
89
  end
@@ -107,6 +113,7 @@ WebMock.after_request(:real_requests_only => true) do |request, response|
107
113
  end
108
114
 
109
115
  WebMock::NetConnectNotAllowedError.class_eval do
116
+ undef stubbing_instructions
110
117
  def stubbing_instructions(*args)
111
118
  '. ' + VCR::HttpStubbingAdapters::Common::RECORDING_INSTRUCTIONS
112
119
  end
@@ -2,6 +2,7 @@ module VCR
2
2
  module Middleware
3
3
  class CassetteArguments
4
4
  def initialize
5
+ @name = nil
5
6
  @options = {}
6
7
  end
7
8
 
@@ -10,6 +10,7 @@ module VCR
10
10
  end
11
11
 
12
12
  def ignored?
13
+ @ignored = false unless defined?(@ignored)
13
14
  @ignored
14
15
  end
15
16
 
data/lib/vcr/version.rb CHANGED
@@ -3,7 +3,7 @@ module VCR
3
3
 
4
4
  def version
5
5
  @version ||= begin
6
- string = '1.11.1'
6
+ string = '1.11.2'
7
7
 
8
8
  def string.parts
9
9
  split('.').map { |p| p.to_i }
@@ -0,0 +1,42 @@
1
+ require 'tempfile'
2
+ stderr_file = Tempfile.new("vcr.stderr")
3
+ $stderr.reopen(stderr_file.path)
4
+ current_dir = Dir.pwd
5
+
6
+ at_exit do
7
+ stderr_file.rewind
8
+ lines = stderr_file.read.split("\n").uniq
9
+ stderr_file.close!
10
+
11
+ vcr_warnings, other_warnings = lines.partition { |line| line.include?(current_dir) }
12
+
13
+ # For some weird reason, JRuby is giving me some warnings about
14
+ # `@proxy` not being initialized, and putting a vcr file/line number
15
+ # in the warning, but it's really happening in excon.
16
+ if RUBY_PLATFORM == 'java'
17
+ vcr_warnings.reject! do |line|
18
+ line.include?('@proxy not initialized') && line.include?('excon')
19
+ end
20
+ end
21
+
22
+ if vcr_warnings.any?
23
+ puts
24
+ puts "-" * 30 + " VCR Warnings: " + "-" * 30
25
+ puts
26
+ puts vcr_warnings.join("\n")
27
+ puts
28
+ puts "-" * 75
29
+ puts
30
+ end
31
+
32
+ if other_warnings.any?
33
+ File.open('tmp/warnings.txt', 'w') { |f| f.write(other_warnings.join("\n")) }
34
+ puts
35
+ puts "Non-VCR warnings written to tmp/warnings.txt"
36
+ puts
37
+ end
38
+
39
+ # fail the build...
40
+ exit(1) if vcr_warnings.any?
41
+ end
42
+
@@ -73,7 +73,11 @@ module MonkeyPatches
73
73
  end
74
74
 
75
75
  def realias(klass, method, alias_extension)
76
- klass.class_eval { alias_method method, :"#{method}_#{alias_extension}" }
76
+ klass.class_eval do
77
+ old_verbose, $VERBOSE = $VERBOSE, nil
78
+ alias_method method, :"#{method}_#{alias_extension}"
79
+ $VERBOSE = old_verbose
80
+ end
77
81
  end
78
82
 
79
83
  def realias_all(alias_extension)
data/spec/spec_helper.rb CHANGED
@@ -35,13 +35,14 @@ module VCR
35
35
  VCR.instance_eval do
36
36
  instance_variables.each { |ivar| remove_instance_variable(ivar) }
37
37
  end
38
+ VCR.send(:initialize_ivars)
38
39
  end
39
40
  end
40
41
  end
41
42
 
42
43
  RSpec.configure do |config|
43
44
  config.color_enabled = true
44
- config.debug = (using_git && RUBY_INTERPRETER == :mri && RUBY_VERSION != '1.9.1' && !ENV['CI'])
45
+ config.debug = (using_git && RUBY_INTERPRETER == :mri && !%w[ 1.9.1 1.9.3 ].include?(RUBY_VERSION) && !ENV['CI'])
45
46
  config.treat_symbols_as_metadata_keys_with_true_values = true
46
47
 
47
48
  tmp_dir = File.expand_path('../../tmp/cassette_library_dir', __FILE__)
@@ -49,7 +49,7 @@ shared_examples_for "an http library" do |library, supported_request_match_attri
49
49
  if recorded_val.is_a?(Array) && replayed_val.is_a?(Array)
50
50
  replayed_val.should =~ recorded_val
51
51
  else
52
- replayed_val.should == recorded_val
52
+ replayed_val.should eq(recorded_val)
53
53
  end
54
54
  end
55
55
  end
@@ -72,7 +72,7 @@ shared_examples_for "an http library" do |library, supported_request_match_attri
72
72
  let(:response) { VCR::Response.new(status, nil, response_body, '1.1') }
73
73
 
74
74
  it 'returns the response for a matching request' do
75
- get_body_string(make_http_request(:get, 'http://example.com/')).should == response_body
75
+ get_body_string(make_http_request(:get, 'http://example.com/')).should eq(response_body)
76
76
  end
77
77
  end
78
78
 
@@ -82,7 +82,7 @@ shared_examples_for "an http library" do |library, supported_request_match_attri
82
82
  let(:response) { VCR::Response.new(status, nil, response_body, '1.1') }
83
83
 
84
84
  it 'returns the expected response for the same request' do
85
- get_body_string(make_http_request(:get, url)).should == response_body
85
+ get_body_string(make_http_request(:get, url)).should eq(response_body)
86
86
  end
87
87
  end
88
88
  end
@@ -116,7 +116,7 @@ shared_examples_for "an http library" do |library, supported_request_match_attri
116
116
 
117
117
  valid.each do |val, response|
118
118
  it "returns the expected response for a #{val.inspect} request" do
119
- get_body_string(make_http_request(val)).should == response
119
+ get_body_string(make_http_request(val)).should eq(response)
120
120
  end
121
121
  end
122
122
 
@@ -174,7 +174,7 @@ shared_examples_for "an http library" do |library, supported_request_match_attri
174
174
  if http_allowed
175
175
 
176
176
  it 'allows real http requests' do
177
- get_body_string(make_http_request(:get, url)).should == 'FOO!'
177
+ get_body_string(make_http_request(:get, url)).should eq('FOO!')
178
178
  end
179
179
 
180
180
  describe 'recording new http requests' do
@@ -192,11 +192,11 @@ shared_examples_for "an http library" do |library, supported_request_match_attri
192
192
  end
193
193
 
194
194
  it 'records the request uri' do
195
- recorded_interaction.request.uri.should == url
195
+ recorded_interaction.request.uri.should eq(url)
196
196
  end
197
197
 
198
198
  it 'records the request method' do
199
- recorded_interaction.request.method.should == :get
199
+ recorded_interaction.request.method.should eq(:get)
200
200
  end
201
201
 
202
202
  it 'records the request body' do
@@ -208,19 +208,19 @@ shared_examples_for "an http library" do |library, supported_request_match_attri
208
208
  end
209
209
 
210
210
  it 'records the response status code' do
211
- recorded_interaction.response.status.code.should == 200
211
+ recorded_interaction.response.status.code.should eq(200)
212
212
  end
213
213
 
214
214
  it 'records the response status message' do
215
- recorded_interaction.response.status.message.should == 'OK'
215
+ recorded_interaction.response.status.message.should eq('OK')
216
216
  end unless other.include?(:status_message_not_exposed)
217
217
 
218
218
  it 'records the response body' do
219
- recorded_interaction.response.body.should == 'FOO!'
219
+ recorded_interaction.response.body.should eq('FOO!')
220
220
  end
221
221
 
222
222
  it 'records the response headers' do
223
- recorded_interaction.response.headers['content-type'].should == ["text/html;charset=utf-8"]
223
+ recorded_interaction.response.headers['content-type'].should eq(["text/html;charset=utf-8"])
224
224
  end
225
225
  end
226
226
  else
@@ -234,12 +234,12 @@ shared_examples_for "an http library" do |library, supported_request_match_attri
234
234
  end
235
235
 
236
236
  def test_request_stubbed(method, url, expected)
237
- subject.request_stubbed?(VCR::Request.new(method, url), [:method, :uri]).should == expected
237
+ subject.request_stubbed?(VCR::Request.new(method, url), [:method, :uri]).should eq(expected)
238
238
  end
239
239
 
240
240
  it "returns false from #http_connections_allowed? when http_connections_allowed is set to nil" do
241
241
  subject.http_connections_allowed = nil
242
- subject.http_connections_allowed?.should == false
242
+ subject.http_connections_allowed?.should eq(false)
243
243
  end
244
244
 
245
245
  describe '.restore_stubs_checkpoint' do
@@ -255,7 +255,7 @@ shared_examples_for "an http library" do |library, supported_request_match_attri
255
255
  before(:each) { subject.http_connections_allowed = http_allowed }
256
256
 
257
257
  it "returns #{http_allowed} for #http_connections_allowed?" do
258
- subject.http_connections_allowed?.should == http_allowed
258
+ subject.http_connections_allowed?.should eq(http_allowed)
259
259
  end
260
260
 
261
261
  test_real_http_request(http_allowed, *other)
@@ -273,7 +273,7 @@ shared_examples_for "an http library" do |library, supported_request_match_attri
273
273
 
274
274
  %w[ 127.0.0.1 localhost ].each do |localhost_alias|
275
275
  it "allows requests to #{localhost_alias}" do
276
- get_body_string(make_http_request(:get, "http://#{localhost_alias}:#{VCR::SinatraApp.port}/localhost_test")).should == localhost_response
276
+ get_body_string(make_http_request(:get, "http://#{localhost_alias}:#{VCR::SinatraApp.port}/localhost_test")).should eq(localhost_response)
277
277
  end
278
278
  end
279
279
 
@@ -309,12 +309,12 @@ shared_examples_for "an http library" do |library, supported_request_match_attri
309
309
  end
310
310
 
311
311
  it 'rotates through multiple responses for the same request' do
312
- get_body_string(make_http_request(:get, 'http://example.com/foo')).should == 'example.com get response 1 with path=foo'
313
- get_body_string(make_http_request(:get, 'http://example.com/foo')).should == 'example.com get response 2 with path=foo'
312
+ get_body_string(make_http_request(:get, 'http://example.com/foo')).should eq('example.com get response 1 with path=foo')
313
+ get_body_string(make_http_request(:get, 'http://example.com/foo')).should eq('example.com get response 2 with path=foo')
314
314
 
315
315
  # subsequent requests keep getting the last one
316
- get_body_string(make_http_request(:get, 'http://example.com/foo')).should == 'example.com get response 2 with path=foo'
317
- get_body_string(make_http_request(:get, 'http://example.com/foo')).should == 'example.com get response 2 with path=foo'
316
+ get_body_string(make_http_request(:get, 'http://example.com/foo')).should eq('example.com get response 2 with path=foo')
317
+ get_body_string(make_http_request(:get, 'http://example.com/foo')).should eq('example.com get response 2 with path=foo')
318
318
  end unless other.include?(:does_not_support_rotating_responses)
319
319
 
320
320
  it "correctly handles stubbing multiple values for the same header" do
@@ -27,11 +27,11 @@ shared_examples_for "an http stubbing adapter" do |supported_http_libraries, sup
27
27
  VCR::HttpStubbingAdapters::Common.adapters.each do |adapter|
28
28
  if adapter == described_class
29
29
  it "yields with #{adapter} enabled" do
30
- adapter_enabled?(adapter).should == true
30
+ adapter_enabled?(adapter).should eq(true)
31
31
  end
32
32
  else
33
33
  it "yields without #{adapter} enabled" do
34
- adapter_enabled?(adapter).should == false
34
+ adapter_enabled?(adapter).should eq(false)
35
35
  end
36
36
  end
37
37
  end
@@ -48,14 +48,14 @@ shared_examples_for "an http stubbing adapter" do |supported_http_libraries, sup
48
48
  it 'returns the uri for the given http request' do
49
49
  net_http = Net::HTTP.new('example.com', 80)
50
50
  request = Net::HTTP::Get.new('/foo/bar')
51
- subject.request_uri(net_http, request).should == 'http://example.com:80/foo/bar'
51
+ subject.request_uri(net_http, request).should eq('http://example.com:80/foo/bar')
52
52
  end
53
53
 
54
54
  it 'handles basic auth' do
55
55
  net_http = Net::HTTP.new('example.com',80)
56
56
  request = Net::HTTP::Get.new('/auth.txt')
57
57
  request.basic_auth 'user', 'pass'
58
- subject.request_uri(net_http, request).should == 'http://user:pass@example.com:80/auth.txt'
58
+ subject.request_uri(net_http, request).should eq('http://user:pass@example.com:80/auth.txt')
59
59
  end
60
60
  end
61
61
 
@@ -73,12 +73,12 @@ shared_examples_for "an http stubbing adapter" do |supported_http_libraries, sup
73
73
 
74
74
  [valid1, valid2].each do |val|
75
75
  it "returns true for a #{val.inspect} request" do
76
- subject.request_stubbed?(request(val), [attribute]).should == true
76
+ subject.request_stubbed?(request(val), [attribute]).should eq(true)
77
77
  end
78
78
  end
79
79
 
80
80
  it "returns false for another #{attribute}" do
81
- subject.request_stubbed?(request(invalid), [attribute]).should == false
81
+ subject.request_stubbed?(request(invalid), [attribute]).should eq(false)
82
82
  end
83
83
  else
84
84
  it 'raises an error indicating matching requests on this attribute is not supported' do
@@ -12,7 +12,7 @@ shared_examples_for '.ignore_localhost? deprecation' do
12
12
  it 'returns false when only some localhost aliases are ignored' do
13
13
  aliases = VCR::LOCALHOST_ALIASES.dup
14
14
  aliases.pop
15
- VCR::Config.ignore_hosts *aliases
15
+ VCR::Config.ignore_hosts(*aliases)
16
16
  described_class.ignore_localhost?.should be_false
17
17
  end
18
18
 
@@ -1,13 +1,11 @@
1
- require 'spec_helper'
2
-
3
1
  shared_examples_for "header normalization" do
4
2
  let(:instance) do
5
3
  with_headers('Some_Header' => 'value1', 'aNother' => ['a', 'b'], 'third' => [], 'fourth' => nil)
6
4
  end
7
5
 
8
6
  it 'normalizes the hash to lower case keys and arrays of values' do
9
- instance.headers['some_header'].should == ['value1']
10
- instance.headers['another'].should == ['a', 'b']
7
+ instance.headers['some_header'].should eq(['value1'])
8
+ instance.headers['another'].should eq(['a', 'b'])
11
9
  end
12
10
 
13
11
  it 'removes empty headers' do
@@ -17,7 +15,7 @@ shared_examples_for "header normalization" do
17
15
 
18
16
  it 'filters out unimportant default values set by the HTTP library' do
19
17
  instance = with_headers('accept' => ['*/*'], 'connection' => 'close', 'http-user' => ['foo'], 'expect' => ['', 'bar'])
20
- instance.headers.should == { 'http-user' => ['foo'], 'expect' => ['bar'] }
18
+ instance.headers.should eq({ 'http-user' => ['foo'], 'expect' => ['bar'] })
21
19
  end
22
20
 
23
21
  it 'sets empty hash header to nil' do
@@ -28,26 +26,26 @@ shared_examples_for "header normalization" do
28
26
  key = 'my-key'
29
27
  key.instance_variable_set(:@foo, 7)
30
28
  instance = with_headers(key => ['value1'])
31
- VCR::YAML.dump(instance.headers).should == VCR::YAML.dump('my-key' => ['value1'])
29
+ VCR::YAML.dump(instance.headers).should eq(VCR::YAML.dump('my-key' => ['value1']))
32
30
  end
33
31
 
34
32
  it 'ensures header values are serialized to yaml as raw strings' do
35
33
  value = 'my-value'
36
34
  value.instance_variable_set(:@foo, 7)
37
35
  instance = with_headers('my-key' => [value])
38
- VCR::YAML.dump(instance.headers).should == VCR::YAML.dump('my-key' => ['my-value'])
36
+ VCR::YAML.dump(instance.headers).should eq(VCR::YAML.dump('my-key' => ['my-value']))
39
37
  end
40
38
 
41
39
  it 'handles nested arrays' do
42
40
  accept_encoding = [["gzip", "1.0"], ["deflate", "1.0"], ["sdch", "1.0"]]
43
41
  instance = with_headers('accept-encoding' => accept_encoding)
44
- instance.headers['accept-encoding'].should == accept_encoding
42
+ instance.headers['accept-encoding'].should eq(accept_encoding)
45
43
  end
46
44
 
47
45
  it 'handles nested arrays with floats' do
48
46
  accept_encoding = [["gzip", 1.0], ["deflate", 1.0], ["sdch", 1.0]]
49
47
  instance = with_headers('accept-encoding' => accept_encoding)
50
- instance.headers['accept-encoding'].should == accept_encoding
48
+ instance.headers['accept-encoding'].should eq(accept_encoding)
51
49
  end
52
50
  end
53
51
 
@@ -59,31 +57,31 @@ shared_examples_for "body normalization" do
59
57
  it "ensures the body is serialized to yaml as a raw string" do
60
58
  body = "My String"
61
59
  body.instance_variable_set(:@foo, 7)
62
- VCR::YAML.dump(instance(body).body).should == VCR::YAML.dump("My String")
60
+ VCR::YAML.dump(instance(body).body).should eq(VCR::YAML.dump("My String"))
63
61
  end
64
62
  end
65
63
 
66
64
  shared_examples_for 'uri normalization' do
67
65
  it 'adds port 80 to an http URI that lacks a port' do
68
- instance('http://example.com/foo').uri.should == 'http://example.com:80/foo'
66
+ instance('http://example.com/foo').uri.should eq('http://example.com:80/foo')
69
67
  end
70
68
 
71
69
  it 'keeps the existing port for an http URI' do
72
- instance('http://example.com:8000/foo').uri.should == 'http://example.com:8000/foo'
70
+ instance('http://example.com:8000/foo').uri.should eq('http://example.com:8000/foo')
73
71
  end
74
72
 
75
73
  it 'adds port 443 to an https URI that lacks a port' do
76
- instance('https://example.com/foo').uri.should == 'https://example.com:443/foo'
74
+ instance('https://example.com/foo').uri.should eq('https://example.com:443/foo')
77
75
  end
78
76
 
79
77
  it 'keeps the existing port for an https URI' do
80
- instance('https://example.com:8000/foo').uri.should == 'https://example.com:8000/foo'
78
+ instance('https://example.com:8000/foo').uri.should eq('https://example.com:8000/foo')
81
79
  end
82
80
  end
83
81
 
84
82
  shared_examples_for 'status message normalization' do
85
83
  it 'chomps leading and trailing spaces on the status message' do
86
- instance(' OK ').message.should == 'OK'
84
+ instance(' OK ').message.should eq('OK')
87
85
  end
88
86
 
89
87
  it 'sets status message to nil when it is the empty string' do