c2b71a4459b823059b755b88659183c8c35406a4
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
11 expect(response
.status
).to
eq(200)
14 it
"renders the index template" do
16 expect(response
).to
render_template("index")
19 it
"loads all the feed names into @feeds" do
21 expect(assigns(:feeds).map
{|f
| f
.feed_name
}).to
match_array(["feed1", "feed2"])
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") }
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
)
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)
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)
47 it
"renders the index template" do
48 get
:show, feed_name
: "test_feed"
49 expect(response
).to
render_template("show")
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
])
59 describe
"POST #feed" do
60 let
!(:feed_item1) { FactoryGirl
.create(:feed_item,
62 let
!(:feed_item2) { FactoryGirl
.create(:feed_item,
64 let
!(:other_feed_item) { FactoryGirl
.create(:feed_item,
65 feed_name
: "other_test_feed", title
: "item") }
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"))