-
-
Save pk-nb/b167c8837e9ad1e776cb to your computer and use it in GitHub Desktop.
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
# place in spec/support/ | |
Capybara.register_driver :poltergeist do |app| | |
options = { | |
:js_errors => true, | |
:window_size => [1280, 1440], | |
:timeout => 30 | |
} | |
Capybara::Poltergeist::Driver.new(app, options) | |
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
# place in spec/support/features | |
module DatabaseCleanerHelper | |
RSpec.configure do |config| | |
config.before(:suite) do | |
DatabaseCleaner.clean_with(:truncation) | |
end | |
config.before(:each) do | |
DatabaseCleaner.strategy = :transaction | |
end | |
config.before(:each, :js => true) do | |
DatabaseCleaner.strategy = :truncation | |
end | |
config.before(:each) do | |
DatabaseCleaner.start | |
end | |
config.after(:each) do | |
DatabaseCleaner.clean | |
Capybara.reset_sessions! # Forget the (simulated) browser state | |
Capybara.use_default_driver # Revert Capybara.current_driver to Capybara.default_driver | |
end | |
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
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 do | |
gem 'capybara' | |
gem 'poltergeist' # 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
require 'capybara/poltergeist' | |
Capybara.configure do |config| | |
config.javascript_driver = :poltergeist | |
config.default_wait_time = 40 # long wait time for to handle jenkins timeouts | |
end | |
RSpec.configure do |config| | |
config.use_transactional_fixtures = false | |
config.include DatabaseCleanerHelper, :type => :feature | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment