-
Notifications
You must be signed in to change notification settings - Fork 4
Cucumber Integration
bfaloona edited this page Sep 13, 2010
·
1 revision
Cucumber Feature files contain Scenarios, which are each comprised of a sequence of Steps. For example:
Scenario: Search for keyword Given I am on the home page And I enter Blagojevich in the search field When I press the search button Then I should see a list of items matching Blagojevich
Steps Definitions are invoked when a Feature file executes. According to the cucumber steps definition page:
A step definition is analogous to a method definition / function definition in any kind of OO/procedural programming language. Step definitions can take 0 or more arguments, identified by groups in the Regexp (and an equal number of arguments to the Proc).
Steps Definition files are .rb
files and can be named anything as long as they are located in the /lib/steps
folder
A new steps file, generated with WatirCraft’s steps generator, will have this skeleton:
require 'spec' $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/..') require 'projectname' # Given "" do # end
In the feature file example above, one step in the scenario is: And I enter Blagojevich in the search field
. The Step Definition for that step might look something like this:
Then /^I enter (.*) in the search field$/ do |search_term|
search_page.query_textbox = search_term
end