Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
Rails Test Prescriptions
Table of Contents
Part 1 Getting Started with Testing in Rails
1: The Goals of Automated Developer Testing
A Testing Fable
Who Are You?
The Power of Testing First
What Is TDD Good For?
When TDD Needs Some Help
Coming Up Next...
Acknowledgments
2: The Basics of Rails Testing
What ’s a Test?
What Goes in a Test?
Setup and Teardown
What Can You Test in Rails?
What Happens When Tests Run?
Running the Rails Tests
More Info: Getting Data into the Test
Beyond the Basics
3: Writing Your First Tests
The First Test-First
The First Refactor
More Validations
Security Now!
Applying Security
Punishing Miscreants
Road Map
4: TDD, Rails Style
Now for a View Test
Testing the Project View: A Cascade of Tests
So Far, So Good
Part 2 Testing Application Data
5: Testing Models with Rails Unit Tests
What ’s Available in a Model Test
What to Test in a Model Test
OK, Funny Man, What Is a Good Model Test Class?
Asserting a Difference, or Not
Testing Active Record Finders
Coming Up Next
6: Creating Model Test Data with Fixtures and Factories
Defining Fixture Data
Loading Fixture Data
Why Fixtures Are a Pain
Using Factories to Fix Fixtures
Data Factories
Installing factory_girl
Creating and Using Simple Factories
Sequencing for Unique Attributes
Freedom of Association
Factories of the World Unite: Preventing Factory Abuse
Managing Date and Time Data
Model Data Summary
7: Using Mock Objects
What ’s a Mock Object?
Stubs
Stubs with Parameters
Mock, Mock, Mock
Mock Objects and Behavior-Driven Development
Mock Dos and Mock Don ’ts
Comparing Mock Object Libraries
Mock Object Summary
Part 3 Testing User-Facing Layers
8: Testing Controllers with Functional Tests
What ’s Available in a Controller Test?
What to Test
Simulating a Controller Call
Testing Controller Response
Testing Returned Data
Testing Routes
Coming Up
9: Testing Views
The Goals of View Testing
Keys to Successful View Testing
Using assert_select
Testing Outgoing Email
Testing Helpers
Testing Block Helpers
Using assert_select in Helper Tests
How Much Time Should You Spend on Helpers?
When to View Test
10: Testing JavaScript and Ajax
First Off, RJS
Testing JavaScript from Rails with Jasmine
Getting Started with Jasmine
Running Jasmine Tests
Writing Jasmine Tests
Integrating Jasmine with Dynamic Rails
Part 4 Testing Framework Extensions
11: Write Cleaner Tests with Shoulda and Contexts
Contexts
Basics of Shoulda
Single Assertion Testing
Shoulda Assertions
Shoulda One-Liners
Writing Your Own Shoulda Matcher
Single-Line Test Tools
When to Use Shoulda
12: RSpec
Getting Started with RSpec
RSpec in Ten Minutes
RSpec and Rails
Running RSpec
RSpec in Practice
Creating Your Own Matchers
Summarizing RSpec
Part 5 Testing Everything All Together
13: Testing Workflow with Integration Tests
What to Test in an Integration Test
What ’s Available in an Integration Test?
Simulating Multipart Interaction
Simulating a Multiuser Interaction
When to Use Integration Tests
14: Write Better Integration Tests with Webrat and Capybara
Installing Webrat and Capybara
Using the Acceptance Testing Rodents
A Brief Example
Webrat and Ajax
Capybara and Ajax
Why Use the Rodents?
15: Acceptance Testing with Cucumber
Getting Started with Cucumber
Writing Cucumber Features
Writing Cucumber Step Definitions
Making Step Definitions Pass
The Edit Scenario: Specifying Paths
Login and Session Issues with Cucumber
Annotating Cucumber Features with Tags
Implicit vs. Explicit Cucumber Tests
Is Cucumber Good for You?
Part 6 Testing Your Tests
16: Using Rcov to Measure Test Coverage
85 Percent of What?
Installing Rcov
Rcov and Rails
Rcov Output
Command-Line Rcov
Rcov and RSpec and Cucumber
Rcov Tricks
How Much Coverage Is Enough?
17: Beyond Coverage: What Makes Good Tests?
The Five Habits of Highly Successful Tests
Troubleshooting
From Greenfield to Legacy
18: Testing a Legacy Application
Accept That You ’re Powerless in the Face of a Higher Power
Basic Setup
Test-Driven Exploration
Dependency Removal
Don ’t Look Back
19: Performance Testing and Performance Improvement
Performance and Benchmark Testing
Focusing Test Execution
Using Autotest
Making Your Tests Faster
Using a Faster Test Runner
And in the End...
20: Sample Application Setup
Basic Rails
Devise
Huddle ’s Data Models
First Tests
21: Bibliography
← Prev
Back
Next →
← Prev
Back
Next →