Skip to content

Commit 597d083

Browse files
committed
Making tests more meaningful by introducing another user that can be followed/follow someone fixes #127
1 parent c60e174 commit 597d083

2 files changed

Lines changed: 31 additions & 12 deletions

File tree

features/step_definitions/user_steps.rb

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
def 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")
1010
end
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+
1219
Given /^a logged in user$/ do
1320
login_user unless @user
1421
end
@@ -29,6 +36,16 @@ def login_user
2936
click_button "Update"
3037
end
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+
3249
When /^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
4057
end
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
4461
end
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
4865
end
4966

5067
Then /^I should be notified that my profile was updated$/ do

features/users.feature

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ Feature: Manage account
1515
And I should see my changes reflected on my profile page
1616

1717
Scenario: See my followers
18-
When I click on the number of followers on my profile
19-
Then I should see a list of my followers
18+
When I have a follower
19+
And I click on the number of followers on my profile
20+
Then I should see my follower
2021

21-
Scenario: See who is following me
22-
When I click on the number of people I am following on my profile
23-
Then I should see a list of the people I'm following
22+
Scenario: See who I am following
23+
When I am following someone
24+
And I click on the number of people I am following on my profile
25+
Then I should see someone I'm following
2426

0 commit comments

Comments
 (0)