Skip to content

Instantly share code, notes, and snippets.

@nahurst
Created May 27, 2011 00:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nahurst/994387 to your computer and use it in GitHub Desktop.
Save nahurst/994387 to your computer and use it in GitHub Desktop.
Selenium, rspec, capybara integration with steak to make it like cucumber when cleaning the database javascript tests
# spec/acceptance/support/javascript.rb
RSpec.configure do |config|
config.use_transactional_fixtures = false
config.before :each do
Capybara.current_driver = :selenium if example.metadata[:js]
if Capybara.current_driver == :rack_test
DatabaseCleaner.strategy = :transaction
else
DatabaseCleaner.strategy = :truncation
end
DatabaseCleaner.start
end
config.after do
DatabaseCleaner.clean
Capybara.use_default_driver if example.metadata[:js]
end
end
# in the feature file
feature "..." %q{
...
} do
scenario "...", :js => true do
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment