aboutsummaryrefslogtreecommitdiffstats
path: root/spec/arel/engines/sql/unit/primitives/attribute_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/arel/engines/sql/unit/primitives/attribute_spec.rb')
-rw-r--r--spec/arel/engines/sql/unit/primitives/attribute_spec.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/arel/engines/sql/unit/primitives/attribute_spec.rb b/spec/arel/engines/sql/unit/primitives/attribute_spec.rb
new file mode 100644
index 0000000000..6cb72f3c19
--- /dev/null
+++ b/spec/arel/engines/sql/unit/primitives/attribute_spec.rb
@@ -0,0 +1,32 @@
+require File.join(File.dirname(__FILE__), '..', '..', '..', '..', '..', '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_not :mysql do
+ sql.should be_like(%Q{"users"."id"})
+ end
+ end
+ end
+ end
+ end
+end