4 let
!(:feed_item1) { FactoryGirl
.create(:feed_item,
6 let
!(:feed_item2) { FactoryGirl
.create(:feed_item,
8 let
!(:other_feed_item) { FactoryGirl
.create(:feed_item,
9 feed_name
: "other_test_feed") }
11 it
"changes the description of an existing item" do
13 FactoryGirl
.attributes_for(:feed_item,
14 title
: "item 1", description
: "New description")
15 expect(assigns(:feed_items).map
{|f
| f
.description
}).to
include("New description")
16 expect(assigns(:feed_items).length
).to
eq(2)
18 expect(assigns(:feeds).length
).to
eq(2)
21 it
"adds the item when inserting a new title into an existing feed" do
23 FactoryGirl
.attributes_for(:feed_item, title
: "item 99",
24 description
: "New description")
25 expect(assigns(:feed_items).map
{|f
| f
.description
}).to
include("New description")
26 expect(assigns(:feed_items).length
).to
eq(3)
28 expect(assigns(:feeds).length
).to
eq(2)
31 it
"adds a new feed when inserting a new item into a new feed" do
33 FactoryGirl
.attributes_for(:feed_item, feed_name
: "new_feed")
34 expect(assigns(:feed_items).length
).to
eq(1)
35 expect(assigns(:feed_items)[0].feed_name
).to
eq("new_feed")
37 expect(assigns(:feeds).length
).to
eq(3)
40 it
"removes the item when updated with a blank description" do
42 FactoryGirl
.attributes_for(:feed_item, title
: "item 1",
44 expect(assigns(:feed_items).map
{|f
| f
.title
}).not_to
include("item 1")
45 expect(assigns(:feed_items).length
).to
eq(1)
47 expect(assigns(:feeds).length
).to
eq(2)
50 it
"removes the feed when deleting the last item from a feed" do
52 FactoryGirl
.attributes_for(:feed_item, feed_name
: "other_test_feed",
55 expect(assigns(:feeds).length
).to
eq(1)