aboutsummaryrefslogtreecommitdiffstats
path: root/test/nodes/test_sql_literal.rb
blob: f8f7e9e90d71b219138be3faf6200c6f292b9d53 (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
require 'test_helper'

module Arel
  module Nodes
    describe 'sql literal' do
      describe 'sql' do
        it 'makes a sql literal node' do
          sql = Arel.sql 'foo'
          sql.must_be_kind_of Arel::Nodes::SqlLiteral
        end
      end

      describe 'count' do
        it 'makes a count node' do
          node = SqlLiteral.new('*').count
          viz = Visitors::ToSql.new Table.engine
          viz.accept(node).must_be_like %{ COUNT(*) }
        end

        it 'makes a distinct node' do
          node = SqlLiteral.new('*').count true
          viz = Visitors::ToSql.new Table.engine
          viz.accept(node).must_be_like %{ COUNT(DISTINCT *) }
        end
      end
    end
  end
end