O'Reilly logo

Application Testing with Capybara by Matthew Robbins

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Capybara and Rack::Test

Rack::Test is a library that implements the Rack protocol, making it possible to test your application's full-stack functionality without the latency of HTTP communication and opening real browsers. You can use its API to send a request to your application; when your application responds, Rack::Test will digest the response and allow you to interrogate it. It can do this because it is simply implementing the Rack protocol, constructing the request hash to present to the application just as the Rack web server would do, interpreting the response hash, and making it available to you via the API.

Here is an example using Rack::Test outside of Capybara that tests the "Hello World" application we developed previously:

require ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required