Permalink
Browse files

adding a test for the dot visitor

  • Loading branch information...
1 parent 3446b72 commit 516ae526b34333073df7a9835952d5d499197fdd @tenderlove tenderlove committed Dec 6, 2010
Showing with 38 additions and 3 deletions.
  1. +1 −0 Manifest.txt
  2. +1 −1 lib/arel/nodes/node.rb
  3. +9 −2 lib/arel/visitors/dot.rb
  4. +27 −0 test/visitors/test_dot.rb
View
@@ -107,6 +107,7 @@ test/test_select_manager.rb
test/test_table.rb
test/test_update_manager.rb
test/visitors/test_depth_first.rb
+test/visitors/test_dot.rb
test/visitors/test_join_sql.rb
test/visitors/test_mysql.rb
test/visitors/test_oracle.rb
@@ -7,7 +7,7 @@ class Node
# Factory method to create a Nodes::Not node that has the recipient of
# the caller as a child.
def not
- Nodes::Not.new self
+ Nodes::Not.new Nodes::Grouping.new self
end
###
@@ -84,9 +84,16 @@ def visit_Arel_Nodes_UnqualifiedColumn o
visit_edge o, "attribute"
end
- def visit_Arel_Nodes_Offset o
- visit_edge o, "value"
+ def unary o
+ visit_edge o, "expr"
end
+ alias :visit_Arel_Nodes_Group :unary
+ alias :visit_Arel_Nodes_Grouping :unary
+ alias :visit_Arel_Nodes_Having :unary
+ alias :visit_Arel_Nodes_Not :unary
+ alias :visit_Arel_Nodes_Offset :unary
+ alias :visit_Arel_Nodes_On :unary
+ alias :visit_Arel_Nodes_UnqualifiedColumn :unary
def visit_Arel_Nodes_InsertStatement o
visit_edge o, "relation"
@@ -0,0 +1,27 @@
+require 'helper'
+
+module Arel
+ module Visitors
+ class TestDot < MiniTest::Unit::TestCase
+ def setup
+ @visitor = Visitors::Dot.new
+ end
+
+ # unary ops
+ [
+ Arel::Nodes::Not,
+ Arel::Nodes::Group,
+ Arel::Nodes::On,
+ Arel::Nodes::Grouping,
+ Arel::Nodes::Offset,
+ Arel::Nodes::Having,
+ Arel::Nodes::UnqualifiedColumn,
+ ].each do |klass|
+ define_method("test_#{klass.name.gsub('::', '_')}") do
+ op = klass.new(:a)
+ @visitor.accept op
+ end
+ end
+ end
+ end
+end

0 comments on commit 516ae52

Please sign in to comment.