diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-04-08 12:03:52 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-04-08 12:03:52 -0700 |
commit | 05b5bb12270b32e094c1c879273e0978dabe5b3b (patch) | |
tree | 24a09e4abc6bdb10e62626577e3c024c10707a19 /test/visitors | |
parent | df52f7ca2ffe1dd4fb8e65db352c7bcaacfea1a5 (diff) | |
download | rails-05b5bb12270b32e094c1c879273e0978dabe5b3b.tar.gz rails-05b5bb12270b32e094c1c879273e0978dabe5b3b.tar.bz2 rails-05b5bb12270b32e094c1c879273e0978dabe5b3b.zip |
bind visitor working with collector object
Diffstat (limited to 'test/visitors')
-rw-r--r-- | test/visitors/test_bind_visitor.rb | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/test/visitors/test_bind_visitor.rb b/test/visitors/test_bind_visitor.rb index 2bfd03c861..4563fddfd1 100644 --- a/test/visitors/test_bind_visitor.rb +++ b/test/visitors/test_bind_visitor.rb @@ -4,8 +4,14 @@ require 'support/fake_record' module Arel module Visitors - class TestBindVisitor < Minitest::Test - + class TestBindVisitor < Arel::Test + attr_reader :collector + + def setup + @collector = Collectors::SQLString.new + super + end + ## # Tests visit_Arel_Nodes_Assignment correctly # substitutes binds with values from block @@ -19,8 +25,12 @@ module Arel }.new Table.engine.connection assignment = um.ast.values[0] - actual = visitor.accept(assignment) { "replace" } - actual.must_be_like "\"name\" = replace" + actual = visitor.accept(assignment, collector) { |collector| + collector << "replace" + } + assert actual + value = actual.value + assert_like "\"name\" = replace", value end def test_visitor_yields_on_binds @@ -33,7 +43,7 @@ module Arel bp = Nodes::BindParam.new 'omg' called = false - visitor.accept(bp) { called = true } + visitor.accept(bp, collector) { |collector| called = true } assert called end @@ -49,7 +59,7 @@ module Arel called = false assert_raises(TypeError) { - visitor.accept(bp) { called = true } + visitor.accept(bp, collector) { called = true } } refute called end |