aboutsummaryrefslogtreecommitdiffstats
path: root/spec/arel/attributes_spec.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-08-12 14:55:31 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2010-08-12 14:55:31 -0700
commit196b4e05b7390ac31e12a17ae224b1cf35e4becd (patch)
treebc5a5e56f8311bd68feb628d89a04e845585f3b5 /spec/arel/attributes_spec.rb
parent1036749e394e5f7f039e75cdec7675f9ca5047b0 (diff)
downloadrails-196b4e05b7390ac31e12a17ae224b1cf35e4becd.tar.gz
rails-196b4e05b7390ac31e12a17ae224b1cf35e4becd.tar.bz2
rails-196b4e05b7390ac31e12a17ae224b1cf35e4becd.zip
tables can fetch attributes
Diffstat (limited to 'spec/arel/attributes_spec.rb')
-rw-r--r--spec/arel/attributes_spec.rb41
1 files changed, 41 insertions, 0 deletions
diff --git a/spec/arel/attributes_spec.rb b/spec/arel/attributes_spec.rb
new file mode 100644
index 0000000000..8b437dff9b
--- /dev/null
+++ b/spec/arel/attributes_spec.rb
@@ -0,0 +1,41 @@
+require 'spec_helper'
+
+module Arel
+ describe 'Attributes' do
+ describe 'for' do
+ it 'returns the correct constant for strings' do
+ [:string, :text, :binary].each do |type|
+ column = Struct.new(:type).new type
+ Attributes.for(column).should == Attributes::String
+ end
+ end
+
+ it 'returns the correct constant for ints' do
+ column = Struct.new(:type).new :integer
+ Attributes.for(column).should == Attributes::Integer
+ end
+
+ it 'returns the correct constant for floats' do
+ column = Struct.new(:type).new :float
+ Attributes.for(column).should == Attributes::Float
+ end
+
+ it 'returns the correct constant for decimals' do
+ column = Struct.new(:type).new :decimal
+ Attributes.for(column).should == Attributes::Decimal
+ end
+
+ it 'returns the correct constant for boolean' do
+ column = Struct.new(:type).new :boolean
+ Attributes.for(column).should == Attributes::Boolean
+ end
+
+ it 'returns the correct constant for time' do
+ [:date, :datetime, :timestamp, :time].each do |type|
+ column = Struct.new(:type).new type
+ Attributes.for(column).should == Attributes::Time
+ end
+ end
+ end
+ end
+end