aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_factory_methods.rb
blob: 3e23b090b473218d7079b197b27ee62d4c9b218d (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
38
39
40
41
42
43
44
require 'helper'

module Arel
  module FactoryMethods
    class TestFactoryMethods < Minitest::Test
      class Factory
        include Arel::FactoryMethods
      end

      def setup
        @factory = Factory.new
      end

      def test_create_join
        join = @factory.create_join :one, :two
        assert_kind_of Nodes::Join, join
        assert_equal :two, join.right
      end

      def test_create_on
        on = @factory.create_on :one
        assert_instance_of Nodes::On, on
        assert_equal :one, on.expr
      end

      def test_create_true
        true_node = @factory.create_true
        assert_instance_of Nodes::True, true_node
      end

      def test_create_false
        false_node = @factory.create_false
        assert_instance_of Nodes::False, false_node
      end

      def test_lower
        lower = @factory.lower :one
        assert_instance_of Nodes::NamedFunction, lower
        assert_equal 'LOWER', lower.name
        assert_equal [:one], lower.expressions.map(&:expr)
      end
    end
  end
end