Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

rack tests

Capybara with Rack::Test

Educative Answers Team
svg viewer


Capybara is a web-based automation framework that creates certain functional tests in order to simulate how a user may interact with the application – it is a library used on top of a web-based driver.

What is integration testing?

Initially, integration testing was slower and took a lot of time, but these tests were quite significant as they tested applications as a user. Therefore, they would depend on the full stack of your models, web servers, databases, helpers, etc.

Proper integration tests use your application as a black boxBlack Box Testing, also known as Behavioral Testing, is a software testing method in which the internal structure/design/implementation of the item being tested is not known to the tester..Their job is to interact with the interface and show results.

svg viewer


By default, Capybara performs RackTest on applications because RackTest is part of Capybara’s default drivers, and it writes the code in Ruby programming language. This Ruby library has the advantage as it interacts with the application from a Rack level, which is similar to any external user. It runs requests against the application, which results in HTML data that is provided to Capybara and RSpec for examination.


  1. Rack::Test is completely headless.
  2. It uses Unix utilities instead of a real browser.
  3. Increased running and processing speed.
  4. Server does need to be used as the RackTest driver as it directly interacts with Rack interface.


  1. It does not process JavaScript.
  2. If an application is not a Rack application (e.g., Rails, Sinatra), this driver becomes incompatible.
  3. Remote applications and remote URLs cannot be tested using the RackTest driver.
  4. There’s no GUI to render, no images to process, etc.

Capybara Setup

To use the library, add gem capybara to the :test and :development groups in your Gemfile, then type bundle in the terminal.

RackTest can be configured with a set of headers, as shown below:

Capybara.register_driver :rack_test do |app|, headers: { 'HTTP_USER_AGENT' => 'Capybara' })


rack tests
Copyright ©2022 Educative, Inc. All rights reserved

View all Courses

Keep Exploring