11def login_user
22 @user = User . create! ( username : "test_user" ,
3- email : "test_user@example.com" ,
4- password : "foobar" ,
5- password_confirmation : "foobar" )
3+ email : "test_user@example.com" ,
4+ password : "foobar" ,
5+ password_confirmation : "foobar" )
66 visit login_path
77 fill_in ( "Username" , :with => @user . username )
88 fill_in ( "Password" , :with => @user . password )
99 click_button ( "Sign in" )
1010end
1111
12+ def create_other_user
13+ @other_user = User . create! ( username : "other_user" ,
14+ email : "other_user@example.com" ,
15+ password : "123456" ,
16+ password_confirmation : "123456" )
17+ end
18+
1219Given /^a logged in user$/ do
1320 login_user unless @user
1421end
@@ -29,6 +36,16 @@ def login_user
2936 click_button "Update"
3037end
3138
39+ When /^I have a follower$/ do
40+ create_other_user
41+ @other_user . follow! @user
42+ end
43+
44+ When /^I am following someone$/ do
45+ create_other_user
46+ @user . follow! @other_user
47+ end
48+
3249When /^I click on the number of followers on my profile$/ do
3350 step 'I go to look at my profile page'
3451 first ( '.user-followers' ) . click
@@ -39,12 +56,12 @@ def login_user
3956 first ( '.user-following' ) . click
4057end
4158
42- Then /^I should see a list of the people I'm following$/ do
43- page . should have_content " #{ @user . username } is following"
59+ Then /^I should see someone I'm following$/ do
60+ page . should have_link @other_user . username
4461end
4562
46- Then /^I should see a list of my followers $/ do
47- page . should have_content " #{ @user . username } 's followers"
63+ Then /^I should see my follower $/ do
64+ page . should have_link @other_user . username
4865end
4966
5067Then /^I should be notified that my profile was updated$/ do
0 commit comments