Cucumber cheat sheet

Cucumber cheat sheet is very hard to find. Trying to find it, you will most likely find Capybara cheat sheet, which imposes as ‘Cucumber’, but in fact, those are two different things. Here, I am going to list the common list of Cucumber steps used in tests:

Form interaction

And I click on "Some button"
And I fill in "some_input_field_id" with "Useful content"
And I select "Something" from "dropdown_id"

Wasn’t that easy? One step that would need special definition in Capybara in order to be user as Cucumber steps are selecting a checkbox. Here is an example how it should look like:

When /^(?:|I )check "([^"]*)"$/ do |field|

When /^(?:|I )uncheck "([^"]*)"$/ do |field| 

In order to check if checkbox is checked:

Then /^Checkbox "([^"]*)" should be checked$/ do |checkbox|
page.has_checked_field?("#{checkbox}").should be_true

Then /^Checkbox "([^"]*)" should be unchecked$/ do |checkbox|
page.has_checked_field?("#{checkbox}").should be_false

Some additional Cucumber cheat sheet steps would include confirmation of expectations:

Then I should see "My awesome cucumber test"

If you would like to submit a form via Cucumber, you could write definition like this:

When /^I submit form within "(.+)"$/ do |id|
within("##{id}") do

This was a small list of basic Cucumber cheat sheet steps. Hope you’ll find it useful.

For more reference, you can refer directly to the documentation