Use nested step to improve readability of ur scenario
27 Jul 2010
Before:
Scenario: Accessing create post page
Given flyerhzm exists
And a post exists with title: "first best practice"
And I go to login page
And I fill in "Username" with "flyerhzm"
And I fill in "Password" with "flyerhzm"
And I press "Login"
When I follow "Submit"
Then I should see "Share a Rails Best Practice" page
After:
Scenario: Accessing create post page
Given I am already signed in as "flyerhzm"
When I follow "Submit"
Then I should see "Share a Rails Best Practice" page
And the corresponding step definition:
# features/step_definitions/custom_web_steps.rb
Given %r{^I am already signed in as "([^"]*)"$} do |someone|
user = Factory.build(someone)
Given "#{someone} exists" rescue nil
And %|I go to login page|
And %|I fill in "Username" with "#{user.login}"|
And %|I fill in "Password" with "#{user.password}"|
And %|I press "Login"|
end
Tags cucumber