Dorian
Dorian

Reputation: 9085

Automatic js: true on rspec system specs?

all my system tests/specs have js: true, is there a way to automatically add that tag/metadata to my system tests/specs?

require "rails_helper"

RSpec.describe "redirect_to", js: true do
  ...
end

Edit: Hmmm, I was relying on js: true for database_cleaner but replaced it with type: :system and now I don't need this hack

Upvotes: 1

Views: 620

Answers (2)

arieljuod
arieljuod

Reputation: 15838

You should be able to set the default driver to be selenium, or selenium_chrome, or any other custom driver: https://github.com/teamcapybara/capybara#selecting-the-driver

Something like:

# spec/rails_helper.rb

Capybara.default_driver = :selenium_chrome_headless

Upvotes: 1

Dorian
Dorian

Reputation: 9085

config.before(:each, type: :system) { |example| example.metadata[:js] = true }

Upvotes: 1

Related Questions