Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
Effective Testing with RSpec 3
About the Pragmatic Bookshelf
Table of Contents
Early praise for Effective Testing with RSpec 3
Foreword
Acknowledgments
From Myron Marston
From Ian Dees
Introduction
How to Use This Book
Code Snippets
RSpec and Behavior-Driven Development
Who We Are
Who You Are
A Note on Versions
Online Resources
Part 1: Getting Started
Installing RSpec
Your First Spec
Understanding Failure
Sharing Setup (But Not Sandwiches)
Your Turn
Customizing Your Spec s’ Output
Identifying Slow Examples
Running Just What You Ne ed
Marking Work in Progress
Your Turn
What Your Specs Are Doing for You
Comparing Costs and Benefits
Different Types of Specs
Guidelines
Part 2: Building an App With RSpec 3
First Steps
Deciding What to Test First
Checking the Response
Filling In the Response Body
Querying the Data
Saving Your P rogress: Pending Specs
Your Turn
From Acceptance Specs to Unit Specs
Filling In the First Spec
Handling Success
Refactoring
Handling Failure
Defining the Ledger
Your Turn
Hooking Up the Database
Testing Ledger Behavior
Testing the Invalid Case
Isolating Your Specs Using Database Transactions
Filling In the Behavior
Querying Expenses
Ensuring the Application Works for Real
Your Turn
Part 3: RSpec Core
Getting the Words Right
Sharing Common Logic
Sharing Example Groups
Your Turn
Defining Metadata
Reading Metadata
Selecting Which Specs to Run
Sharing Code Conditional ly
Changing How Your Specs Run
Your Turn
Command-Line Configuration
Setting Command-Line Defaults
Using a Custom Formatter
RSpec.configure
Your Turn
Part 4: RSpec Expectations
Parts of an Expectation
Ho w Matchers Work
Composing Matchers
Generated Example Descriptions
Your Turn
Primitive Matchers
Higher-Order Matchers
Block Matchers
Your Turn
Delegating to Existing Matchers Using Helper Methods
Defining Matcher Aliases
Negating Matchers
Using the Matcher DSL
Defining a Matcher Class
Your Turn
Part 5: RSpec Mocks
Types of Test Doubles
Usage Modes: Mocks, Stubs, and Spies
Origins: Pure, Partial, and Verifying Doubles
Your Turn
Configuring Responses
Setting Constraints
Your Turn
Constructing Your Test Environment
Stubject (Stubbing the Subject)
Using Partial Doubles Effecti vely
Connecting the Test Subject to Its Environmen t
The Risks of Mocking Third-Party C ode
High-Fidelity Fakes
Faking I/O with StringIO
Wrapping a Third-Party Dependency
Your Turn
Appendix 1: RSpec and the Wider Ruby Ecosystem
Bundler
Rake
Using Parts of RSpec With Oth er Test Frameworks
Appendix 2: Using RSpec with Rails
Installation
Using rspec-rails
Spec Types
Spec Types Cheat Sheet
Rails Matchers Cheat Sheet
Appendix 3: Matcher Cheat Sheet
Value Matchers
Block Matchers
Appendix 4: Bibliography
You May Be Interested In…
← Prev
Back
Next →
← Prev
Back
Next →