Sha256: 5ba9f176631dd4b5ce88cc4bd9df089be0dc1bf434254715d010623239b93054

Contents?: true

Size: 828 Bytes

Versions: 52

Compression:

Stored size: 828 Bytes

Contents

require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../fixtures/classes.rb', __FILE__)
require File.expand_path('../shared/equal_value.rb', __FILE__)

describe "String#==" do
  it_behaves_like(:string_equal_value, :==)
end

describe "String#==" do
  it "returns false if obj does not respond to to_str" do
    ('hello' == 5).should == false
    ('hello' == :hello).should == false
    ('hello' == mock('x')).should == false
  end

  it "returns obj == self if obj responds to to_str" do
    obj = Object.new

    # String#== merely checks if #to_str is defined. It does
    # not call it.
    obj.stub!(:to_str)

    obj.should_receive(:==).and_return(true)

    ('hello' == obj).should ==  true
  end

  it "is not fooled by NUL characters" do
    "abc\0def".should_not == "abc\0xyz"
  end
end

Version data entries

52 entries across 52 versions & 2 rubygems

Version Path
rhodes-7.6.0 spec/framework_spec/app/spec/core/string/equal_value_spec.rb
rhodes-7.5.1 spec/framework_spec/app/spec/core/string/equal_value_spec.rb
rhodes-7.4.1 spec/framework_spec/app/spec/core/string/equal_value_spec.rb
rhodes-7.1.17 spec/framework_spec/app/spec/core/string/equal_value_spec.rb
rhodes-6.2.0 spec/framework_spec/app/spec/core/string/equal_value_spec.rb
rhodes-6.0.11 spec/framework_spec/app/spec/core/string/equal_value_spec.rb
rhodes-5.5.18 spec/framework_spec/app/spec/core/string/equal_value_spec.rb
rhodes-5.5.17 spec/framework_spec/app/spec/core/string/equal_value_spec.rb
rhodes-5.5.15 spec/framework_spec/app/spec/core/string/equal_value_spec.rb
rhodes-5.5.0.22 spec/framework_spec/app/spec/core/string/equal_value_spec.rb
rhodes-5.5.2 spec/framework_spec/app/spec/core/string/equal_value_spec.rb
rhodes-5.5.0.7 spec/framework_spec/app/spec/core/string/equal_value_spec.rb
rhodes-5.5.0.3 spec/framework_spec/app/spec/core/string/equal_value_spec.rb
rhodes-5.5.0 spec/framework_spec/app/spec/core/string/equal_value_spec.rb
tauplatform-1.0.3 spec/framework_spec/app/spec/core/string/equal_value_spec.rb
tauplatform-1.0.2 spec/framework_spec/app/spec/core/string/equal_value_spec.rb
tauplatform-1.0.1 spec/framework_spec/app/spec/core/string/equal_value_spec.rb
rhodes-3.5.1.12 spec/framework_spec/app/spec/core/string/equal_value_spec.rb
rhodes-3.3.5 spec/framework_spec/app/spec/core/string/equal_value_spec.rb
rhodes-3.4.2 spec/framework_spec/app/spec/core/string/equal_value_spec.rb