Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

ruby hash comparison uses #eql? for equality check

  • Loading branch information...
commit b8e4f430c8dad209c719eee75c621bee68e015f5 1 parent 208c7c9
@bjornblomqvist bjornblomqvist authored
Showing with 13 additions and 0 deletions.
  1. +4 −0 lib/plucky/extensions/symbol.rb
  2. +9 −0 spec/symbol_operator_spec.rb
View
4 lib/plucky/extensions/symbol.rb
@@ -77,6 +77,10 @@ def <=>(other)
def hash
field.hash + operator.hash
end
+
+ def eql?(other)
+ self == other
+ end
def ==(other)
other.class == self.class && field == other.field && operator == other.operator
View
9 spec/symbol_operator_spec.rb
@@ -43,6 +43,15 @@
end
+ context 'eql?' do
+
+ it 'uses #== for equality comparison' do
+ subject.should_receive(:"==").with("dummy_value")
+ subject.eql?("dummy_value")
+ end
+
+ end
+
context "<=>" do
it "returns string comparison of operator for same field, different operator" do
(SymbolOperator.new(:foo, 'in') <=> SymbolOperator.new(:foo, 'all')).should == 1
Please sign in to comment.
Something went wrong with that request. Please try again.