2

The docs at https://github.com/cucumber/cucumber/wiki/Step-Definitions are great and have tons of detail. They're a bit overwhelming for a newbie to cucumber.
I just want to understand how my englishy spec will relate to the code it will execute and what files to put where. What is a high level summary of that ?

Michael Durrant
  • 25,210
  • 3
  • 40
  • 112

1 Answers1

2

For this spec:

Feature: Buy car

  Scenario: Jeff buys a car
    Given Jeff sees a car he want
    And he has the cash
    When he pays cash
    Then Jeff should own the car

The above spec file is called buy_car.feature and is placed in /spec/features/

The steps (Given, When, Then) inside Scenario: Jeff buys a car will reference the ruby file spec/features/step_definitions/buy_car_steps.rb which will have content like this:

Given("Jeff sees a car he wants") do |car|
  perform capybara action to display car, e.g. visit, click, etc.
end
When("he pays cash") do |pay|
  perform payment actions (front or back end as desired)
end
And("he has the cash") do |cash_check|
  perform code to check bank balance is sufficient
end
...

I think this is right for where stuff goes and how it is named but welcome review and any correction. I've always found the cucumber docs a little hard to get started with so wanted to help with another simple example for folks getting started.

Michael Durrant
  • 25,210
  • 3
  • 40
  • 112