Book Image

RSpec Essentials

By : Mani Tadayon
Book Image

RSpec Essentials

By: Mani Tadayon

Overview of this book

This book will teach you how to use RSpec to write high-value tests for real-world code. We start with the key concepts of the unit and testability, followed by hands-on exploration of key features. From the beginning, we learn how to integrate tests into the overall development process to help create high-quality code, avoiding the dangers of testing for its own sake. We build up sample applications and their corresponding tests step by step, from simple beginnings to more sophisticated versions that include databases and external web services. We devote three chapters to web applications with rich JavaScript user interfaces, building one from the ground up using behavior-driven development (BDD) and test-driven development (TDD). The code examples are detailed enough to be realistic while simple enough to be easily understood. Testing concepts, development methodologies, and engineering tradeoffs are discussed in detail as they arise. This approach is designed to foster the reader’s ability to make well-informed decisions on their own.
Table of Contents (17 chapters)
RSpec Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Exploring BDD


We have discussed testing and testability with a view to ensuring high-quality code. But what about the feature itself? What use are excellent code and tests if the feature itself is bad? Indeed, software engineers have struggled to find ways of improving the overall quality of the system they work on. One of the more successful, and more popular, methods of addressing the problem of feature or product quality in software is BDD, which was developed in the mid-2000s by Dan North, Martin Fowler, and Aslak Hellesoy. This methodology seeks to describe the behavior of software from the outside in and justify this behavior in terms of business value. BDD developed alongside RSpec, which was the first widely used BDD framework. Therefore, it is natural that we explore the methodology so that we understand the motivation behind RSpec itself.

BDD concerns itself with ensuring that the right software is developed. Contrast this with our typical concern when writing tests, which is to...