Sha256: 814a79961a60b9a92b0c7c5fd66750a9dc62151f57904565a60c39311394b855

Contents?: true

Size: 1.07 KB

Versions: 3

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

require 'dotenv'
Dotenv.load('.env.test')
Dotenv.overload('.env.test.local')

ENV['APP_ENV'] ||= 'test'
ENV['RACK_ENV'] ||= 'test'
require 'simplecov'
SimpleCov.start

ENV['DATABASE_URL'] ||= 'sqlite::memory:'

require 'ditty'
require 'ditty/db'
require 'rspec'
require 'rack/test'
require 'factory_bot'
require 'database_cleaner'
require 'timecop'

if ENV['DATABASE_URL'] == 'sqlite::memory:'
  folder = File.expand_path("#{File.dirname(__FILE__)}/../migrate")
  Sequel.extension :migration
  Sequel::Migrator.apply(DB, folder)

  # Seed the DB
  require 'ditty/seed'
end

Ditty.component :ditty
RSpec.configure do |config|
  config.include Rack::Test::Methods
  config.include FactoryBot::Syntax::Methods

  config.alias_example_to :fit, focus: true
  config.filter_run focus: true
  config.run_all_when_everything_filtered = true

  config.before(:suite) do
    DatabaseCleaner.strategy = :transaction
    FactoryBot.find_definitions
    Timecop.freeze
  end

  config.around do |example|
    DatabaseCleaner.cleaning do
      example.run
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ditty-0.11.1 spec/spec_helper.rb
ditty-0.10.2 spec/spec_helper.rb
ditty-0.10.1 spec/spec_helper.rb