-
-
Save efatsi/3875957 to your computer and use it in GitHub Desktop.
Capybara-webkit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe "JS Example" do | |
it "doesn't use javascript driver" do | |
end | |
it "uses javascript driver", :js => true do | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
group :test, :development do | |
gem 'capybara' | |
gem 'capybara-webkit' | |
gem 'database_cleaner' | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
just FYI, also need this atop your
spec_helper.rb