Skip to content

Commit

Permalink
Use "should eq(...)" instead of "should ==" to avoid ruby warning.
Browse files Browse the repository at this point in the history
  • Loading branch information
myronmarston committed Aug 26, 2011
1 parent 1dcba45 commit 8fc0f6e
Show file tree
Hide file tree
Showing 27 changed files with 173 additions and 165 deletions.
8 changes: 8 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,11 @@ task :release => [:require_ruby_18, :prep_relish_release, :relish]

# For gem-test: http://gem-testers.org/
task :test => :spec

task :fix_should_eq do
Dir["spec/**/*.rb"].each do |spec_file|
contents = File.read(spec_file)
contents.gsub!(/should == (.*)$/, 'should eq(\1)')
File.open(spec_file, 'w') { |f| f.write(contents) }
end
end
38 changes: 19 additions & 19 deletions spec/support/shared_example_groups/http_library.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
if recorded_val.is_a?(Array) && replayed_val.is_a?(Array)
replayed_val.should =~ recorded_val
else
replayed_val.should == recorded_val
replayed_val.should eq(recorded_val)
end
end
end
Expand All @@ -72,7 +72,7 @@
let(:response) { VCR::Response.new(status, nil, response_body, '1.1') }

it 'returns the response for a matching request' do
get_body_string(make_http_request(:get, 'http://example.com/')).should == response_body
get_body_string(make_http_request(:get, 'http://example.com/')).should eq(response_body)
end
end

Expand All @@ -82,7 +82,7 @@ def self.test_url(description, url)
let(:response) { VCR::Response.new(status, nil, response_body, '1.1') }

it 'returns the expected response for the same request' do
get_body_string(make_http_request(:get, url)).should == response_body
get_body_string(make_http_request(:get, url)).should eq(response_body)
end
end
end
Expand Down Expand Up @@ -116,7 +116,7 @@ def self.matching_on(attribute, valid, invalid, &block)

valid.each do |val, response|
it "returns the expected response for a #{val.inspect} request" do
get_body_string(make_http_request(val)).should == response
get_body_string(make_http_request(val)).should eq(response)
end
end

Expand Down Expand Up @@ -174,7 +174,7 @@ def self.test_real_http_request(http_allowed, *other)
if http_allowed

it 'allows real http requests' do
get_body_string(make_http_request(:get, url)).should == 'FOO!'
get_body_string(make_http_request(:get, url)).should eq('FOO!')
end

describe 'recording new http requests' do
Expand All @@ -192,11 +192,11 @@ def self.test_real_http_request(http_allowed, *other)
end

it 'records the request uri' do
recorded_interaction.request.uri.should == url
recorded_interaction.request.uri.should eq(url)
end

it 'records the request method' do
recorded_interaction.request.method.should == :get
recorded_interaction.request.method.should eq(:get)
end

it 'records the request body' do
Expand All @@ -208,19 +208,19 @@ def self.test_real_http_request(http_allowed, *other)
end

it 'records the response status code' do
recorded_interaction.response.status.code.should == 200
recorded_interaction.response.status.code.should eq(200)
end

it 'records the response status message' do
recorded_interaction.response.status.message.should == 'OK'
recorded_interaction.response.status.message.should eq('OK')
end unless other.include?(:status_message_not_exposed)

it 'records the response body' do
recorded_interaction.response.body.should == 'FOO!'
recorded_interaction.response.body.should eq('FOO!')
end

it 'records the response headers' do
recorded_interaction.response.headers['content-type'].should == ["text/html;charset=utf-8"]
recorded_interaction.response.headers['content-type'].should eq(["text/html;charset=utf-8"])
end
end
else
Expand All @@ -234,12 +234,12 @@ def self.test_real_http_request(http_allowed, *other)
end

def test_request_stubbed(method, url, expected)
subject.request_stubbed?(VCR::Request.new(method, url), [:method, :uri]).should == expected
subject.request_stubbed?(VCR::Request.new(method, url), [:method, :uri]).should eq(expected)
end

it "returns false from #http_connections_allowed? when http_connections_allowed is set to nil" do
subject.http_connections_allowed = nil
subject.http_connections_allowed?.should == false
subject.http_connections_allowed?.should eq(false)
end

describe '.restore_stubs_checkpoint' do
Expand All @@ -255,7 +255,7 @@ def test_request_stubbed(method, url, expected)
before(:each) { subject.http_connections_allowed = http_allowed }

