Sha256: f71f6f60c9b9215c975b97563a7a2ec9718c89dede635c68f90cc8baccd0ba32

Contents?: true

Size: 1.3 KB

Versions: 2

Compression:

Stored size: 1.3 KB

Contents

# frozen_string_literal: true

require 'simplecov'
SimpleCov.start 'rails' do
  add_filter 'lib/dirty_seed/version.rb'
end

ENV['RAILS_ENV'] ||= 'test'

ENGINE_ROOT = File.join(File.dirname(__FILE__), '../')

# Load environment.rb from the dummy app.
require File.expand_path('dummy/config/environment', __dir__)

abort('The Rails environment is running in production mode!') if Rails.env.production?

require 'database_cleaner'
require 'factory_bot_rails'
require 'rspec/rails'
Dir[Rails.root.join('../../spec/support/**/*.rb')].sort.each { |f| require f }

# Load migrations from the dummy app.
ActiveRecord::Migrator.migrations_paths = File.join(ENGINE_ROOT, 'spec/dummy/db/migrate')
ActiveRecord::Migration.maintain_test_schema!

RSpec.configure do |config|
  config.include FactoryBot::Syntax::Methods

  config.before(:suite) do
    DatabaseCleaner.clean_with(:truncation)
    DatabaseCleaner.strategy = :transaction
  end

  config.around do |example|
    DirtySeed::DataModel.instance.models = nil
    DirtySeed::DataModel.instance.seeders = nil
    Faker::UniqueGenerator.clear
    DirtySeed::Engine.initializers.each(&:run)
    DatabaseCleaner.cleaning do
      example.run
    end
  end

  config.use_transactional_fixtures = true
  config.infer_spec_type_from_file_location!
  config.filter_rails_from_backtrace!
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dirty_seed-0.2.1 spec/rails_helper.rb
dirty_seed-0.2.0 spec/rails_helper.rb