Search⌘ K
AI Features

Setting Up Rails System Tests

Explore how to set up Rails system tests in a Dockerized Rails app using RSpec and Capybara. Understand the use of system tests for verifying user interactions and how they differ from unit tests. Learn to configure drivers, organize test files, and run tests with Docker Compose to ensure your app functions correctly from a user's perspective.

Rails system tests

Rails system tests, added in Rails 5.14, allow you to perform high-level, end-to-end tests of your application. Rather than testing if individual functions or methods perform as they should (unit testing), they test the application based on how the user interacts with it, that is, via a web interface. They allow us to assert that when a user interacts with our application in a certain way (such as filling in forms, clicking links or buttons), the app responds as we would expect (such as displaying the correct page or having the correct things appear on the page).

Although this kind of end-to-end test was possible previously, for example, with RSpec Feature specs, system tests bring a number of new benefits. We no longer have to worry about the cleanup of our ...