it "returns #{http_allowed} for #http_connections_allowed?" do
subject.http_connections_allowed?.should == http_allowed
subject.http_connections_allowed?.should eq(http_allowed)
end

test_real_http_request(http_allowed, *other)
Expand All @@ -273,7 +273,7 @@ def test_request_stubbed(method, url, expected)

%w[ 127.0.0.1 localhost ].each do |localhost_alias|
it "allows requests to #{localhost_alias}" do
get_body_string(make_http_request(:get, "http://#{localhost_alias}:#{VCR::SinatraApp.port}/localhost_test")).should == localhost_response
get_body_string(make_http_request(:get, "http://#{localhost_alias}:#{VCR::SinatraApp.port}/localhost_test")).should eq(localhost_response)
end
end

Expand Down Expand Up @@ -309,12 +309,12 @@ def test_request_stubbed(method, url, expected)
end

it 'rotates through multiple responses for the same request' do
get_body_string(make_http_request(:get, 'http://example.com/foo')).should == 'example.com get response 1 with path=foo'
get_body_string(make_http_request(:get, 'http://example.com/foo')).should == 'example.com get response 2 with path=foo'
get_body_string(make_http_request(:get, 'http://example.com/foo')).should eq('example.com get response 1 with path=foo')
get_body_string(make_http_request(:get, 'http://example.com/foo')).should eq('example.com get response 2 with path=foo')

# subsequent requests keep getting the last one
get_body_string(make_http_request(:get, 'http://example.com/foo')).should == 'example.com get response 2 with path=foo'
get_body_string(make_http_request(:get, 'http://example.com/foo')).should == 'example.com get response 2 with path=foo'
get_body_string(make_http_request(:get, 'http://example.com/foo')).should eq('example.com get response 2 with path=foo')
get_body_string(make_http_request(:get, 'http://example.com/foo')).should eq('example.com get response 2 with path=foo')
end unless other.include?(:does_not_support_rotating_responses)

it "correctly handles stubbing multiple values for the same header" do
Expand Down
12 changes: 6 additions & 6 deletions spec/support/shared_example_groups/http_stubbing_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ def adapter_enabled?(adapter)
VCR::HttpStubbingAdapters::Common.adapters.each do |adapter|
if adapter == described_class
it "yields with #{adapter} enabled" do
adapter_enabled?(adapter).should == true
adapter_enabled?(adapter).should eq(true)
end
else
it "yields without #{adapter} enabled" do
adapter_enabled?(adapter).should == false
adapter_enabled?(adapter).should eq(false)
end
end
end
Expand All @@ -48,14 +48,14 @@ def adapter_enabled?(adapter)
it 'returns the uri for the given http request' do
net_http = Net::HTTP.new('example.com', 80)
request = Net::HTTP::Get.new('/foo/bar')
subject.request_uri(net_http, request).should == 'http://example.com:80/foo/bar'
subject.request_uri(net_http, request).should eq('http://example.com:80/foo/bar')
end

it 'handles basic auth' do
net_http = Net::HTTP.new('example.com',80)
request = Net::HTTP::Get.new('/auth.txt')
request.basic_auth 'user', 'pass'
subject.request_uri(net_http, request).should == 'http://user:[email protected]:80/auth.txt'
subject.request_uri(net_http, request).should eq('http://user:[email protected]:80/auth.txt')
end
end

Expand All @@ -73,12 +73,12 @@ def self.matching_on(attribute, valid1, valid2, invalid, &block)

[valid1, valid2].each do |val|
it "returns true for a #{val.inspect} request" do
subject.request_stubbed?(request(val), [attribute]).should == true
subject.request_stubbed?(request(val), [attribute]).should eq(true)
end
end

it "returns false for another #{attribute}" do
subject.request_stubbed?(request(invalid), [attribute]).should == false
subject.request_stubbed?(request(invalid), [attribute]).should eq(false)
end
else
it 'raises an error indicating matching requests on this attribute is not supported' do
Expand Down
26 changes: 13 additions & 13 deletions spec/support/shared_example_groups/normalizers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
end

it 'normalizes the hash to lower case keys and arrays of values' do
instance.headers['some_header'].should == ['value1']
instance.headers['another'].should == ['a', 'b']
instance.headers['some_header'].should eq(['value1'])
instance.headers['another'].should eq(['a', 'b'])
end

it 'removes empty headers' do
Expand All @@ -17,7 +17,7 @@

