Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #32 from bjornblomqvist/rspec_query_equality_fix

Rspec query equality fix
  • Loading branch information...
commit 593582b03daf59673e28bb6cb847f40e2af8b0eb 2 parents 6fd55a6 + b8e4f43
@jnunemaker jnunemaker authored
Showing with 26 additions and 1 deletion.
  1. +8 −0 lib/plucky/extensions/symbol.rb
  2. +18 −1 spec/symbol_operator_spec.rb
View
8 lib/plucky/extensions/symbol.rb
@@ -73,6 +73,14 @@ def <=>(other)
field.to_s <=> other.field.to_s
end
end
+
+ 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
19 spec/symbol_operator_spec.rb
@@ -34,7 +34,24 @@
SymbolOperator.new(:foo, 'in').should_not == 'foo.in'
end
end
-
+
+ context "hash" do
+
+ it 'returns sum of operator and hash field' do
+ SymbolOperator.new(:foo, 'in').hash.should == :foo.hash + 'in'.hash
+ end
+
+ 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.