售 价:¥
温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印
为你推荐
RSpec Essentials
Table of Contents
RSpec Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
eBooks, discount offers, and more
Why subscribe?
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. Exploring Testability from Unit Tests to Behavior-Driven Development
The promise of testing
Testability
Technical assumptions
Running our first spec
Understanding the unit test
Writing specs with RSpec
Test-driven development
Behavior-driven development
Summary
2. Specifying Behavior with Examples and Matchers
Structure of a spec file
Using let and context
Matchers
Built-in matchers
Custom matchers
Enhanced context in matcher output
Creating a good custom error message
Improving application code
Testing for errors
Summary
3. Taking Control of State with Doubles and Hooks
Why mock?
Mocks, stubs, and doubles
Using hooks
Controlling when hooks are executed
Advanced state control with hooks and mocks
Summary
4. Setting Up and Cleaning Up
Configuring RSpec with spec_helper.rb
Initialization and configuration of resources
A case study of test simplicity with an external service
A case study of production faithfulness with a test resource instance
Summary
5. Simulating External Services
The importance of external web services
Mock HTTP responses with custom helpers
Using real-world requests for mock responses
Using WebMock for mock HTTP requests
Using VCR for mock requests
Summary
6. Driving a Web Browser with Capybara
Getting started with Capybara and Selenium
Integrating Capybara with RSpec
Why Capybara?
Black-box JavaScript tests with a real browser
Summary
7. Building an App from the Outside In with Behavior-Driven Development
Exploring BDD
MMFs by example
Using TodoMVC
Specifying the MMF
Configuring RSpec to run a feature file
The BDD process begins
Building web apps with Rack
Serving static files using Rack middleware
Summary
8. Tackling the Challenges of End-to-end Testing
Step 1 – building the view
Step 2 – defining the API
Step 3 – finishing the view
The pros and cons of BDD
Simple Rack authentication middleware
JSON Web Token
Summary
9. Configurability
Configuration and testability
What is so important about configuration?
What does all this have to do with testing?
File-based configuration management
A better configuration manager
Summary
10. Odds and Ends
Reducing duplication with shared example groups
Mocking time
Detecting false negatives and false positives
Testing mixins with dummy containers
Summary
Index
买过这本书的人还买过
读了这本书的人还在读
同类图书排行榜