aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorSean Griffin <sean@seantheprogrammer.com>2014-10-24 17:03:14 -0500
committerSean Griffin <sean@seantheprogrammer.com>2014-10-24 17:03:14 -0500
commit9911ff53c9f94cb6852c28791a06b5cd10e49f6f (patch)
treedbb13a31bc2e9c523066e50a4833b0ee728d218c /test
parent0e6c7e6de73fdddaf7f1486657f4d9f8e8f5fde3 (diff)
parent0c99711a1564bf1cb213b35142a3c05feddef0bd (diff)
downloadrails-9911ff53c9f94cb6852c28791a06b5cd10e49f6f.tar.gz
rails-9911ff53c9f94cb6852c28791a06b5cd10e49f6f.tar.bz2
rails-9911ff53c9f94cb6852c28791a06b5cd10e49f6f.zip
Merge pull request #330 from sgrif/sg-binary-node-hash-equality
Binary nodes should not generate the same hash as nodes of other classes
Diffstat (limited to 'test')
-rw-r--r--test/nodes/test_binary.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/nodes/test_binary.rb b/test/nodes/test_binary.rb
new file mode 100644
index 0000000000..7e25a21151
--- /dev/null
+++ b/test/nodes/test_binary.rb
@@ -0,0 +1,26 @@
+require 'helper'
+require 'set'
+
+module Arel
+ module Nodes
+ describe 'Binary' do
+ describe '#hash' do
+ it 'generates a hash based on its value' do
+ eq = Equality.new('foo', 'bar')
+ eq2 = Equality.new('foo', 'bar')
+ eq3 = Equality.new('bar', 'baz')
+
+ assert_equal eq.hash, eq2.hash
+ refute_equal eq.hash, eq3.hash
+ end
+
+ it 'generates a hash specific to its class' do
+ eq = Equality.new('foo', 'bar')
+ neq = NotEqual.new('foo', 'bar')
+
+ refute_equal eq.hash, neq.hash
+ end
+ end
+ end
+ end
+end