次のテスト ケースをパスする方法がわかりません。ユニオン (|) と 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
最後のケースで nil ではなく false を返すようにしたいのですが、これを実現する方法がわかりません。