RSpec and Behavior-Driven Development
RSpec bills itself as a behavior-driven development (BDD) test framework. We’d like to take a moment to talk about our use of that term, along with a related term, test-driven development (TDD).
Without TDD, you might check your program’s behavior by running it manually or by writing a one-off test harness. In situations where you intend to scrap the program shortly afterward, these approaches are all right. But when long-term maintenance is a priority, TDD provides important benefits.
With TDD, you write each test case just before implementing the next bit of behavior. When you have well-written tests, you wind up with more maintainable code. You can make changes with the confidence that your test suite ...
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.