Ruby On Rails Lesson
Features and Steps
Cucumber features are descriptions of expected behavior using a plain-text language called Gherkin. Gherkin tests read much like well-written RSpec examples, but because they are plain-text they are more accessible to those more comfortable reading English than Ruby code.
OurCucumberfeatureswill implement a subset of thesignin examplesin Listing 8.5 and Listing 8.6. To get started, we’ll create a file in the features/ directory called signing_in.feature.
Cucumber features start with a short description of the feature, as follows:
Then they add individual scenarios. For example, to test unsuccessful signin, we could write the following scenario:
Similarly, to test successful signin, we could add this:
Collecting these together yields the Cucumber feature file shown in Listing 8.32.
To run the features, we use the cucumber executable:
Compare this to