aboutsummaryrefslogtreecommitdiffstats
path: root/spec/active_relation/primitives/attribute_spec.rb
diff options
context:
space:
mode:
authorBryan Helmkamp <bryan@brynary.com>2008-01-14 10:50:46 -0500
committerBryan Helmkamp <bryan@brynary.com>2008-01-14 10:50:46 -0500
commit553eb0ad490abc7f85d9836c3ba959ab771d3cf4 (patch)
treebaa9714465488d77980e8d252a82849b32844d3b /spec/active_relation/primitives/attribute_spec.rb
parent17a5fd13bc4ba8405d95e90d12b87dcd7e5bea5b (diff)
downloadrails-553eb0ad490abc7f85d9836c3ba959ab771d3cf4.tar.gz
rails-553eb0ad490abc7f85d9836c3ba959ab771d3cf4.tar.bz2
rails-553eb0ad490abc7f85d9836c3ba959ab771d3cf4.zip
Remove ActiveRelation sub-modules and refactor specs
Diffstat (limited to 'spec/active_relation/primitives/attribute_spec.rb')
-rw-r--r--spec/active_relation/primitives/attribute_spec.rb164
1 files changed, 82 insertions, 82 deletions
diff --git a/spec/active_relation/primitives/attribute_spec.rb b/spec/active_relation/primitives/attribute_spec.rb
index f1aa404a34..6078da08f3 100644
--- a/spec/active_relation/primitives/attribute_spec.rb
+++ b/spec/active_relation/primitives/attribute_spec.rb
@@ -1,119 +1,119 @@
require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
-describe ActiveRelation::Primitives::Attribute do
- before do
- @relation1 = ActiveRelation::Relations::Table.new(:foo)
- @relation2 = ActiveRelation::Relations::Table.new(:bar)
- end
-
- describe '#as' do
- it "manufactures an aliased attributed when provided a parameter" do
- @relation1[:id].as(:alias).should == ActiveRelation::Primitives::Attribute.new(@relation1, :id, :alias)
+module ActiveRelation
+ describe Attribute do
+ before do
+ @relation1 = Table.new(:foo)
+ @relation2 = Table.new(:bar)
end
- end
- describe '#qualified_name' do
- it "manufactures an attribute name prefixed with the relation's name" do
- @relation1[:id].qualified_name.should == 'foo.id'
+ describe '#as' do
+ it "manufactures an aliased attributed when provided a parameter" do
+ @relation1[:id].as(:alias).should == Attribute.new(@relation1, :id, :alias)
+ end
end
+
+ describe '#qualified_name' do
+ it "manufactures an attribute name prefixed with the relation's name" do
+ @relation1[:id].qualified_name.should == 'foo.id'
+ end
- it "manufactures an attribute name prefixed with the relation's aliased name" do
- @relation1.as(:bar)[:id].qualified_name.should == 'bar.id'
+ it "manufactures an attribute name prefixed with the relation's aliased name" do
+ @relation1.as(:bar)[:id].qualified_name.should == 'bar.id'
+ end
end
- end
- describe '#qualify' do
- it "manufactures an attribute aliased with that attributes qualified name" do
- @relation1[:id].qualify.should == @relation1[:id].qualify
+ describe '#qualify' do
+ it "manufactures an attribute aliased with that attributes qualified name" do
+ @relation1[:id].qualify.should == @relation1[:id].qualify
+ end
end
- end
- describe '==' do
- it "obtains if the relation and attribute name are identical" do
- ActiveRelation::Primitives::Attribute.new(@relation1, :name).should == ActiveRelation::Primitives::Attribute.new(@relation1, :name)
- ActiveRelation::Primitives::Attribute.new(@relation1, :name).should_not == ActiveRelation::Primitives::Attribute.new(@relation1, :another_name)
- ActiveRelation::Primitives::Attribute.new(@relation1, :name).should_not == ActiveRelation::Primitives::Attribute.new(@relation2, :name)
+ describe '==' do
+ it "obtains if the relation and attribute name are identical" do
+ Attribute.new(@relation1, :name).should == Attribute.new(@relation1, :name)
+ Attribute.new(@relation1, :name).should_not == Attribute.new(@relation1, :another_name)
+ Attribute.new(@relation1, :name).should_not == Attribute.new(@relation2, :name)
+ end
end
- end
- describe 'predications' do
- before do
- @attribute1 = ActiveRelation::Primitives::Attribute.new(@relation1, :name)
- @attribute2 = ActiveRelation::Primitives::Attribute.new(@relation2, :name)
- end
+ describe 'predications' do
+ before do
+ @attribute1 = Attribute.new(@relation1, :name)
+ @attribute2 = Attribute.new(@relation2, :name)
+ end
- describe '#equals' do
- it "manufactures an equality predicate" do
- @attribute1.equals(@attribute2).should == ActiveRelation::Predicates::Equality.new(@attribute1, @attribute2)
+ describe '#equals' do
+ it "manufactures an equality predicate" do
+ @attribute1.equals(@attribute2).should == Equality.new(@attribute1, @attribute2)
+ end
end
- end
- describe '#less_than' do
- it "manufactures a less-than predicate" do
- @attribute1.less_than(@attribute2).should == ActiveRelation::Predicates::LessThan.new(@attribute1, @attribute2)
+ describe '#less_than' do
+ it "manufactures a less-than predicate" do
+ @attribute1.less_than(@attribute2).should == LessThan.new(@attribute1, @attribute2)
+ end
end
- end
- describe '#less_than_or_equal_to' do
- it "manufactures a less-than or equal-to predicate" do
- @attribute1.less_than_or_equal_to(@attribute2).should == ActiveRelation::Predicates::LessThanOrEqualTo.new(@attribute1, @attribute2)
+ describe '#less_than_or_equal_to' do
+ it "manufactures a less-than or equal-to predicate" do
+ @attribute1.less_than_or_equal_to(@attribute2).should == LessThanOrEqualTo.new(@attribute1, @attribute2)
+ end
end
- end
- describe '#greater_than' do
- it "manufactures a greater-than predicate" do
- @attribute1.greater_than(@attribute2).should == ActiveRelation::Predicates::GreaterThan.new(@attribute1, @attribute2)
+ describe '#greater_than' do
+ it "manufactures a greater-than predicate" do
+ @attribute1.greater_than(@attribute2).should == GreaterThan.new(@attribute1, @attribute2)
+ end
end
- end
- describe '#greater_than_or_equal_to' do
- it "manufactures a greater-than or equal to predicate" do
- @attribute1.greater_than_or_equal_to(@attribute2).should == ActiveRelation::Predicates::GreaterThanOrEqualTo.new(@attribute1, @attribute2)
+ describe '#greater_than_or_equal_to' do
+ it "manufactures a greater-than or equal to predicate" do
+ @attribute1.greater_than_or_equal_to(@attribute2).should == GreaterThanOrEqualTo.new(@attribute1, @attribute2)
+ end
end
- end
- describe '#matches' do
- it "manufactures a match predicate" do
- @attribute1.matches(/.*/).should == ActiveRelation::Predicates::Match.new(@attribute1, @attribute2)
+ describe '#matches' do
+ it "manufactures a match predicate" do
+ @attribute1.matches(/.*/).should == Match.new(@attribute1, @attribute2)
+ end
end
end
- end
- describe 'aggregations' do
- before do
- @attribute1 = ActiveRelation::Primitives::Attribute.new(@relation1, :name)
- end
-
- describe '#count' do
- it "manufactures a count aggregation" do
- @attribute1.count.should == ActiveRelation::Primitives::Aggregation.new(@attribute1, "COUNT")
+ describe 'aggregations' do
+ before do
+ @attribute1 = Attribute.new(@relation1, :name)
end
- end
- describe '#sum' do
- it "manufactures a sum aggregation" do
- @attribute1.sum.should == ActiveRelation::Primitives::Aggregation.new(@attribute1, "SUM")
+ describe '#count' do
+ it "manufactures a count aggregation" do
+ @attribute1.count.should == Aggregation.new(@attribute1, "COUNT")
+ end
end
- end
- describe '#maximum' do
- it "manufactures a maximum aggregation" do
- @attribute1.maximum.should == ActiveRelation::Primitives::Aggregation.new(@attribute1, "MAX")
+ describe '#sum' do
+ it "manufactures a sum aggregation" do
+ @attribute1.sum.should == Aggregation.new(@attribute1, "SUM")
+ end
end
- end
- describe '#minimum' do
- it "manufactures a minimum aggregation" do
- @attribute1.minimum.should == ActiveRelation::Primitives::Aggregation.new(@attribute1, "MIN")
+ describe '#maximum' do
+ it "manufactures a maximum aggregation" do
+ @attribute1.maximum.should == Aggregation.new(@attribute1, "MAX")
+ end
end
- end
- describe '#average' do
- it "manufactures an average aggregation" do
- @attribute1.average.should == ActiveRelation::Primitives::Aggregation.new(@attribute1, "AVG")
+ describe '#minimum' do
+ it "manufactures a minimum aggregation" do
+ @attribute1.minimum.should == Aggregation.new(@attribute1, "MIN")
+ end
end
- end
-
+ describe '#average' do
+ it "manufactures an average aggregation" do
+ @attribute1.average.should == Aggregation.new(@attribute1, "AVG")
+ end
+ end
+ end
end
-end
+end \ No newline at end of file