From e91d393fab7d6d192ada0f51b743a2e9bca30d2a Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 30 Nov 2010 11:10:30 -0800 Subject: [PATCH] adding node test --- test/nodes/test_node.rb | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 test/nodes/test_node.rb diff --git a/test/nodes/test_node.rb b/test/nodes/test_node.rb new file mode 100644 index 0000000000..71d2098a60 --- /dev/null +++ b/test/nodes/test_node.rb @@ -0,0 +1,33 @@ +require 'helper' + +module Arel + class TestNode < MiniTest::Unit::TestCase + def test_all_nodes_are_nodes + Nodes.constants.map { |k| + Nodes.const_get(k) + }.grep(Class).each do |klass| + next if Nodes::SqlLiteral == klass + assert klass.ancestors.include?(Nodes::Node), klass.name + end + end + + def test_each + list = [] + node = Nodes::Node.new + node.each { |n| list << n } + assert_equal [node], list + end + + def test_generator + list = [] + node = Nodes::Node.new + node.each.each { |n| list << n } + assert_equal [node], list + end + + def test_enumerable + node = Nodes::Node.new + assert_kind_of Enumerable, node + end + end +end