Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

adding a test for the dot visitor

  • Loading branch information...
commit 516ae526b34333073df7a9835952d5d499197fdd 1 parent 3446b72
Aaron Patterson tenderlove authored
1  Manifest.txt
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
2  lib/arel/nodes/node.rb
View
@@ -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
###
11 lib/arel/visitors/dot.rb
View
@@ -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"
27 test/visitors/test_dot.rb
View
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.