Efficient Cucumber Step Regex Matching

TL:DR Avoid using Cucumber Expression if possible. Using the conventional regular expression Cucumber is key to more flexible, reusable and customisable test code. When writing cucumber step definitions, developers and testers often face difficulties capturing parameters in test steps while ensuring that the steps flow smoothly in natural English sentences. Without a good knowledge of general regex, step definitions can appear clunky, even when using Cucumber Expressions to capture step definitions parameters....

June 7, 2023 · 7 min · 1380 words · Choon Meng Yap

FakerMaker Initialisation

In the world of automation testing, generating realistic-looking test data is a preferred approach to using static fixtures. FakerMaker is a Ruby gem that allows you to do just that; using factories to create the test data you need. It can be used with Faker to dynamically generate test data. Initialisation We can use Faker and FakerMaker to create a factory for an API request body like this: require 'faker' require 'faker_maker' FakerMaker....

May 17, 2023 · 2 min · 333 words · Mark Isaac

Testing Standard-Out in Ruby

Testing what a Ruby process writes to STDOUT. Ruby’s relationship with STDOUT Ruby has two built-in values that represent the system’s standard output stream: The constant STDOUT The global variable $stdout The Ruby documentation, describes STDOUT as the standard output, and $stdout and the current standard output. If you want to change the stream that this Ruby process sends its output to, you can change the value of $stdout Hello StringIO Given an RSpec test pack, I should be able to use an output matcher, but I couldn’t get this to reliably work across tests for my system....

May 15, 2023 · 1 min · 142 words · Nigel Brookes-Thomas