Permalink
Browse files

Merge pull request #16 from Oktavilla/symbol-operator-comparability

Symbol operator comparability
  • Loading branch information...
2 parents 8b52b96 + f71d298 commit 008c7feb20ed65de4c72aed0b81be1dc94afc28b @bkeepers bkeepers committed Sep 14, 2011
Showing with 10 additions and 4 deletions.
  1. +1 −1 lib/plucky/extensions/symbol.rb
  2. +9 −3 test/test_symbol_operator.rb
@@ -75,7 +75,7 @@ def <=>(other)
end
def ==(other)
- field == other.field && operator == other.operator
+ other.class == self.class && field == other.field && operator == other.operator
end
end
@@ -17,18 +17,24 @@ class SymbolOperatorTest < Test::Unit::TestCase
should "be true if field and operator are equal" do
SymbolOperator.new(:foo, 'in').should == SymbolOperator.new(:foo, 'in')
end
-
+
should "be false if fields are equal but operators are not" do
SymbolOperator.new(:foo, 'in').should_not == SymbolOperator.new(:foo, 'all')
end
-
+
should "be false if operators are equal but fields are not" do
SymbolOperator.new(:foo, 'in').should_not == SymbolOperator.new(:bar, 'in')
end
-
+
should "be false if neither are equal" do
SymbolOperator.new(:foo, 'in').should_not == SymbolOperator.new(:bar, 'all')
end
+
+ should "be false if other isn't an symbol operator" do
+ assert_nothing_raised do
+ SymbolOperator.new(:foo, 'in').should_not == 'foo.in'
+ end
+ end
end
context "<=>" do

0 comments on commit 008c7fe

Please sign in to comment.