Articles liés à RSpec Essentials

RSpec Essentials - Couverture souple

Mani Tadayon

 
9781784395902: RSpec Essentials

Synopsis

Develop testable, modular, and maintainable Ruby software for the real world using RSpec

About This Book

  • Explore the concept of testability and how to implement tests that deliver the most value
  • Maximize the quality of your Ruby code through a wide variety of tests
  • Master the real-world tradeoffs of testing through detailed examples supported by in-depth discussion

Who This Book Is For

This book is aimed at professional test engineers who are looking to automate their testing of complex systems or software engineers looking to make their code more reliable and their development process easier by using RSpec. Prior experience with automated testing and Ruby would be helpful but is not mandatory.

What You Will Learn

  • Identify a unit of software for the purposes of testing
  • Manage test state with hooks, fixtures, and mocks
  • Handle external web services in tests using various techniques
  • Configure RSpec flexibly and cleanly using support code and environment variables
  • Interact with rich web apps in tests using Capybara
  • Build the right feature with behavior-driven development
  • Customize matchers and failure messages
  • Verify correct development and production environments

In Detail

Automated testing has emerged as an important approach to improving reliability and maintainability. RSpec is one of the most mature and powerful testing tools for the Ruby programming language, and arguably for any language. Its vast array of features combined with its simple, intuitive syntax allow you to create a broad variety of automated tests, specifications, and examples. Not only can tests catch bugs, they can improve the quality of your Ruby code, encouraging modularity, and allowing changes to be made efficiently and with confidence.

In this book practical features are covered with a view to using simple, stable tools to develop sophisticated tests while avoiding fancy dead-ends.

Starting with some basics, such as automated testing and the concept of testability, we move on to show you how RSpec's examples and matchers implement the general testing concepts of units and assertions.

We also cover the general testing concept of stubs, mocks, and spies with double. Along with this you will explore hooks that manage fixture data and learn to organize your support code cleanly in your applications.

In the latter chapters, we'll look at some advanced techniques to manage external web services and you'll be guided through writing end-to-end tests for web applications. You will also implement the BDD approach to test a small to-do list manager with Capybara.

This book shows you how to use RSpec to write high-value tests that will improve the reliability and maintainability of your software.

Les informations fournies dans la section « Synopsis » peuvent faire référence à une autre édition de ce titre.

Présentation de l'éditeur

Key Features

  • Explore the concept of testability and how to implement tests that deliver the most value
  • Maximize the quality of your Ruby code through a wide variety of tests
  • Master the real-world tradeoffs of testing through detailed examples supported by in-depth discussion

Book Description

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.

What you will learn

  • Identify a unit of software for the purposes of testing
  • Manage test states with hooks, fixtures, and mocks
  • Handle external web services in tests using various techniques
  • Configure RSpec flexibly and cleanly using support code and environment variables
  • Interact with rich web apps in tests using Capybara
  • Build the right feature with behavior-driven development
  • Customize matchers and failure messages
  • Verify correct development and production environments

About the Author

Mani Tadayon first learned to program as a shy 7th grader on an Apple IIe using BASIC. He went on to learn Pascal, C++, Java, JavaScript, Visual Basic, and PHP before becoming a Ruby developer in 2008. With 15 years of experience in the software industry, he has developed expertise in web development, infrastructure, and testing. Mani's interests and education are broad, with degrees in foreign languages, computer science, and geography. He lives just far enough from Silicon Valley with his family and their many, many Shiba Inus.

Table of Contents

  1. Exploring Testability from Unit Tests to Behavior-Driven Development
  2. Specifying Behavior with Examples and Matchers
  3. Taking Control of State with Doubles and Hooks
  4. Setting Up and Cleaning Up
  5. Simulating External Services
  6. Driving a Web Browser with Capybara
  7. Building an App from the Outside In with Behavior-Driven Development
  8. Tackling the Challenges of End-to-end Testing
  9. Configurability
  10. Odds and Ends

Biographie de l'auteur

Mani Tadayon

Mani Tadayon first learned to program as a shy 7th grader on an Apple IIe using BASIC. He went on to learn Pascal, C++, Java, JavaScript, Visual Basic, and PHP before becoming a Ruby developer in 2008. With 15 years of experience in the software industry, he has developed expertise in web development, infrastructure, and testing. Mani's interests and education are broad, with degrees in foreign languages, computer science, and geography. He lives just far enough from Silicon Valley with his family and their many, many Shiba Inus.

Les informations fournies dans la section « A propos du livre » peuvent faire référence à une autre édition de ce titre.

Vos droits au titre de la garantie légale : Chaque consommateur de l'UE bénéficie d'au moins deux ans de protection au titre de la garantie légale pour tout bien de consommation vendu dans l'UE. Voir plus