-
Notifications
You must be signed in to change notification settings - Fork 98
Expand file tree
/
Copy pathuser_steps.rb
More file actions
86 lines (71 loc) · 2.49 KB
/
user_steps.rb
File metadata and controls
86 lines (71 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
def login_user
@user = User.create!(username: "test_user",
email: "test_user@example.com",
password: "foobar",
password_confirmation: "foobar")
visit login_path
fill_in("Username", :with => @user.username)
fill_in("Password", :with => @user.password)
click_button("Sign in")
end
def create_other_user
@other_user = User.create!(username: "other_user",
email: "other_user@example.com",
password: "123456",
password_confirmation: "123456")
end
Given /^a logged in user$/ do
login_user unless @user
end
Given /^a steve exists$/ do
@steve = User.create!(username: "steve",
email: "steve_user@example.com",
password: "foobar",
password_confirmation: "foobar")
end
When /^I go to look at my profile page$/ do
visit user_path(@user)
end
Then /^it should have the right information$/ do
page.should have_title("#{@user.username}'s Profile\n | Hackety Hack!")
page.should have_content("#{@user.username}'s Profile")
end
When /^I edit my profile$/ do
visit('/users/edit')
fill_in("About", with: "Test user likes to edit his profile|")
fill_in("Current password", with: @user.password)
click_button "Update"
end
When /^I have a follower$/ do
create_other_user
@other_user.follow! @user
end
When /^I am following someone$/ do
create_other_user
@user.follow! @other_user
end
When /^I click on the number of followers on my profile$/ do
step 'I go to look at my profile page'
first('.user-followers').click
end
When /^I click on the number of people I am following on my profile$/ do
step 'I go to look at my profile page'
first('.user-following').click
end
Then /^I should see someone I'm following$/ do
page.should have_link @other_user.username
end
Then /^I should see my follower$/ do
page.should have_link @other_user.username
end
Then /^I should be notified that my profile was updated$/ do
page.should have_content("updated your account")
end
Then /^I should see my changes reflected on my profile page$/ do
visit("/users/#{@user.username}")
page.should have_content("Test user likes to edit his profile")
end
Then(/^I should see 'Steve'$/) do
@user.following?(@steve).should == true
page.should have_link @steve.username
end