• Title: Rails Test Prescriptions
  • Author: Noel Rappin
  • Length: 350 pages
  • Edition: 1
  • Language: English
  • Publisher: Pragmatic Bookshelf
  • Publication Date: 2011-03-07
  • ISBN-10: 1934356646
  • ISBN-13: 9781934356647
  • Sales Rank: #3327330 (See Top 100 Books)


Your Ruby on Rails application is sick. It's got bugs. Nobody remembers what that tricky piece of code was supposed to do, and nobody can tell what it actually does. Deadlines are looming, but every time you make the slightest change to the code, something else breaks.

You need Test-Driven Development (TDD), a proven process for improving the design, maintainability, and long-term viability of software. In TDD, the tests come first, and then code is written to match the expectation of the test. Using TDD means writing better code faster.

Ruby on Rails has unparalleled support for TDD. In addition to the tools that Rails has built-in, a large and thriving testing community adds new tools at an accelerating rate. Rails Test Prescriptions is your guide to the entire Rails testing ecosystem.

Containing both practical code examples and discussion of why testing works, this book starts with the most basic features delivered as part of core Ruby on Rails. Once you've integrated those features into your coding practice, you'll want to use popular third-party testing tools such as RSpec, Shoulda, Cucumber, Factory Girl, and Rcov. Rails Test Prescriptions will show you how to use these tools and when they are appropriate. Rails Test Prescriptions will cover both the current Rails 2.3.x version as well as the initial 3.0 release.

If you are a Rails programmer who tests code, this book is an invaluable guide to the latest in available testing tools. If you are a Rails programmer who doesn't test code, then start testing immediately: this book can help.

Table of Contents

Part 1 Getting Started with Testing in Rails
Chapter 1 The Goals of Automated Developer Testing
Chapter 2 The Basics of Rails Testing
Chapter 3 Writing Your First Tests
Chapter 4 TDD, Rails Style

Part 2 Testing Application Data
Chapter 5 Testing Models with Rails Unit Tests
Chapter 6 Creating Model Test Data with Fixtures and Factories
Chapter 7 Using Mock Objects

Part 3 Testing User-Facing Layers
Chapter 8 Testing Controllers with Functional Tests
Chapter 9 Testing Views
Chapter 10 Testing JavaScript and Ajax

Part 4 Testing Framework Extensions
Chapter 11 Write Cleaner Tests with Shoulda and Contexts
Chapter 12 RSpec

Part 5 Testing Everything All Together
Chapter 13 Testing Workflow with Integration Tests
Chapter 14 Write Better Integration Tests with Webrat and Capybara
Chapter 15 Acceptance Testing with Cucumber

Part 6 Testing Your Tests
Chapter 16 Using Rcov to Measure Test Coverage
Chapter 17 Beyond Coverage: What Makes Good Tests?
Chapter 18 Testing a Legacy Application
Chapter 19 Performance Testing and Performance Improvement
appendix.A Sample Application Setup
appendix.B Bibliography