We cover:

  • How to arrange your specs into meaningful groups
  • How to “get the words right” with names for your groups
  • Where to put shared setup and teardown code

Chapter 7Structuring Code Examples

Now that you’ve used RSpec to design and build the beginnings of an application, you’ve got a mental model of “where things go.” You’ve written short, clear examples that explain exactly what the expected behavior of the code is. You’ve laid these examples out in logical groups—not only to share setup code, but to keep related specs together.

By the end of this chapter, you’ll be an organizational expert—for RSpec examples, at least. You’ll use RSpec’s flexible language to communicate your intent clearly when you organize your specs into groups. You’ll ...

Get Effective Testing with RSpec 3 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.