3 describe FeedController
do
4 # describe "POST create" do
5 # let (:feed_item1) { mock_model(FeedItem).as_null_object }
8 # FeedItem.stub(:new).and_return(feed_item)
12 describe
"GET #index" do
13 let
!(:feed_item1) { FactoryGirl
.create(:feed_item, feed_name
: "feed1") }
14 let
!(:feed_item2) { FactoryGirl
.create(:feed_item, feed_name
: "feed2") }
16 it
"responds successfully with an HTTP 200 status code" do
18 expect(response
).to be_success
19 expect(response
.status
).to
eq(200)
22 it
"renders the index template" do
24 expect(response
).to
render_template("index")
27 it
"loads all the feed names into @feeds" do
29 expect(assigns(:feeds).map
{|f
| f
.feed_name
}).to
match_array(["feed1", "feed2"])
33 describe
"GET #feed" do
34 let
!(:feed_item1) { FactoryGirl
.create(:feed_item, feed_name
: "test_feed", title
: "item 1") }
35 let
!(:feed_item2) { FactoryGirl
.create(:feed_item, feed_name
: "test_feed", title
: "item 2") }
37 it
"redirects an emtpy feed to the index" do
38 get
:show, feed_name
: "empty_feed"
39 expect(response
).to
redirect_to(index_path
)
42 it
"responds successfully with an HTTP 200 status code" do
43 get
:show, feed_name
: "test_feed"
44 expect(response
).to be_success
45 expect(response
.status
).to
eq(200)
48 it
"renders the index template" do
49 get
:show, feed_name
: "test_feed"
50 expect(response
).to
render_template("show")
53 it
"loads all of the items of a feed into @feed_items" do
54 get
:show, feed_name
: "test_feed"
55 expect(assigns(:feed_items)).to
match_array([feed_item1
, feed_item2
])
63 # describe MessagesController do
64 # describe "POST create" do
65 # let(:message) { mock_model(Message).as_null_object }
67 # Message.stub(:new).and_return(message)
69 # it "creates a new message" do
70 # Message.should_receive(:new).
71 # with("text" => "a quick brown fox").
73 # post :create, :message => { "text" => "a quick brown fox" }
75 # it "saves the message" do
76 # message.should_receive(:save)
79 # it "redirects to the Messages index" do
81 # response.should redirect_to(:action => "index")