More tinkering with feed controller spec
[feedcatcher.git] / spec / controllers / feed_controller_spec.rb
index fd533ba2ebca8c60efd997fafabc4840597efce9..9e75e8c238a4f3aa681ae216074546ccef2c49f2 100644 (file)
@@ -1,14 +1,6 @@
 require 'spec_helper'
 
-describe FeedController do
-#   describe "POST create" do
-#     let (:feed_item1) { mock_model(FeedItem).as_null_object }
-#     
-#     before do
-#       FeedItem.stub(:new).and_return(feed_item)
-#     end
-#   end
-    
+describe FeedController do    
   describe "GET #index" do
     let!(:feed_item1) { FactoryGirl.create(:feed_item, feed_name: "feed1") }
     let!(:feed_item2) { FactoryGirl.create(:feed_item, feed_name: "feed2") }
@@ -16,7 +8,6 @@ describe FeedController do
     it "responds successfully with an HTTP 200 status code" do
       get :index
       expect(response).to be_success
-      expect(response.status).to eq(200)
     end
 
     it "renders the index template" do
@@ -36,15 +27,24 @@ describe FeedController do
     let!(:feed_item2) { FactoryGirl.create(:feed_item, 
       feed_name: "test_feed", title: "item 2") }
     
-    it "redirects an emtpy feed to the index" do
+    it "redirects an emtpy html feed to the index" do
       get :show, feed_name: "empty_feed"
       expect(response).to redirect_to(index_path)
     end 
+
+    it "does not redirect an emtpy rss document for an empty feed" do
+      get :show, feed_name: "empty_feed", format: "rss"
+      expect(response).to be_success
+    end 
+
+    it "returns an emtpy rss document for an empty feed" do
+      get :show, feed_name: "empty_feed", format: "rss"
+      expect(assigns(:feed_items)).to be_empty
+    end 
     
     it "responds successfully with an HTTP 200 status code" do
       get :show, feed_name: "test_feed"
       expect(response).to be_success
-      expect(response.status).to eq(200)
     end
 
     it "renders the index template" do
@@ -69,36 +69,8 @@ describe FeedController do
     
     it "redirects an update the feed path" do
       post :update, FactoryGirl.attributes_for(:feed_item, 
-                       title: "item 1", description: "New description")
+                title: "item 1", description: "New description")
       expect(response).to redirect_to(feed_path("test_feed"))
     end
-    
   end
-  
-  
 end
-
-
-# describe MessagesController do
-# describe "POST create" do
-# let(:message) { mock_model(Message).as_null_object }
-# before do
-# Message.stub(:new).and_return(message)
-# end
-# it "creates a new message" do
-# Message.should_receive(:new).
-# with("text" => "a quick brown fox").
-# and_return(message)
-# post :create, :message => { "text" => "a quick brown fox" }
-# end
-# it "saves the message" do
-# message.should_receive(:save)
-# post :create
-# end
-# it "redirects to the Messages index" do
-# post :create
-# response.should redirect_to(:action => "index")
-# end
-# end
-# end
-#