Skip to content
On this page

Installation ๐Ÿ’ฟ

Add this line to your application's Gemfile:

gem 'capybara_test_helpers'

And then run:

$ bundle install

RSpec

To use with RSpec, require the following in spec_helper.rb:

require 'capybara_test_helpers/rspec'

Most of the examples in the guide will cover how to use test helpers in RSpec.

In Rails

If using Rails, make sure you follow the setup in rspec-rails first.

You can run rails g test_helper base to create a base test helper and require it as well so that other test helpers can extend it without manually requiring.

# spec/rails_helper.rb
require 'capybara_test_helpers/rspec'
require Rails.root.join('test_helpers/base_test_helper')

Example

Cucumber ๐Ÿฅ’

To use with Cucumber, require the following in env.rb:

require 'capybara_test_helpers/cucumber'
require Rails.root.join('test_helpers/base_test_helper')

Example

Read about using test helpers in Cucumber for more information.