test/test_helper.rb in dynamic_fields-0.1.0 vs test/test_helper.rb in dynamic_fields-0.2.0

- old
+ new

@@ -4,7 +4,34 @@ require File.expand_path("../dummy/config/environment.rb", __FILE__) require "rails/test_help" Rails.backtrace_cleaner.remove_silencers! +# Configure capybara for integration testing +require "capybara/rails" +Capybara.default_driver = :rack_test +Capybara.default_selector = :css + +# Run any available migration +ActiveRecord::Migrator.migrate File.expand_path("../dummy/db/migrate/", __FILE__) + # Load support files Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f } + +# Transactional fixtures do not work with Selenium tests, because Capybara +# uses a separate server thread, which the transactions would be hidden +# from. We hence use DatabaseCleaner to truncate our test database. +DatabaseCleaner.strategy = :truncation + +class ActionDispatch::IntegrationTest + # Make the Capybara DSL available in all integration tests + include Capybara::DSL + + # Stop ActiveRecord from wrapping tests in transactions + self.use_transactional_fixtures = false + + teardown 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 \ No newline at end of file