Let’s Talk About Drivers
Learn about Capybara and JavaScript drivers and how to import them into the project.
Capybara drivers
To understand what Capybara is doing and what we need to do to make JavaScript integration testing work, we need to know about drivers. The driver is the part of Capybara that actually manages a web page as a series of DOM elements. The Capybara query language interacts with the driver, telling it to click a button or fill a form element or querying the driver to return DOM elements that match a selector and some other criteria.
The Rack::Test
driver
Capybara’s default driver is called Rack::Test
. It’s relatively simple and relatively fast. The Rack::Test
is written in Ruby and maintains its own DOM element tree. It’s also dependent on Rack, the web stack that underlies nearly all Ruby web frameworks(not only Rails but also Sinatra). The Rack::Test
has been great for our purposes so far, but it has some limitations. The most relevant of those for us is that ...