diff options
Diffstat (limited to 'test/nodes')
-rw-r--r-- | test/nodes/test_bin.rb | 4 | ||||
-rw-r--r-- | test/nodes/test_select_core.rb | 2 | ||||
-rw-r--r-- | test/nodes/test_sql_literal.rb | 19 |
3 files changed, 12 insertions, 13 deletions
diff --git a/test/nodes/test_bin.rb b/test/nodes/test_bin.rb index b06aeb0b0d..7f123eab13 100644 --- a/test/nodes/test_bin.rb +++ b/test/nodes/test_bin.rb @@ -8,13 +8,13 @@ module Arel end def test_default_to_sql - viz = Arel::Visitors::ToSql.new Table.engine + viz = Arel::Visitors::ToSql.new Table.engine.connection_pool node = Arel::Nodes::Bin.new(Arel.sql('zomg')) assert_equal 'zomg', viz.accept(node) end def test_mysql_to_sql - viz = Arel::Visitors::MySQL.new Table.engine + viz = Arel::Visitors::MySQL.new Table.engine.connection_pool node = Arel::Nodes::Bin.new(Arel.sql('zomg')) assert_equal 'BINARY zomg', viz.accept(node) end diff --git a/test/nodes/test_select_core.rb b/test/nodes/test_select_core.rb index 47f85aee8a..4382c79865 100644 --- a/test/nodes/test_select_core.rb +++ b/test/nodes/test_select_core.rb @@ -23,7 +23,7 @@ module Arel def test_set_quantifier core = Arel::Nodes::SelectCore.new core.set_quantifier = Arel::Nodes::Distinct.new - viz = Arel::Visitors::ToSql.new Table.engine + viz = Arel::Visitors::ToSql.new Table.engine.connection_pool assert_match 'DISTINCT', viz.accept(core) end end 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 |