Updated a test for no direction with empty feeds as rss, changed some private keyword...
[feedcatcher.git] / spec / controllers / feed_controller_spec.rb
1 require 'spec_helper'
2
3 describe FeedController do
4 describe "GET #index" do
5 let!(:feed_item1) { FactoryGirl.create(:feed_item, feed_name: "feed1") }
6 let!(:feed_item2) { FactoryGirl.create(:feed_item, feed_name: "feed2") }
7
8 it "responds successfully with an HTTP 200 status code" do
9 get :index
10 expect(response).to be_success
11 expect(response.status).to eq(200)
12 end
13
14 it "renders the index template" do
15 get :index
16 expect(response).to render_template("index")
17 end
18
19 it "loads all the feed names into @feeds" do
20 get :index
21 expect(assigns(:feeds).map {|f| f.feed_name}).to match_array(["feed1", "feed2"])
22 end
23 end
24
25 describe "GET #feed" do
26 let!(:feed_item1) { FactoryGirl.create(:feed_item,
27 feed_name: "test_feed", title: "item 1") }
28 let!(:feed_item2) { FactoryGirl.create(:feed_item,
29 feed_name: "test_feed", title: "item 2") }
30
31 it "redirects an emtpy html feed to the index" do
32 get :show, feed_name: "empty_feed"
33 expect(response).to redirect_to(index_path)
34 end
35
36 it "returns an emtpy rss document for an empty feed" do
37 get :show, feed_name: "empty_feed", format: "rss"
38 expect(response.status).to be(200)
39 end
40
41 it "responds successfully with an HTTP 200 status code" do
42 get :show, feed_name: "test_feed"
43 expect(response).to be_success
44 expect(response.status).to eq(200)
45 end
46
47 it "renders the index template" do
48 get :show, feed_name: "test_feed"
49 expect(response).to render_template("show")
50 end
51
52 it "loads all of the items of a feed into @feed_items" do
53 get :show, feed_name: "test_feed"
54 expect(assigns(:feed_items)).to match_array([feed_item1, feed_item2])
55 end
56 end
57
58
59 describe "POST #feed" do
60 let!(:feed_item1) { FactoryGirl.create(:feed_item,
61 title: "item 1") }
62 let!(:feed_item2) { FactoryGirl.create(:feed_item,
63 title: "item 2") }
64 let!(:other_feed_item) { FactoryGirl.create(:feed_item,
65 feed_name: "other_test_feed", title: "item") }
66
67 it "redirects an update the feed path" do
68 post :update, FactoryGirl.attributes_for(:feed_item,
69 title: "item 1", description: "New description")
70 expect(response).to redirect_to(feed_path("test_feed"))
71 end
72 end
73 end