RSpec, Testing in Ruby — Part 1.5

The sequel

Daniel Glover
2 min readJul 15, 2019

Initially, I was hoping to write a full part 2, but as I’m strapped for time this week — part 2 will have to be published into two parts. So, let’s consider this part 1.5.

Here we go

In this blog, we’re going to cover format configuration options.

Format Defaults

When we run our tests in the console, RSpec will have default format options to display passing, failing and pending tests.
We can configure these format options however, so we can display as little or as much information as we need.

The default option is to output green dots for passing tests, yellow stars for pending, and red Fs for — you guessed it — failures!

We can configure our formatting options inside our test suite, and display clearer, more informative test outputs.

Remember how we wrote describe blocks, we can write configure blocks pretty much the same way, except we pass it a single argument (config).

Then, we can set the formatter option to documentation. This will print out the string arguments of our it blocks.

Remember our it blocks?

We’ll now see our descriptions displayed…

Come back next week for RSpec, Testing in Ruby — Part 2, where we’ll cover setting tests variables, and other cool stuff.

--

--