Sha256: 0ec073df5023a399e059754298451c84d5623f25954d3fdcfc4d4df63d121e18

Contents?: true

Size: 1.28 KB

Versions: 14

Compression:

Stored size: 1.28 KB

Contents

require 'torque-postgresql'
require 'database_cleaner'
require 'factory_bot'
require 'dotenv'
require 'faker'
require 'rspec'
require 'byebug'

Dotenv.load

ActiveRecord::Base.establish_connection(ENV['DATABASE_URL'])
cache = ActiveRecord::Base.connection.schema_cache

cleaner = ->() do
  cache.instance_variable_set(:@inheritance_loaded, false)
  cache.instance_variable_set(:@inheritance_dependencies, {})
  cache.instance_variable_set(:@inheritance_associations, {})
end

load File.join('schema.rb')
Dir.glob(File.join('spec', '{models,factories,mocks}', '*.rb')) do |file|
  require file[5..-4]
end

cleaner.call
I18n.load_path << Pathname.pwd.join('spec', 'en.yml')
RSpec.configure do |config|
  config.extend Mocks::CreateTable
  config.include Mocks::CacheQuery

  config.formatter = :documentation
  config.color     = true
  config.tty       = true

  # Handles acton before rspec initialize
  config.before(:suite) do
    DatabaseCleaner.clean_with(:truncation)
  end

  config.before(:each) do
    DatabaseCleaner.strategy = :transaction
  end

  config.before(:each, js: true) do
    DatabaseCleaner.strategy = :truncation
  end

  config.before(:each) do
    DatabaseCleaner.start
  end

  config.after(:each) do
    DatabaseCleaner.clean
  end

  config.before(:each) do
    cleaner.call
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
torque-postgresql-2.2.2 spec/spec_helper.rb
torque-postgresql-2.2.1 spec/spec_helper.rb
torque-postgresql-2.2.0 spec/spec_helper.rb
torque-postgresql-2.1.3 spec/spec_helper.rb
torque-postgresql-2.1.2 spec/spec_helper.rb
torque-postgresql-2.1.1 spec/spec_helper.rb
torque-postgresql-2.1.0 spec/spec_helper.rb
torque-postgresql-2.0.6 spec/spec_helper.rb
torque-postgresql-2.0.5 spec/spec_helper.rb
torque-postgresql-2.0.4 spec/spec_helper.rb
torque-postgresql-2.0.3 spec/spec_helper.rb
torque-postgresql-2.0.2 spec/spec_helper.rb
torque-postgresql-2.0.1 spec/spec_helper.rb
torque-postgresql-2.0.0 spec/spec_helper.rb