Skip to content
Browse files

Added unit test for the mysql2 bind substitution

  • Loading branch information...
1 parent b4fd431 commit 30a74c09e794a46eac6bd0719f1b0333704317b2 @olliwer olliwer committed
Showing with 20 additions and 1 deletion.
  1. +20 −1 test/visitors/test_bind_visitor.rb
View
21 test/visitors/test_bind_visitor.rb
@@ -1,9 +1,28 @@
require 'helper'
require 'arel/visitors/bind_visitor'
+require 'support/fake_record'
module Arel
module Visitors
- class TestBindVisitor < MiniTest::Unit::TestCase
+ class TestBindVisitor < MiniTest::Unit::TestCase
+
+ ##
+ # Tests visit_Arel_Nodes_Assignment correctly
+ # substitutes binds with values from block
+ def test_assignment_binds_are_substituted
+ table = Table.new(:users)
+ um = Arel::UpdateManager.new Table.engine
+ bp = Nodes::BindParam.new '?'
+ um.set [[table[:name], bp]]
+ visitor = Class.new(Arel::Visitors::ToSql) {
+ include Arel::Visitors::BindVisitor
+ }.new Table.engine.connection
+
+ assignment = um.ast.values[0]
+ actual = visitor.accept(assignment) { "replace" }
+ actual.must_be_like "\"name\" = replace"
+ end
+
def test_visitor_yields_on_binds
visitor = Class.new(Arel::Visitors::Visitor) {
def initialize omg

0 comments on commit 30a74c0

Please sign in to comment.
Something went wrong with that request. Please try again.