2010-11-30 14:10:30 -05:00
|
|
|
require 'helper'
|
|
|
|
|
|
|
|
module Arel
|
2014-01-04 05:08:46 -05:00
|
|
|
class TestNode < Minitest::Test
|
2010-12-14 19:24:36 -05:00
|
|
|
def test_includes_factory_methods
|
|
|
|
assert Node.new.respond_to?(:create_join)
|
|
|
|
end
|
|
|
|
|
2010-11-30 14:10:30 -05:00
|
|
|
def test_all_nodes_are_nodes
|
|
|
|
Nodes.constants.map { |k|
|
|
|
|
Nodes.const_get(k)
|
|
|
|
}.grep(Class).each do |klass|
|
|
|
|
next if Nodes::SqlLiteral == klass
|
2012-02-20 20:57:37 -05:00
|
|
|
next if Nodes::BindParam == klass
|
2011-01-04 23:27:34 -05:00
|
|
|
next if klass.name =~ /^Arel::Nodes::Test/
|
2010-11-30 14:10:30 -05:00
|
|
|
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
|