aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2014-04-08 12:03:52 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2014-04-08 12:03:52 -0700
commit05b5bb12270b32e094c1c879273e0978dabe5b3b (patch)
tree24a09e4abc6bdb10e62626577e3c024c10707a19 /test
parentdf52f7ca2ffe1dd4fb8e65db352c7bcaacfea1a5 (diff)
downloadrails-05b5bb12270b32e094c1c879273e0978dabe5b3b.tar.gz
rails-05b5bb12270b32e094c1c879273e0978dabe5b3b.tar.bz2
rails-05b5bb12270b32e094c1c879273e0978dabe5b3b.zip
bind visitor working with collector object
Diffstat (limited to 'test')
-rw-r--r--test/helper.rb9
-rw-r--r--test/visitors/test_bind_visitor.rb22
2 files changed, 25 insertions, 6 deletions
diff --git a/test/helper.rb b/test/helper.rb
index 1292c09a08..6e8ac836fc 100644
--- a/test/helper.rb
+++ b/test/helper.rb
@@ -11,3 +11,12 @@ class Object
gsub(/\s+/, ' ').strip.must_equal other.gsub(/\s+/, ' ').strip
end
end
+
+module Arel
+ class Test < MiniTest::Test
+ def assert_like expected, actual
+ assert_equal expected.gsub(/\s+/, ' ').strip,
+ actual.gsub(/\s+/, ' ').strip
+ end
+ end
+end
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