it 'filters out unimportant default values set by the HTTP library' do
instance = with_headers('accept' => ['*/*'], 'connection' => 'close', 'http-user' => ['foo'], 'expect' => ['', 'bar'])
instance.headers.should == { 'http-user' => ['foo'], 'expect' => ['bar'] }
instance.headers.should eq({ 'http-user' => ['foo'], 'expect' => ['bar'] })
end

it 'sets empty hash header to nil' do
Expand All @@ -28,26 +28,26 @@
key = 'my-key'
key.instance_variable_set(:@foo, 7)
instance = with_headers(key => ['value1'])
VCR::YAML.dump(instance.headers).should == VCR::YAML.dump('my-key' => ['value1'])
VCR::YAML.dump(instance.headers).should eq(VCR::YAML.dump('my-key' => ['value1']))
end

it 'ensures header values are serialized to yaml as raw strings' do
value = 'my-value'
value.instance_variable_set(:@foo, 7)
instance = with_headers('my-key' => [value])
VCR::YAML.dump(instance.headers).should == VCR::YAML.dump('my-key' => ['my-value'])
VCR::YAML.dump(instance.headers).should eq(VCR::YAML.dump('my-key' => ['my-value']))
end

it 'handles nested arrays' do
accept_encoding = [["gzip", "1.0"], ["deflate", "1.0"], ["sdch", "1.0"]]
instance = with_headers('accept-encoding' => accept_encoding)
instance.headers['accept-encoding'].should == accept_encoding
instance.headers['accept-encoding'].should eq(accept_encoding)
end

it 'handles nested arrays with floats' do
accept_encoding = [["gzip", 1.0], ["deflate", 1.0], ["sdch", 1.0]]
instance = with_headers('accept-encoding' => accept_encoding)
instance.headers['accept-encoding'].should == accept_encoding
instance.headers['accept-encoding'].should eq(accept_encoding)
end
end

Expand All @@ -59,31 +59,31 @@
it "ensures the body is serialized to yaml as a raw string" do
body = "My String"
body.instance_variable_set(:@foo, 7)
VCR::YAML.dump(instance(body).body).should == VCR::YAML.dump("My String")
VCR::YAML.dump(instance(body).body).should eq(VCR::YAML.dump("My String"))
end
end

shared_examples_for 'uri normalization' do
it 'adds port 80 to an http URI that lacks a port' do
instance('http://example.com/foo').uri.should == 'http://example.com:80/foo'
instance('http://example.com/foo').uri.should eq('http://example.com:80/foo')
end

it 'keeps the existing port for an http URI' do
instance('http://example.com:8000/foo').uri.should == 'http://example.com:8000/foo'
instance('http://example.com:8000/foo').uri.should eq('http://example.com:8000/foo')
end

it 'adds port 443 to an https URI that lacks a port' do
instance('https://example.com/foo').uri.should == 'https://example.com:443/foo'
instance('https://example.com/foo').uri.should eq('https://example.com:443/foo')
end

it 'keeps the existing port for an https URI' do
instance('https://example.com:8000/foo').uri.should == 'https://example.com:8000/foo'
instance('https://example.com:8000/foo').uri.should eq('https://example.com:8000/foo')
end
end

shared_examples_for 'status message normalization' do
it 'chomps leading and trailing spaces on the status message' do
instance(' OK ').message.should == 'OK'
instance(' OK ').message.should eq('OK')
end

it 'sets status message to nil when it is the empty string' do
Expand Down
8 changes: 4 additions & 4 deletions spec/vcr/cassette/reader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ def read(*args)

context 'when ERB is disabled' do
it 'reads the raw file content' do
read('no_vars', false).should == no_vars_content
read('no_vars', nil).should == no_vars_content
read('no_vars', false).should eq(no_vars_content)
read('no_vars', nil).should eq(no_vars_content)
end
end

context 'when ERB is enabled but no variables are passed' do
it 'renders the file content as ERB' do
read('no_vars', true).should == "7. Some ERB"
read('no_vars', true).should eq("7. Some ERB")
end

it 'raises an appropriate error when the ERB template needs variables' do
Expand All @@ -43,7 +43,7 @@ def read(*args)

context 'when ERB is enabled and variables are passed' do
it 'renders the file content as ERB with the passed variables' do
read('vars', :var1 => 'foo', :var2 => 'bar').should == 'foo. ERB with Vars! bar'
read('vars', :var1 => 'foo', :var2 => 'bar').should eq('foo. ERB with Vars! bar')
end

it 'raises an appropriate error when one or more of the needed variables are not passed' do
Expand Down
Loading

0 comments on commit 8fc0f6e

Please sign in to comment.