as far as I know driven_by is part of the Rails DSL for system specs, not RSpec feature specs. I've never had to use it with feature specs
Actually I've never used Rails new system specs, I've always used RSpec/Capybara feature specs with both headless & non headless drivers for years, they work great
Here's how I configure headless chrome with capybara
## Headless!
Capybara.register_driver :headless_chrome do |app|
options = Selenium::WebDriver::Chrome::Options.new
options.add_argument('--headless')
options.add_argument('--disable-gpu')
options.add_argument('--test-type')
options.add_argument('--ignore-certificate-errors')
options.add_argument('--disable-popup-blocking')
options.add_argument('--disable-extensions')
options.add_argument('--enable-automation')
options.add_argument('--window-size=1920,1080')
options.add_argument("--start-maximized")
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
logging_prefs: { 'browser' => 'ALL' }
)
Capybara::Selenium::Driver.new app, browser: :chrome, options: options, desired_capabilities: capabilities
end
## Capy Configuration Defaults
Capybara.configure do |config|
config.server = :puma
config.javascript_driver = (ENV['HEADLESS'] || ENV['H']) ? :headless_chrome : :chrome
config.default_max_wait_time = 7
end
I use an environment variable to control when I pick headless or not from the command line, i.e.
H=1 bundle exec rspec spec/models/
feature specs go in a /features directory under my /spec directory and look like the following, note the :js tag to trigger the browser vs the capybara default :rack_test (no browser)
RSpec.feature 'Admin can do stuff, :js do
describe 'fancy feature' do
it 'works well' do
# spec implementation
end
end
end