Created
December 4, 2010 12:56
-
-
Save jmaicher/728159 to your computer and use it in GitHub Desktop.
Testing attribute changes in the database with cucumber
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Background: | |
Given I am signed in as a user | |
And I am on the dashboard site | |
Scenario: Change e-mail address | |
When I follow "Edit user account" | |
And I fill in "E-mail" with "[email protected]" | |
And I press "Update user account" | |
Then I should see a confirmation message | |
And my "E-mail" should be "[email protected]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# it doesn't work with the following step definitions because .. | |
Given /^I am signed in as a user$/ do | |
@user = Factory.create(:user) | |
# [..] sign in | |
end | |
Then /^my "([^"]*)" should be "([^"]*)"$/ do |key, value| | |
key = clean_attribute_name(key) | |
@user[key].should == value | |
end | |
# .. the @user object doesn't automatically pull updates from the database |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# in order to get it to work we've to pull changes manually from the database | |
Then /^my "([^"]*)" should be "([^"]*)"$/ do |key, value| | |
key = clean_attribute_name(key) | |
@user.reload # pull changes from the database | |
@user[key].should == value | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment