Update request spec done
[feedcatcher.git] / spec / controllers / feed_controller_spec.rb
index fd477916a9dfd299536f8518d6758afbcaf76c5a..8c065036f09830786c002b5f6027c1a752b94c57 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") }
@@ -31,8 +23,10 @@ describe FeedController do
   end
 
   describe "GET #feed" do
-    let!(:feed_item1) { FactoryGirl.create(:feed_item, feed_name: "test_feed", title: "item 1") }
-    let!(:feed_item2) { FactoryGirl.create(:feed_item, feed_name: "test_feed", title: "item 2") }
+    let!(:feed_item1) { FactoryGirl.create(:feed_item, 
+      feed_name: "test_feed", title: "item 1") }
+    let!(:feed_item2) { FactoryGirl.create(:feed_item, 
+      feed_name: "test_feed", title: "item 2") }
     
     it "redirects an emtpy feed to the index" do
       get :show, feed_name: "empty_feed"
@@ -55,31 +49,20 @@ describe FeedController do
       expect(assigns(:feed_items)).to match_array([feed_item1, feed_item2])
     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
-# 
+  describe "POST #feed" do
+    let!(:feed_item1) { FactoryGirl.create(:feed_item, 
+      title: "item 1") }
+    let!(:feed_item2) { FactoryGirl.create(:feed_item, 
+      title: "item 2") }
+    let!(:other_feed_item) { FactoryGirl.create(:feed_item, 
+      feed_name: "other_test_feed", title: "item") }
+    
+    it "redirects an update the feed path" do
+      post :update, FactoryGirl.attributes_for(:feed_item, 
+                title: "item 1", description: "New description")
+      expect(response).to redirect_to(feed_path("test_feed"))
+    end
+  end
+end