aboutsummaryrefslogtreecommitdiffstats
path: root/test/nodes/test_node.rb
blob: ffa3f273ea45afa919e6ce7e050c28b1d076f56d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
require 'helper'

module Arel
  class TestNode < MiniTest::Unit::TestCase
    def test_includes_factory_methods
      assert Node.new.respond_to?(:create_join)
    end

    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