We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c2ae3fe commit 6be82fbCopy full SHA for 6be82fb
lib/mongoid/equality.rb
@@ -18,6 +18,7 @@ module Equality
18
#
19
# @return [ Integer ] -1, 0, 1.
20
def <=>(other)
21
+ return super unless other.is_a?(Mongoid::Equality)
22
attributes["_id"].to_s <=> other.attributes["_id"].to_s
23
end
24
spec/mongoid/equality_spec.rb
@@ -189,6 +189,12 @@
189
it "compares based on the document id" do
190
expect(first <=> second).to eq(-1)
191
192
+
193
+ it "doesn't break if one isn't a document" do
194
+ expect do
195
+ first <=> "Foo"
196
+ end.to_not raise_error
197
+ end
198
199
200
describe "#eql?" do
0 commit comments