spec/spec_helper.rb in deimos-ruby-1.7.0.pre.beta1 vs spec/spec_helper.rb in deimos-ruby-1.8.0.pre.beta1

- old
+ new

@@ -1,9 +1,10 @@ # frozen_string_literal: true $LOAD_PATH.unshift(File.expand_path('../lib', __dir__)) require 'active_record' +require 'database_cleaner' require 'deimos' require 'deimos/metrics/mock' require 'deimos/tracing/mock' require 'deimos/test_helpers' require 'active_support/testing/time_helpers' @@ -145,10 +146,13 @@ config.full_backtrace = true # true by default for RSpec 4.0 config.shared_context_metadata_behavior = :apply_to_host_groups + config.filter_run(focus: true) + config.run_all_when_everything_filtered = true + config.before(:all) do Time.zone = 'Eastern Time (US & Canada)' ActiveRecord::Base.logger = Logger.new('/dev/null') ActiveRecord::Base.establish_connection( 'adapter' => 'sqlite3', @@ -157,10 +161,13 @@ end config.include Deimos::TestHelpers config.include ActiveSupport::Testing::TimeHelpers config.before(:suite) do setup_db(DbConfigs::DB_OPTIONS.last) + + DatabaseCleaner.strategy = :transaction + DatabaseCleaner.clean_with(:truncation) end config.mock_with(:rspec) do |mocks| mocks.yield_receiver_to_any_instance_implementation_blocks = true mocks.verify_partial_doubles = true @@ -176,9 +183,19 @@ deimos_config.kafka.seed_brokers = ENV['KAFKA_SEED_BROKER'] || 'localhost:9092' deimos_config.logger = Logger.new('/dev/null') deimos_config.logger.level = Logger::INFO deimos_config.schema.backend = :avro_validation end + end + + config.around(:each) do |example| + use_cleaner = !example.metadata[:integration] + + DatabaseCleaner.start if use_cleaner + + example.run + + DatabaseCleaner.clean if use_cleaner end end RSpec.shared_context('with widgets') do before(:all) do