Created
August 30, 2012 17:59
-
-
Save leviwilson/3535625 to your computer and use it in GitHub Desktop.
Reusing background steps
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
class LoginPage | |
include Gametel | |
text(:username, :index => 0) | |
text(:password, :index => 1) | |
def login_successfully | |
self.username = 'user' | |
self.password = 'secret' | |
on(LandingPage).should be_active | |
end | |
end | |
Given /^I have logged in successfully$/ | |
on(LoginPage).login_successfully | |
end |
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
When I login with 'user' / 'secret' | |
Then I am successfully logged in |
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
Given /^I have logged in successfully$/ | |
Given "I login with 'user' / 'secret' | |
Then "I am successfully logged in" | |
end |
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 have logged in successfully |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
General good rule of thumb is to strive to keep any technical stuff out of the cucumber steps.
I could probably take the 'as an "X" role' and make that even more english-like: 'I login as an Axial Admin' and do some magic behind the scenes. Deeper in the step implementation, you can see some other styles of reuse: