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://stackoverflow.com/a/5150855/95683 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