database_cleaner.rb revision e200ddd4b78a4915a072095be2a2e6cac65ed333
1516N/Arequire 'database_cleaner'
50N/A
50N/Amodule DatabaseCleanerConfig
50N/A CLEAN_MODE = :transaction
50N/A INITIAL_CLEAN_MODE = :truncation
50N/A INITIAL_CLEAN_OPTIONS = {except: %w(ontology_file_extensions proof_statuses)}
50N/A
50N/A if defined?(RSpec) && RSpec.respond_to?(:configure)
50N/A RSpec.configure do |config|
50N/A config.use_instantiated_fixtures = false
50N/A config.use_transactional_fixtures = false
50N/A
50N/A config.before(:suite) do
50N/A DatabaseCleaner.strategy = INITIAL_CLEAN_MODE, INITIAL_CLEAN_OPTIONS
50N/A DatabaseCleaner.clean
50N/A DatabaseCleaner.strategy = CLEAN_MODE
50N/A end
50N/A
50N/A config.before(:each) do
50N/A DatabaseCleaner.start
50N/A end
50N/A
2026N/A config.after(:each) do
2627N/A DatabaseCleaner.clean
2026N/A
50N/A # Remove repositories and other data created in a test
2627N/A %w(data test).each do |d|
202N/A dir = Rails.root.join('tmp', d)
50N/A dir.rmtree if dir.exist?
1431N/A end
1431N/A end
1431N/A end
1755N/A end
1352N/A
1618N/A if defined? ActiveSupport::TestCase
72N/A # Set strategy and clean once at load time
1431N/A DatabaseCleaner.strategy = INITIAL_CLEAN_MODE, INITIAL_CLEAN_OPTIONS
50N/A DatabaseCleaner.clean
2470N/A DatabaseCleaner.strategy = CLEAN_MODE
1618N/A
50N/A class ActiveSupport::TestCase
50N/A
50N/A class_attribute :use_transactional_fixtures
66N/A class_attribute :use_instantiated_fixtures
135N/A
66N/A self.use_transactional_fixtures = false
66N/A self.use_instantiated_fixtures = false
50N/A
2205N/A setup do
2627N/A DatabaseCleaner.start
2627N/A end
2627N/A
2627N/A teardown do
2627N/A DatabaseCleaner.clean
2627N/A end
2627N/A
2627N/A end
2627N/A end
2627N/Aend
2627N/A