Skip to content

Commit

Permalink
Showing 2 changed files with 19 additions and 0 deletions.
15 changes: 15 additions & 0 deletions spec/ruby/core/comparable/equal_value_spec.rb
Original file line number Diff line number Diff line change
@@ -107,4 +107,19 @@
lambda { (a == b) }.should raise_error(Exception)
end
end

context "when #<=> is not defined" do
before :each do
@a = ComparableSpecs::WithoutEqualDefined.new
@b = ComparableSpecs::WithoutEqualDefined.new
end

it "returns true for identical objects" do
@a.should == @a
end

it "returns false and does not recurse infinitely" do
@a.should_not == @b
end
end
end
4 changes: 4 additions & 0 deletions spec/ruby/core/comparable/fixtures/classes.rb
Original file line number Diff line number Diff line change
@@ -12,4 +12,8 @@ def <=>(other)
self.value <=> other.value
end
end

class WithoutEqualDefined
include Comparable
end
end

0 comments on commit b0f1841

Please sign in to comment.