From a83efc5d5d94d50589a80bdd27ddf5b83ed39810 Mon Sep 17 00:00:00 2001
From: Nick Kallen <nkallen@nick-kallens-computer-2.local>
Date: Sat, 12 Jan 2008 20:18:52 -0800
Subject: added aggregations

---
 spec/active_relation/relations/attribute_spec.rb | 40 +++++++++++++++++++++++-
 1 file changed, 39 insertions(+), 1 deletion(-)

(limited to 'spec/active_relation')

diff --git a/spec/active_relation/relations/attribute_spec.rb b/spec/active_relation/relations/attribute_spec.rb
index 28fb0c3754..2a6deca22a 100644
--- a/spec/active_relation/relations/attribute_spec.rb
+++ b/spec/active_relation/relations/attribute_spec.rb
@@ -56,7 +56,7 @@ describe ActiveRelation::Primitives::Attribute do
       end
     end
     
-    describe 'greater_than' do
+    describe '#greater_than' do
       it "manufactures a greater-than predicate" do
         @attribute1.greater_than(@attribute2).should == ActiveRelation::Predicates::GreaterThan.new(@attribute1, @attribute2)
       end
@@ -74,4 +74,42 @@ describe ActiveRelation::Primitives::Attribute do
       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")
+      end
+    end
+    
+    describe '#sum' do
+      it "manufactures a sum aggregation" do
+        @attribute1.sum.should == ActiveRelation::Primitives::Aggregation.new(@attribute1, "SUM")
+      end
+    end
+    
+    describe '#maximum' do
+      it "manufactures a maximum aggregation" do
+        @attribute1.maximum.should == ActiveRelation::Primitives::Aggregation.new(@attribute1, "MAX")
+      end
+    end
+    
+    describe '#minimum' do
+      it "manufactures a minimum aggregation" do
+        @attribute1.minimum.should == ActiveRelation::Primitives::Aggregation.new(@attribute1, "MIN")
+      end
+    end
+    
+    describe '#average' do
+      it "manufactures an average aggregation" do
+        @attribute1.average.should == ActiveRelation::Primitives::Aggregation.new(@attribute1, "AVG")
+      end
+    end
+    
+    
+  end
 end
-- 
cgit v1.2.3