Skip to content

Instantly share code, notes, and snippets.

@efatsi
Forked from mackermedia/Gemfile
Created October 11, 2012 22:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save efatsi/3875957 to your computer and use it in GitHub Desktop.
Save efatsi/3875957 to your computer and use it in GitHub Desktop.
Capybara-webkit
require 'spec_helper'
describe "JS Example" do
it "doesn't use javascript driver" do
end
it "uses javascript driver", :js => true do
end
end
group :test, :development do
gem 'capybara'
gem 'capybara-webkit'
gem 'database_cleaner'
end
Capybara.default_driver = :selenium
Capybara.javascript_driver = :webkit
RSpec.configure do |config|
config.use_transactional_fixtures = false
config.before(:each) do
if example.metadata[:js]
DatabaseCleaner.strategy = :truncation
DatabaseCleaner.clean_with(:truncation)
else
DatabaseCleaner.strategy = :transaction
DatabaseCleaner.clean_with(:transaction)
end
DatabaseCleaner.start
end
config.after(:each) do
DatabaseCleaner.clean # Truncate the database
Capybara.reset_sessions! # Forget the (simulated) browser state
Capybara.use_default_driver # Revert Capybara.current_driver to Capybara.default_driver
end
end
@efatsi
Copy link
Author

efatsi commented Nov 23, 2013

just FYI, also need this atop your spec_helper.rb

require 'capybara/rails'

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