Sha256: 24386f2a3b372c1a7e34bda968e202036b91c1e04852f3f0751560c7a4aae1f3

Contents?: true

Size: 818 Bytes

Versions: 5

Compression:

Stored size: 818 Bytes

Contents

require 'spec_helper'

module Arel
  describe Attribute do
    before do
      @relation = Table.new(:users)
      @attribute = @relation[:id]
    end

    describe '#column' do
      it "returns the corresponding column in the relation" do
        @attribute.column.should == @relation.column_for(@attribute)
      end
    end

    describe '#to_sql' do
      describe 'for a simple attribute' do
        it "manufactures sql with an alias" do
          sql = @attribute.to_sql

          adapter_is :mysql do
            sql.should be_like(%Q{`users`.`id`})
          end

          adapter_is :oracle do
            sql.should be_like(%Q{"USERS"."ID"})
          end

          adapter_is_not :mysql, :oracle do
            sql.should be_like(%Q{"users"."id"})
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
arel-1.0.1 spec/engines/sql/unit/primitives/attribute_spec.rb
arel-1.0.0 spec/engines/sql/unit/primitives/attribute_spec.rb
arel-1.0.0.rc1 spec/engines/sql/unit/primitives/attribute_spec.rb
arel-compat-0.4.0 spec/engines/sql/unit/primitives/attribute_spec.rb
arel-0.4.0 spec/engines/sql/unit/primitives/attribute_spec.rb