diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/visitors/test_bind_visitor.rb | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/test/visitors/test_bind_visitor.rb b/test/visitors/test_bind_visitor.rb new file mode 100644 index 0000000000..92e5d1612c --- /dev/null +++ b/test/visitors/test_bind_visitor.rb @@ -0,0 +1,39 @@ +require 'helper' +require 'arel/visitors/bind_visitor' + +module Arel + module Visitors + class TestBindVisitor < MiniTest::Unit::TestCase + def test_visitor_yields_on_binds + visitor = Class.new(Arel::Visitors::Visitor) { + def initialize omg + end + + include Arel::Visitors::BindVisitor + }.new nil + + bp = Nodes::BindParam.new 'omg' + called = false + visitor.accept(bp) { called = true } + assert called + end + + def test_visitor_only_yields_on_binds + visitor = Class.new(Arel::Visitors::Visitor) { + def initialize omg + end + + include Arel::Visitors::BindVisitor + }.new(nil) + + bp = Arel.sql 'omg' + called = false + + assert_raises(TypeError) { + visitor.accept(bp) { called = true } + } + refute called + end + end + end +end |