TL;DR
This is chapter 03 on our journey to awesome browser automation. In this chapter, we add two cucumber steps and two scenarios. We run Cucumber features using the HTML report option.
In this pull request, you can observe changed files from chapter 03:
.gitignore
we added report.html to .gitignore because this is Cucumber run a report in HTML format that we do not need to have in repo because this is Cucumber run result.
features/home.feature
This is a cucumber feature file with two scenarios.
features/step_definitions/home.rb
In this file, we have steps implementation for the home page. @browser and @app are global variables initialized in env.rb. Steps English language is defined between // characters. It uses regex characters begin ^ and end $ of string. Except is the RSpec DSL keyword. It is an RSpec matcher. We can also call expect as a check or assert. It will throw an exception if the condition is false. @browser is an instance of the Watir Browser class.
features/support/env.rb
As humans are error machines, in chapter 02, we had wrong key values in application yml class for SITE and HEADLESS variables.
That is it. Now run those two scenarios using:
cucumber -f HTML -o report.html
And then open report.html in the browser. The report shows one failure that we made on purpose. We put expect condition that we know it will fail.
Now set HEADLESS to true and run again:
cucumber -f HTML -o report.html