aboutsummaryrefslogtreecommitdiffstats
path: root/test/nodes/test_sql_literal.rb
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2011-08-08 23:23:51 +0100
committerJon Leighton <j@jonathanleighton.com>2011-08-08 23:23:51 +0100
commit79411322ae225289e1c051f4f68ed84c6349e4a0 (patch)
tree424499366dc9c7ced8a271756b86a865ce17c977 /test/nodes/test_sql_literal.rb
parent03b6ca269ac8dfec8f70f2b98439d45b873f9e97 (diff)
downloadrails-79411322ae225289e1c051f4f68ed84c6349e4a0.tar.gz
rails-79411322ae225289e1c051f4f68ed84c6349e4a0.tar.bz2
rails-79411322ae225289e1c051f4f68ed84c6349e4a0.zip
Make it the responsibility of the connection to hold on to a visitor for generating SQL, rather than the TreeManager. (There is a related commit coming in Active Record.)
Diffstat (limited to 'test/nodes/test_sql_literal.rb')
-rw-r--r--test/nodes/test_sql_literal.rb19
1 files changed, 9 insertions, 10 deletions
diff --git a/test/nodes/test_sql_literal.rb b/test/nodes/test_sql_literal.rb
index d280d6d928..54d1d4417f 100644
--- a/test/nodes/test_sql_literal.rb
+++ b/test/nodes/test_sql_literal.rb
@@ -3,6 +3,10 @@ require 'helper'
module Arel
module Nodes
describe 'sql literal' do
+ before do
+ @visitor = Visitors::ToSql.new Table.engine.connection_pool
+ end
+
describe 'sql' do
it 'makes a sql literal node' do
sql = Arel.sql 'foo'
@@ -13,38 +17,33 @@ module Arel
describe 'count' do
it 'makes a count node' do
node = SqlLiteral.new('*').count
- viz = Visitors::ToSql.new Table.engine
- viz.accept(node).must_be_like %{ COUNT(*) }
+ @visitor.accept(node).must_be_like %{ COUNT(*) }
end
it 'makes a distinct node' do
node = SqlLiteral.new('*').count true
- viz = Visitors::ToSql.new Table.engine
- viz.accept(node).must_be_like %{ COUNT(DISTINCT *) }
+ @visitor.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 }
+ @visitor.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) }
+ @visitor.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) }
+ @visitor.accept(node).must_be_like %{ (foo = 1 AND foo = 2) }
end
end
end