Skip to content

Instantly share code, notes, and snippets.

@raul
Created August 11, 2010 07:32
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save raul/518636 to your computer and use it in GitHub Desktop.
Save raul/518636 to your computer and use it in GitHub Desktop.
# Adapted for Rspec2. This won't work in RSpec 1.
# Put this code in acceptance_helper.rb or better in a new file spec/acceptance/support/javascript.rb
Rspec.configure do |config|
config.before(:each) do
Capybara.current_driver = :selenium if example.metadata[:js]
end
config.after(:each) do
Capybara.use_default_driver if example.metadata[:js]
end
end
#...
scenario "Scenario that needs Javascript", :js => true do
#...
end
scenario "Scenario that doesn't need Javascript" do
#...
end
@wincent
Copy link

wincent commented Sep 8, 2010

example.options also works under RSpec 2.

@raul
Copy link
Author

raul commented Sep 8, 2010

Nice tip! Thanks wincent! :D

@ravicious
Copy link

FYI: now you can do it just like this http://jeffkreeftmeijer.com/2011/capybara-ate-swinger/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment