You can set an environment variable from the command line that can be used in spec/spec_helper.rb:
DEBUG = ENV['DEBUG'] || false
if DEBUG
Capybara.default_driver = :selenium
else
Capybara.default_driver = :rack_test
Capybara.javascript_driver = :poltergeist
end
Which can then be run from the command line like so:
DEBUG=true rspec spec/features/my_spec.rb:35
This will allow you to specify a specific line number.
You may also have to change your cleanup strategy depending on the capybara driver being used (ie; with database cleaner):
RSpec.configure do |config|
config.before(:suite) do
if DEBUG
DatabaseCleaner.strategy = :truncation
else
DatabaseCleaner.strategy = :transaction
end
DatabaseCleaner.clean_with(:truncation)
end
end
If you want to get fancy, you can combine it with this stackoverflow answer: https://mcmap.net/q/693789/-how-can-i-run-selenium-used-through-capybara-at-a-lower-speed to slow down the speed at which selenium runs specs when they're running in DEBUG mode:
config.before(:each) do |group|
set_speed :slow if DEBUG
end
:54
to run specific test, at least in 2015, and 2016, but I can't remember if it was possible in 2014 as well. – Periodontal