Sha256: 153f3ccfcc0a030da61bf7fb3dc4def8b5258e7bf04cd8da57c359ac92f1df53

Contents?: true

Size: 1.34 KB

Versions: 3

Compression:

Stored size: 1.34 KB

Contents

require 'yaml'
require 'active_record'
require 'polymorphic_integer_type'
require 'support/configuration'
require 'support/link'
require 'support/animal'
require 'support/namespaced_animal'
require 'support/namespaced_plant'
require 'support/dog'
require 'support/person'
require 'support/food'
require 'support/drink'
require 'support/namespaced_activity'
require 'byebug'
require 'pry'

RSpec.configure do |config|
  config.before(:suite) do
    database_config = YAML.load(File.open("#{File.dirname(__FILE__)}/support/database.yml"))
    migrations_path = "#{File.dirname(__FILE__)}/support/migrations"
    active_record_version = Gem::Version.new(ActiveRecord::VERSION::STRING)

    ActiveRecord::Base.establish_connection(database_config)

    if active_record_version < Gem::Version.new("5.2")
      ActiveRecord::Migrator.migrate(migrations_path)      
    end

    if active_record_version >= Gem::Version.new("5.2") && active_record_version < Gem::Version.new("6.0")
      ActiveRecord::MigrationContext.new(migrations_path).migrate      
    end
    
    if active_record_version >= Gem::Version.new("6.0")
      ActiveRecord::MigrationContext.new(migrations_path, ActiveRecord::SchemaMigration).migrate      
    end
  end

  config.around do |example|
    ActiveRecord::Base.transaction do
      example.run
      raise ActiveRecord::Rollback
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
polymorphic_integer_type-3.2.1 spec/spec_helper.rb
polymorphic_integer_type-3.2.0 spec/spec_helper.rb
polymorphic_integer_type-3.1.1 spec/spec_helper.rb