Skip to content

Commit

Permalink
Add specs for String#{eql?,===,==}
Browse files Browse the repository at this point in the history
  • Loading branch information
ryoqun committed Jun 14, 2013
1 parent bcce70c commit 3456bc7
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion spec/ruby/core/string/shared/eql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,25 @@
"less".send(@method, "greater").should be_false
end

ruby_version_is "1.9" do
it "ignores encoding difference of compatible string" do
"hello".force_encoding("utf-8").send(@method, "hello".force_encoding("iso-8859-1")).should be_true
end

it "considers encoding difference of incompatible string" do
"\xff".force_encoding("utf-8").send(@method, "\xff".force_encoding("iso-8859-1")).should be_false
end

it "considers encoding compatibility" do
"hello".force_encoding("utf-8").send(@method, "hello".force_encoding("utf-32le")).should be_false
end
end

it "ignores subclass differences" do
a = "hello"
b = StringSpecs::MyString.new("hello")

a.send(@method, b).should be_true
b.send(@method, a).should be_true
end
end
end

0 comments on commit 3456bc7

Please sign in to comment.