Created
September 13, 2010 12:11
-
-
Save jstirk/577206 to your computer and use it in GitHub Desktop.
Examples for my post at http://griffin.oobleyboo.com/archive/our-3-laws-of-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
# This was ripped from one of our Webrat suites - Capybara would be similar, but slightly different... | |
Then /^I should( not)? see "([^\"]*)" in (.+)$/ do |negatory, text, area| | |
within(selector_for(area)) do |content| | |
if negatory.blank? then | |
content.should contain(text) | |
else | |
content.should_not contain(text) | |
end | |
end | |
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 am on the login page | |
And I fill in "Username" with "joe" | |
And I fill in "Password" with "password" | |
And I press "Log In" | |
Then I should be on the dashboard | |
And I should see "Welcome back, Joe!" in the notification area |
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 am logged in as joe |
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 am on the Dashboard | |
# And I follow "Little Johnny" | |
# Then I should be on the Student page for "Little Johnny" | |
# In paths.rb : | |
when /the Student page for "([^"]+)"/i | |
user=User.find_by_name($1) | |
"/classes/#{user.school_classes.first.id}/students/#{user.id}" |
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
Then I should see "Welcome Back, Jason!" in the notification area |
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
# Put this in features/support/selectors.rb | |
module AreaHelpers | |
# Maps a name to a selector. | |
def selector_for(area_name) | |
case area_name | |
when /^"(.*)"$/ | |
$1 | |
when /the notification area/ | |
'#notice' | |
when /the error message/ | |
'#error' | |
when /the menu/ | |
'#menu' | |
when /the sidebar/ | |
'#sidebar' | |
when /the requests table/ | |
'table#requests' | |
when /the history/ | |
'.history' | |
# Add more mappings here. | |
else | |
raise "Can't find mapping from \"#{area_name}\" to a selector.\n" + | |
"Now, go and add a mapping in #{__FILE__}" | |
end | |
end | |
end | |
World(AreaHelpers) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment