Commit acd2aa06

mo khan <mo@mokhan.ca>
2013-03-02 17:22:04
clean up the categories controller specs.
1 parent 7b96044
Changed files (1)
spec/controllers/categories_controller_spec.rb
@@ -4,36 +4,36 @@ describe CategoriesController do
 
   before(:each) do
     @creation = FactoryGirl.create(:creation)
-    @creations = [@creation]
-    @category = FactoryGirl.create(:category, :creations => @creations)
-    @creation.category_ids = [@category.id]
-    @creation.save
+    @category = FactoryGirl.create(:category, :creations => [@creation])
   end
 
   describe "GET show" do
     context "when there is NO category that matches the slug" do
-      it "should return nothing" do
+      before(:each) do
+        get :show, :id => "!#{@category.slug}"
+      end
+      it "should not return a category" do
         assigns(:category).should be_nil
-        assigns(:creations).should be_nil
+      end
+      it "should not return any creations" do
+        assigns(:creations).should be_empty
       end
     end
     context "when there is a category that matches the slug" do
       context "when there are creations in the category" do
-        before(:each) do
-          get :show, :id => @category.slug
-        end
+        before { get :show, :id => @category.slug }
+
         it "should return the creations in the category" do
-          assigns(:creations).should eq(@creations)
+          assigns(:creations).should == [@creation]
         end
         it "should return the category" do
-          assigns(:category).should eq(@category)
+          assigns(:category).should == @category
         end
       end
       context "when there are no creations in the category" do
         let(:other_category) { FactoryGirl.create(:category, :slug => 'booooo') }
-        before(:each) do
-          get :show, :id => other_category.slug
-        end
+        before { get :show, :id => other_category.slug }
+
         it "should return zero creations" do
           assigns(:creations).should be_empty
         end