Skip to content

Commit 918767c

Browse files
author
Rhys Powell
committed
Got the 'View my profile' scenario to pass
1 parent 42132b5 commit 918767c

3 files changed

Lines changed: 44 additions & 4 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Given /^a logged in user$/ do
2+
@user = User.create!(username: "test_user",
3+
email: "test_user@example.com",
4+
password: "foobar",
5+
password_confirmation: "foobar")
6+
visit('/login')
7+
fill_in("Username", :with => @user.username)
8+
fill_in("Password", :with => @user.password)
9+
click_button("Sign in")
10+
end
11+
12+
When /^I go to look at my profile page$/ do
13+
visit user_path(@user)
14+
end
15+
16+
Then /^it should have the right information$/ do
17+
page.should have_selector('title', :content => "#{@user.username}'s page")
18+
page.should have_content("About #{@user.username}")
19+
end

features/support/env.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@
3131

3232
# Remove/comment out the lines below if your app doesn't have a database.
3333
# For some databases (like MongoDB and CouchDB) you may need to use :truncation instead.
34-
begin
35-
DatabaseCleaner.strategy = :transaction
36-
rescue NameError
37-
raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
34+
DatabaseCleaner.orm = "mongo_mapper"
35+
DatabaseCleaner[:mongo_mapper].strategy = :truncation
36+
37+
Before do
38+
DatabaseCleaner[:mongo_mapper].clean
3839
end
3940

4041
# You may also want to configure DatabaseCleaner to use different strategies for certain features and scenarios.

features/users.feature

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Feature: Manage account
2+
3+
As a user of this site, I can view and update my profile
4+
5+
Background: The user is logged in
6+
Given a logged in user
7+
8+
Scenario: View my profile
9+
When I go to look at my profile page
10+
Then it should have the right information
11+
12+
Scenario: Edit my profile
13+
When I go to change my settings
14+
And fill in the following
15+
| About | New users love editing their page |
16+
| Current password | foobar |
17+
And submit the form
18+
Then I should be notified that my profile was updated
19+
When I look at my page
20+
Then I should see my changes reflected

0 commit comments

Comments
 (0)