Skip to content

Instantly share code, notes, and snippets.

@thecatwasnot
Forked from onthespotqa/cucumber
Created October 6, 2011 23:11
Show Gist options
  • Save thecatwasnot/1268965 to your computer and use it in GitHub Desktop.
Save thecatwasnot/1268965 to your computer and use it in GitHub Desktop.
cucumber examples
Feature: Cucumber Question
Scenario Outline: Google Search for <search term>
Given I am on Google Search Home Page
When I search for "<Search Term>"
Then I should find "<Search Term>"
Examples:
| Search Term |
| Facebook |
| Delicious |
step definitions:
Given /^I am on Google Search Home Page$/ do
@site.browser.title == "Google"
end
When /^I search for "([^"]*)"$/ do |arg1|
@site.google_search.search_field.set arg1
end
Then /^I should find "([^"]*)"$/ do |arg1|
@site.google_search_page.text.include? arg1
@site.browser.close
end
errors
wrong number of arguments (0 for 1) (ArgumentError)
./features/step_definitions/google_steps.rb:10:in `google_search'
./features/step_definitions/google_steps.rb:10:in `/^I search for "([^"]*)"$/'
features/google.feature:4:in `When I search for "<Search Term>"'
wrong number of arguments (0 for 1) (ArgumentError)
./features/step_definitions/google_steps.rb:10:in `google_search'
./features/step_definitions/google_steps.rb:10:in `/^I search for "([^"]*)"$/'
features/google.feature:4:in `When I search for "<Search Term>"'
Failing Scenarios:
cucumber features/google.feature:2 # Scenario: Google Search for <search term>
cucumber features/google.feature:2 # Scenario: Google Search for <search term>
@thecatwasnot
Copy link
Author

the part after the do is kind of like an argument list, so if you want to try to use arg1, it should match on both lines

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment