End-to-End Testing
Learn to write tests using end-to-end testing, set up Capybara, and get an overview of the outside-in-testing advantages.
Outside-in testing
We’ll follow a testing practice called outside-in testing, which involves writing an end-to-end test that defines the feature (the “outside”) and augmenting it with a series of unit tests that drive the actual code and design (the “inside”).
Capybara
Capybara will make our end-to-end tests easier to read and write. It allows tests to describe user interaction with the web page and the document object model (DOM). We’ll cover Capybara and end-to-end testing in more detail in the chapter “Integration Testing with Capybara and Cucumber”.
Capybara installation
In Rails 5.1 and higher, Capybara is already included as part of the default project. In older projects, we add it to the Gemfile:
group :test do
gem "capybara"
end
Then we reinstall the bundle:
$ bundle install