O'Reilly logo

Effective Testing with RSpec 3 by Myron Marston, Ian Dees

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

Getting the Words Right

Specs can’t exist on their own. From the first spec you wrote while reading this book, every spec has been part of an example group. The example group fulfills the role of a test case class in other test frameworks. It has multiple purposes:

  • Gives a logical structure for understanding how individual examples relate to one another

  • Describes the context—such as a particular class, method, or situation—of what you’re testing

  • Provides a Ruby class to act as a scope for your shared logic, such as hooks, let definitions, and helper methods

  • Runs common setup and teardown code shared by several examples

Let’s look at a few different ways to create these groups.

The Basics

We saw the basic ways to organize specs in Groups, Examples, ...

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