我不确定如何使以下测试用例通过。我将 source 用于 union (|) 和内部 list.include?(source)
class Source
# mongoid object code...
def hash
url.hash
end
def ==(other)
eql?(other)
end
def eql?(other_source)
url = self.url and other_source and url == other_source.url
end
end
测试用例:
ext1 = Source.new
ext2 = Source.new(url: "test")
(ext2.== ext1).should == false # false
(ext1.== ext2).should == false # is returning nil instead of false
我想让最后一个案例返回 false 而不是 nil 但不知道如何让这种情况发生?