aboutsummaryrefslogtreecommitdiffstats
path: root/spec/arel/engines/sql/unit/primitives/value_spec.rb
blob: c8f03fc27029684aa662b35c7531edb5957d4762 (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
require 'spec_helper'

module Arel
  describe Value do
    before do
      @relation = Table.new(:users)
    end

    describe '#to_sql' do
      it "appropriately quotes the value" do
        Value.new(1, @relation).to_sql.should be_like('1')
        
        adapter_is_not :postgresql do
          Value.new('asdf', @relation).to_sql.should be_like("'asdf'")
        end
        
        adapter_is :postgresql do
          Value.new('asdf', @relation).to_sql.should be_like("E'asdf'")
        end
      end
    end

    describe '#format' do
      it "returns the sql of the provided object" do
        Value.new(1, @relation).format(@relation[:id]).should == @relation[:id].to_sql
      end
    end
  end
end