fd533ba2ebca8c60efd997fafabc4840597efce9
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,
35 feed_name
: "test_feed", title
: "item 1") }
36 let
!(:feed_item2) { FactoryGirl
.create(:feed_item,
37 feed_name
: "test_feed", title
: "item 2") }
39 it
"redirects an emtpy feed to the index" do
40 get
:show, feed_name
: "empty_feed"
41 expect(response
).to
redirect_to(index_path
)
44 it
"responds successfully with an HTTP 200 status code" do
45 get
:show, feed_name
: "test_feed"
46 expect(response
).to be_success
47 expect(response
.status
).to
eq(200)
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"))
82 # describe MessagesController do
83 # describe "POST create" do
84 # let(:message) { mock_model(Message).as_null_object }
86 # Message.stub(:new).and_return(message)
88 # it "creates a new message" do
89 # Message.should_receive(:new).
90 # with("text" => "a quick brown fox").
92 # post :create, :message => { "text" => "a quick brown fox" }
94 # it "saves the message" do
95 # message.should_receive(:save)
98 # it "redirects to the Messages index" do
100 # response.should redirect_to(:action => "index")