aboutsummaryrefslogtreecommitdiffstats
path: root/test/nodes/test_sql_literal.rb
diff options
context:
space:
mode:
authorErnie Miller <ernie@metautonomo.us>2010-10-27 21:43:20 +0800
committerAaron Patterson <aaron.patterson@gmail.com>2010-10-27 22:34:04 +0800
commit01e7ceef453e3dc976dc0d12002bb6d4a66f1252 (patch)
treee5acf86795ae6d36d2d489aca79ce66f2f142851 /test/nodes/test_sql_literal.rb
parentf515283f5190096cd3b1cfe0312c723cdeb542c1 (diff)
downloadrails-01e7ceef453e3dc976dc0d12002bb6d4a66f1252.tar.gz
rails-01e7ceef453e3dc976dc0d12002bb6d4a66f1252.tar.bz2
rails-01e7ceef453e3dc976dc0d12002bb6d4a66f1252.zip
Refactor predication methods to be available to SqlLiterals as well.
Diffstat (limited to 'test/nodes/test_sql_literal.rb')
-rw-r--r--test/nodes/test_sql_literal.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/nodes/test_sql_literal.rb b/test/nodes/test_sql_literal.rb
index 5cf91cef0c..d280d6d928 100644
--- a/test/nodes/test_sql_literal.rb
+++ b/test/nodes/test_sql_literal.rb
@@ -23,6 +23,30 @@ module Arel
viz.accept(node).must_be_like %{ COUNT(DISTINCT *) }
end
end
+
+ describe 'equality' do
+ it 'makes an equality node' do
+ node = SqlLiteral.new('foo').eq(1)
+ viz = Visitors::ToSql.new Table.engine
+ viz.accept(node).must_be_like %{ foo = 1 }
+ end
+ end
+
+ describe 'grouped "or" equality' do
+ it 'makes a grouping node with an or node' do
+ node = SqlLiteral.new('foo').eq_any([1,2])
+ viz = Visitors::ToSql.new Table.engine
+ viz.accept(node).must_be_like %{ (foo = 1 OR foo = 2) }
+ end
+ end
+
+ describe 'grouped "and" equality' do
+ it 'makes a grouping node with an or node' do
+ node = SqlLiteral.new('foo').eq_all([1,2])
+ viz = Visitors::ToSql.new Table.engine
+ viz.accept(node).must_be_like %{ (foo = 1 AND foo = 2) }
+ end
+ end
end
end
end