aboutsummaryrefslogtreecommitdiffstats
path: root/test/nodes/test_sql_literal.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2014-04-08 21:26:50 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2014-04-08 21:28:51 -0700
commit307f89312353d1360ee547468ebaaf8791889d71 (patch)
tree71805db4cbec87c07bf8e9f203caa1ee510fae0b /test/nodes/test_sql_literal.rb
parent59b1d98a5f6268bee661a411f06b285fdb292a47 (diff)
downloadrails-307f89312353d1360ee547468ebaaf8791889d71.tar.gz
rails-307f89312353d1360ee547468ebaaf8791889d71.tar.bz2
rails-307f89312353d1360ee547468ebaaf8791889d71.zip
fixing sql_literal tests
Diffstat (limited to 'test/nodes/test_sql_literal.rb')
-rw-r--r--test/nodes/test_sql_literal.rb14
1 files changed, 9 insertions, 5 deletions
diff --git a/test/nodes/test_sql_literal.rb b/test/nodes/test_sql_literal.rb
index 2f17cfd72a..ed602cc47d 100644
--- a/test/nodes/test_sql_literal.rb
+++ b/test/nodes/test_sql_literal.rb
@@ -8,6 +8,10 @@ module Arel
@visitor = Visitors::ToSql.new Table.engine.connection
end
+ def compile node
+ @visitor.accept(node, Collectors::SQLString.new).value
+ end
+
describe 'sql' do
it 'makes a sql literal node' do
sql = Arel.sql 'foo'
@@ -18,19 +22,19 @@ module Arel
describe 'count' do
it 'makes a count node' do
node = SqlLiteral.new('*').count
- @visitor.accept(node).must_be_like %{ COUNT(*) }
+ compile(node).must_be_like %{ COUNT(*) }
end
it 'makes a distinct node' do
node = SqlLiteral.new('*').count true
- @visitor.accept(node).must_be_like %{ COUNT(DISTINCT *) }
+ compile(node).must_be_like %{ COUNT(DISTINCT *) }
end
end
describe 'equality' do
it 'makes an equality node' do
node = SqlLiteral.new('foo').eq(1)
- @visitor.accept(node).must_be_like %{ foo = 1 }
+ compile(node).must_be_like %{ foo = 1 }
end
it 'is equal with equal contents' do
@@ -47,14 +51,14 @@ module Arel
describe 'grouped "or" equality' do
it 'makes a grouping node with an or node' do
node = SqlLiteral.new('foo').eq_any([1,2])
- @visitor.accept(node).must_be_like %{ (foo = 1 OR foo = 2) }
+ compile(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])
- @visitor.accept(node).must_be_like %{ (foo = 1 AND foo = 2) }
+ compile(node).must_be_like %{ (foo = 1 AND foo = 2) }
end
end