Skip to content

Instantly share code, notes, and snippets.

@jmaicher
Created December 4, 2010 12:56
Show Gist options
  • Save jmaicher/728159 to your computer and use it in GitHub Desktop.
Save jmaicher/728159 to your computer and use it in GitHub Desktop.
Testing attribute changes in the database with cucumber
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 "new_email@example.com"
And I press "Update user account"
Then I should see a confirmation message
And my "E-mail" should be "new_email@example.com"
# 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
# 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