Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
# 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)
content.should_not contain(text)
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
Given I am logged in as joe
# 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
Then I should see "Welcome Back, Jason!" in the notification area
# Put this in features/support/selectors.rb
module AreaHelpers
# Maps a name to a selector.
def selector_for(area_name)
case area_name
when /^"(.*)"$/
when /the notification area/
when /the error message/
when /the menu/
when /the sidebar/
when /the requests table/
when /the history/
# Add more mappings here.
raise "Can't find mapping from \"#{area_name}\" to a selector.\n" +
"Now, go and add a mapping in #{__FILE__}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment