Cucumber and Tips(briefly)
Scenarios
● Written in YAML
● Scenario: Eat Cake
given there is cake
when I go to the cake page
and I press “Eat Cake”
then I should see “There is no more cake”
Get clients or stakeholders in on the writing
●
process.
Steps
When /^I go to (.+)$/ do |page_name|
visit path_to(page_name)
end
Generic is better.
Dealing with slow test suites
Just target one feature:
Cucumber features/[Link]
Specify by line number:
Cucumber features/[Link]:29
Avoid Excessive Givens
● Each given loads data and is held in a
transaction for the scenario.
● Seed data where possible rather than
establishing it in givens
Tagging features
● Tag features and scenarios with :
@tag @tag2
Feature: cake
● Run specific tags with:
cucumber --tags @tag
● The @wip tag applies automatically to all
features currently unfinished.
Validate your HTML
● Throw in a step to validate your HTML
● markup_validity gem
Then %r/the page is valid XHTML/ do
$[Link] be_xhtml_strict if ENV["VALIDATION"]
end
● Equal opportunity for front end people to get
laughed at for breaking the build.