diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2012-02-21 15:01:27 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2012-02-21 15:01:27 -0800 |
commit | bb22e84abe262b6e6e0975b3f6c4262929ab8bca (patch) | |
tree | 4bb98cb7d8c7ba2028e7c67a38d4738663ef23f2 /test/visitors | |
parent | aa43fe1eb7db56f333698033e02b5e879b85145b (diff) | |
download | rails-bb22e84abe262b6e6e0975b3f6c4262929ab8bca.tar.gz rails-bb22e84abe262b6e6e0975b3f6c4262929ab8bca.tar.bz2 rails-bb22e84abe262b6e6e0975b3f6c4262929ab8bca.zip |
added a module for visiting and transforming bind values
Diffstat (limited to 'test/visitors')
-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 |