Created
March 17, 2016 18:35
-
-
Save paulmars/e7752077c8beaa3de1f7 to your computer and use it in GitHub Desktop.
Capybara + Rspec + Poltergesit
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
| config.use_transactional_fixtures = true | |
| config.before(:each, js: true) do | |
| self.use_transactional_fixtures = false | |
| ActiveRecord::Base.establish_connection | |
| DatabaseCleaner.strategy = :truncation | |
| DatabaseCleaner.start | |
| end | |
| config.after(:each, js: true) do | |
| DatabaseCleaner.clean | |
| ActiveRecord::Base.establish_connection | |
| self.use_transactional_fixtures = true | |
| 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
| ENV["RAILS_ENV"] ||= 'test' | |
| require File.expand_path("../../config/environment", __FILE__) | |
| require 'rspec/rails' | |
| require 'pry-remote' | |
| Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f } | |
| ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration) | |
| include Warden::Test::Helpers | |
| Warden.test_mode! | |
| require 'capybara' | |
| require 'capybara/dsl' | |
| require 'capybara/poltergeist' | |
| Capybara.register_driver :poltergeist_debug do |app| | |
| # redirect_limit: 20 | |
| Capybara::Poltergeist::Driver.new(app, js_errors: true, phantomjs_logger: Logger.new(STDOUT)) | |
| end | |
| Capybara.javascript_driver = :poltergeist_debug | |
| RSpec.configure do |config| | |
| config.use_transactional_fixtures = true | |
| config.before(:each, js: true) do | |
| self.use_transactional_fixtures = false | |
| ActiveRecord::Base.establish_connection | |
| DatabaseCleaner.strategy = :truncation | |
| DatabaseCleaner.start | |
| end | |
| config.after(:each, js: true) do | |
| DatabaseCleaner.clean | |
| ActiveRecord::Base.establish_connection | |
| self.use_transactional_fixtures = true | |
| end | |
| config.include Devise::TestHelpers, type: :controller | |
| config.include Devise::TestHelpers, type: :view | |
| config.use_transactional_fixtures = true | |
| config.infer_base_class_for_anonymous_controllers = false | |
| config.order = "random" | |
| 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
| http://www.ultrasaurus.com/2014/01/rspec-mixing-transcations-truncation-database-clearner-strategies/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment