O'Reilly logo

The Cucumber Book, 2nd Edition by Steve Tooke, Aslak Hellesoy, Matt Wynne

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding an Assertion

So, following Cucumber’s lead, we need to create a Ruby file for our program. Let’s just create an empty Ruby file for the time being so that we can stay on the outside and get the test finished before we go on to the solution. Linux/Mac users can type this to create an empty file:

 $ ​​touch​​ ​​calc.rb

If you’re using Windows, there is no touch command, so either just create an empty text file named calc.rb in your editor or use this little trick:

 C:\>​​ ​​echo.>calc.rb

When we run cucumber again, we should see that the second step is passing and we’re on to the final step:

 $ ​​cucumber​​ ​​--format​​ ​​progress
 ..P
 
 (::) pending steps (::)
 
 features/step_definitions/calculator_steps.rb:14:in ‘/^the output ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required