Log In
Join
for free
Back To Course Home
Fundamentals of Testing Using Rails
0% completed
Introduction
Who Should Take this Course and Why?
Tools, Best practices, and Teaching TDD
Test-Driven Fable
Test-Driven Development (TDD) Advantages
Testing First Drives Design
What is TDD Good For?
When TDD needs help
Summary
Test-Driven Development Basics
Infrastructure
Installing RSpec
Where to Start?
RSpec and Rails Features
RSpec Predefined Matchers
Running the Test
Making the Test Pass
The Second Test
Expectations and lit
Back on Task
Adding Some Math
The First Date
Using the Time Data
Summary
Test-Driven Rails
Let's Write Some Rails
End-to-End Testing
Pending Tests
Creating ActiveRecord Models
The Days Are Action-Packed
Going with the Workflow
Refactoring to Single-Assertion Specs
Who Controls the Controllers?
A Test with a View
Testing for Failure
Summary
What Makes a Great Test?
The Big One
Cost and Value
Straightforward: The First Quality of Valuable Tests
Well Defined: The Second Quality of Valuable Tests
Independent: The Third Quality of Valuable Tests
Fast: The Fourth Quality of Valuable Tests
Truthful: The Fifth Quality of Valuable Tests
Summary
Testing Models
What can We do in a Model Test?
A TDD Metaprocess
Refactoring Models
Combine Duplication
Find Missing Abstractions
A Note on Assertions Per Test
Testing What Rails Give Us
Testing ActiveRecord Finders
Testing Shared Modules and ActiveSupport Concerns
Writing RSpec Matchers
Summary
Adding Data to Tests
Getting Started with Testing Data
What's The Problem?
Fixtures
Loading Fixture Data
Why Fixtures are a Pain?
Factories
Basic Factory Definition
Basic Factory Creation
Associations and Factories
Managing Duplication in Factories
Dates and Times
Summary
Using Test Doubles as Mocks and Stubs
Problem
Test Doubles Defined
Creating Stubs
Partial Stubs
Mock Expectations
Using Mocks to Simulate Database Failure
Using Mocks to Specify Behavior
More Expectation Annotations
Mock Tips
Summary
Integration Testing with Capybara and Cucumber
A Field Guide to Integration and System Tests
Setting Up Capybara
Using Feature Tests to Build a Feature
The Capybara API: Interacting
The Capybara API: Querying
What to Test in an RSpec System Test
Outside-in Testing
Making the Capybara Test Pass
Retrospective
Setting Up Cucumber
Writing Cucumber Features
Advanced Cucumber
Is Cucumber Worth It?
Summary
Testing JavaScript: Integration Testing
Integration-Testing JavaScript with Capybara
Let’s Talk About Drivers
Making the Test Pass
Webpack in Developer Mode
Summary
Unit-Testing Javascript
Getting Started with Unit Testing Javascript
Setting Up Javascript Unit-Test
JavaScript Unit-Testing using Karma Module
Writing a Sample Test
TDD in Javascript
Jasmine matchers
Testing Ajax Calls
Using testdouble.js
Creating Test Doubles
Specifying Test Double Behavior
Verifying Test Doubles
Connecting the JavaScript to the Server Code
Summary
Testing Rails Display Elements
Getting Started
Testing Routes
Testing Helper Methods
Testing Helper Methods Blocks
Testing Controllers and Requests
Simulating Requests
What to Expect in a Request Spec
Older Rails Controller Tests
Testing Mailers
Testing Views and View Markup
What Does The View Test Do?
Using Presenters
Testing Jobs and Cables
Summary
Minitest
Getting Started with Minitest
Minitest Basics
Running Minitest
Minitest Setup
Mocha
System Tests and Others
Minitest Integration Tests
Minitest Helper Tests
Minitest and Routing
Summary
Testing for Security
Getting Started with Security Testing
User Authentication and Authorization
Adding Users and Roles
Restricting Access
More Access-Control Testing
Using Roles
More Roles Tests
Protection Against Form Modification
Mass Assignment Testing
Other Security Resources
Summary
Testing External Services
Getting Started with External Services
External Testing Strategy
The Service Integration Test
Introducing VCR
VCR and RSpec
VCR and Minitest
VCR and Cucumber
Client Unit Tests
Why an Adapter?
Adapter Tests
Testing for Error Cases
Smoke Tests and VCR Options
The World is a Service
Summary
Troubleshooting and Debugging
Getting Started with Troubleshooting and Debugging
The Humble Print Statement
Git Bisect
RSpec or Minitest Bisect
Pry
Basic Pry Consoling
Using Pry to Troubleshoot Test Failures
Common Rails Gotchas
Summary
Running Tests Faster and Running Faster Tests
Getting Started with Running Smaller Groups of Tests
Running Smaller Groups of Tests: RSpec
Running Smaller Groups of Tests in Minitest
Running Smaller Groups of Tests Using Cucumber
Running Rails in the Background
Using Spring
Spring Advantages
Running Tests Automatically with Guard
Writing Faster Tests by Bypassing Rails
Why Speed Is Important
Why Separation from Rails Is Useful
Rails Test Prescriptions, Hold the Rails
Bypassing Rails in Minitest
Workflow Tests Without Rails
Running Rails-free Tests
Recommendations for Faster Tests
Summary
Testing Legacy Code
What is a Legacy?
Set Expectations
Getting Started with Legacy Code
Black-Box and White-Box Testing
Dependency Removal
Legacy Databases, Testing, and Us
Using Test Doubles to Remove Dependencies
Find the Seam
Don’t Look Back
Conclusion
Testing Helper Methods
Learn how to test the helper methods.
We'll cover the following
Testing helper methods
The spec/helpers file
Helper test
ActionView test environment
Get hands-on with 1400+ tech skills courses.
Start Free Trial