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") }
8 it
"responds successfully with an HTTP 200 status code" do
10 expect(response
).to be_success
13 it
"renders the index template" do
15 expect(response
).to
render_template("index")
18 it
"loads all the feed names into @feeds" do
20 expect(assigns(:feeds).map
{|f
| f
.feed_name
}).to
match_array(["feed1", "feed2"])
24 describe
"GET #feed" do
25 let
!(:feed_item1) { FactoryGirl
.create(:feed_item,
26 feed_name
: "test_feed", title
: "item 1") }
27 let
!(:feed_item2) { FactoryGirl
.create(:feed_item,
28 feed_name
: "test_feed", title
: "item 2") }
30 it
"redirects an emtpy html feed to the index" do
31 get
:show, feed_name
: "empty_feed"
32 expect(response
).to
redirect_to(index_path
)
35 it
"does not redirect an emtpy rss document for an empty feed" do
36 get
:show, feed_name
: "empty_feed", format
: "rss"
37 expect(response
).to be_success
40 it
"returns an emtpy rss document for an empty feed" do
41 get
:show, feed_name
: "empty_feed", format
: "rss"
42 expect(assigns(:feed_items)).to be_empty
45 it
"responds successfully with an HTTP 200 status code" do
46 get
:show, feed_name
: "test_feed"
47 expect(response
).to be_success
50 it
"renders the index template" do
51 get
:show, feed_name
: "test_feed"
52 expect(response
).to
render_template("show")
55 it
"loads all of the items of a feed into @feed_items" do
56 get
:show, feed_name
: "test_feed"
57 expect(assigns(:feed_items)).to
match_array([feed_item1
, feed_item2
])
62 describe
"POST #feed" do
63 let
!(:feed_item1) { FactoryGirl
.create(:feed_item,
65 let
!(:feed_item2) { FactoryGirl
.create(:feed_item,
67 let
!(:other_feed_item) { FactoryGirl
.create(:feed_item,
68 feed_name
: "other_test_feed", title
: "item") }
70 it
"redirects an update the feed path" do
71 post
:update, FactoryGirl
.attributes_for(:feed_item,
72 title
: "item 1", description
: "New description")
73 expect(response
).to
redirect_to(feed_path("test_feed"))