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.
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
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.
Advatanges:
Disadvantages:
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|
Capybara::RackTest::Driver.new(app, headers: { 'HTTP_USER_AGENT' => 'Capybara' })
end
RELATED TAGS
View all Courses