2 options
Rails 5 test prescriptions : build a healthy codebase / Noel Rappin ; edited by Katharine Dvorak.
- Format:
- Book
- Author/Creator:
- Rappin, Noel, author.
- Series:
- Pragmatic programmers.
- Pragmatic Programmers
- Language:
- English
- Subjects (All):
- Ruby on rails (Electronic resource).
- Web site development.
- Physical Description:
- 1 online resource (388 pages) : illustrations.
- Edition:
- Version: P1.0 (February 2018).
- Place of Publication:
- Raleigh, North Carolina : The Pragmatic Bookshelf, 2018.
- System Details:
- text file
- Summary:
- Does your Rails code suffer from bloat, brittleness, or inaccuracy? Cure these problems with the regular application of test-driven development. You'll use Rails 5.1, Minitest 5, and RSpec 3.6, as well as popular testing libraries such as factory_girl and Cucumber. Updates include Rails 5.1 system tests and Webpack integration. Do what the doctor ordered to make your applications feel all better. Side effects may include better code, fewer bugs, and happier developers. Your Ruby on Rails application is sick. Deadlines are looming, but every time you make the slightest change to the code, something else breaks. Nobody remembers what that tricky piece of code was supposed to do, and nobody can tell what it actually does. Plus, it has bugs. You need test-driven development: a process for improving the design, maintainability, and long-term viability of software. With 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, work with popular third-party testing tools such as RSpec, Jasmine, Cucumber, and factory_girl. Test the component parts of a Rails application, including the back-end model logic and the front-end display logic. With Rails examples, use testing to enable your code to respond better to future change. Plus, see how to handle real-world testing situations. This new edition has been updated to Rails 5.1 and RSpec 3.6 and contains full coverage of new Rails features, including system tests and the Webpack-based JavaScript setup. What You Need: Ruby 2.4, Rails 5.1
- Contents:
- Cover
- Table of Contents
- Acknowledgments
- Preface
- Who You Are
- What's in This Book
- What You'll Need
- A Word About Tools, Best Practices, and Teaching TDD
- Changes in This Edition
- Online Resources
- 1. A Test-Driven Fable
- Testing First Drives Design
- What Is TDD Good For?
- When TDD Needs Some Help
- What You've Done
- 2. Test-Driven Development Basics
- Infrastructure
- The Requirements
- Installing RSpec
- Where to Start?
- Running the Test
- Making the Test Pass
- The Second Test
- Back on Task
- Adding Some Math
- The First Date
- Using the Time Data
- 3. Test-Driven Rails
- Let's Write Some Rails
- The Days Are Action-Packed
- Who Controls the Controller?
- A Test with a View
- Testing for Failure
- 4. What Makes Great Tests
- The Big One
- Cost and Value
- SWIFT: The Five Qualities of Valuable Tests
- 5. Testing Models
- What Can You Do in a Model Test?
- What Should You Test in a Model Test?
- Okay, Funny Man, What Makes a Good Set of Model Tests?
- Refactoring Models
- A Note on Assertions per Test
- Testing What Rails Gives You
- Testing ActiveRecord Finders
- Testing Shared Modules and ActiveSupport Concerns
- Writing Your Own RSpec Matchers
- 6. Adding Data to Tests
- What's the Problem?
- Fixtures
- Factories
- Dates and Times
- 7. Using Test Doubles as Mocks and Stubs
- Test Doubles Defined
- Creating Stubs
- Mock Expectations
- Using Mocks to Simulate Database Failure
- Using Mocks to Specify Behavior
- More Expectation Annotations
- Mock Tips
- 8. Integration Testing with Capybara and Cucumber
- A Field Guide to Integration and System Tests
- Setting Up Capybara
- Using Feature Tests to Build a Feature.
- What to Test in an RSpec System Test
- Outside-in Testing
- Making the Capybara Test Pass
- Retrospective
- Setting Up Cucumber
- Writing Cucumber Features
- Writing Cucumber Steps
- Advanced Cucumber
- Is Cucumber Worth It?
- 9. Testing JavaScript: Integration Testing
- Integration-Testing JavaScript with Capybara
- Let's Talk About Drivers
- Webpack in Developer Mode
- 10. Unit-Testing JavaScript
- Setting Up JavaScript Unit Tests
- Writing a Sample Test
- TDD in JavaScript
- Jasmine Matchers
- Testing Ajax Calls
- Using testdouble.js
- Connecting the JavaScript to the Server Code
- 11. Testing Rails Display Elements
- Testing Routes
- Testing Helper Methods
- Testing Controllers and Requests
- Simulating Requests
- What to Expect in a Request Spec
- Older Rails Controller Tests
- Testing Mailers
- Testing Views and View Markup
- Using Presenters
- Testing Jobs and Cables
- 12. Minitest
- Getting Started with Minitest
- Minitest Basics
- Running Minitest
- Minitest Setup
- Mocha
- System Tests and Others
- Minitest Helper Tests
- Minitest and Routing
- 13. Testing for Security
- User Authentication and Authorization
- Adding Users and Roles
- Restricting Access
- More Access-Control Testing
- Using Roles
- Protection Against Form Modification
- Mass Assignment Testing
- Other Security Resources
- 14. Testing External Services
- External Testing Strategy
- The Service Integration Test
- Introducing VCR
- Client Unit Tests
- Why an Adapter?
- Adapter Tests
- Testing for Error Cases
- Smoke Tests and VCR Options
- The World Is a Service
- 15. Troubleshooting and Debugging
- General Principles
- The Humble Print Statement.
- Git Bisect
- RSpec or Minitest Bisect
- Pry
- Common Rails Gotchas
- 16. Running Tests Faster and Running Faster Tests
- Running Smaller Groups of Tests
- Running Rails in the Background
- Running Tests Automatically with Guard
- Writing Faster Tests by Bypassing Rails
- Recommendations for Faster Tests
- 17. Testing Legacy Code
- What's a Legacy?
- Set Expectations
- Getting Started with Legacy Code
- Test-Driven Exploration
- Dependency Removal
- Find the Seam
- Don't Look Back
- Bibliography
- Index
- - SYMBOLS -
- - A -
- - B -
- - C -
- - D -
- - E -
- - F -
- - G -
- - H -
- - I -
- - J -
- - K -
- - L -
- - M -
- - N -
- - O -
- - P -
- - Q -
- - R -
- - S -
- - T -
- - U -
- - V -
- - W -
- - X -
- - Y -.
- Notes:
- Includes bibliographical references and index.
- Description based on online resource; title from PDF title page (EBC, viewed April 6, 2018).
- ISBN:
- 9781680505573
- 1680505572
- 9781680505566
- 1680505564
- 9781680505580
- 1680505580
- 9781680502503
- 1680502506
- OCLC:
- 1030304591
The Penn Libraries is committed to describing library materials using current, accurate, and responsible language. If you discover outdated or inaccurate language, please fill out this feedback form to report it and suggest alternative language.