aboutsummaryrefslogtreecommitdiffstats
path: root/spec/arel/attributes/attribute_spec.rb
blob: e6e6483e64ad4d9fc8b8ad467eda45d17ce795db (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
require 'spec_helper'

module Arel
  module Attributes
    describe 'attribute' do
      describe '#eq' do
        it 'should return an equality node' do
          attribute = Attribute.new nil, nil, nil
          equality = attribute.eq 1
          check equality.left.should == attribute
          check equality.right.should == 1
          equality.should be_kind_of Nodes::Equality
        end
      end

      describe '#in' do
        it 'can be constructed with a list' do
        end

        it 'should return an in node' do
          attribute = Attribute.new nil, nil, nil
          node = Nodes::In.new attribute, [1,2,3]
          check node.left.should  == attribute
          check node.right.should == [1, 2, 3]
        end
      end
    end

    describe 'equality' do
      describe '#to_sql' do
        it 'should produce sql' do
          table = Table.new :users
          condition = table['id'].eq 1
          condition.to_sql.should == '"users"."id" = 1'
        end
      end
    end
  end
end