require 'bundler'
Bundler.setup

require 'simplecov'
SimpleCov.start

require 'with_model'
RSpec.configure do |config|
  config.extend WithModel

  config.warnings = true

  config.expect_with :rspec do |c|
    c.syntax = :expect
  end

  config.mock_with :rspec do |c|
    c.syntax = :expect
  end
end

# WithModel requires ActiveRecord::Base.connection to be established.
# If ActiveRecord already has a connection, as in a Rails app, this is unnecessary.
require 'active_record'
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')

if defined?(I18n) && I18n.respond_to?(:enforce_available_locales=)
  I18n.enforce_available_locales = true
end

if ENV['LOGGER']
  require 'logger'
  ActiveRecord::Base.logger = Logger.new($stdout)
end

module SpecHelper
  module RailsTestCompatability
    require 'minitest'
    include Minitest::Assertions

    def assertions
      @assertions ||= 0
    end

    def assertions=(value)
      @assertions = value
    end
  end
end

require 'bundler'
Bundler.setup

require 'simplecov'
SimpleCov.start

require 'with_model'
RSpec.configure do |config|
  config.extend WithModel

  config.warnings = true

  config.expect_with :rspec do |c|
    c.syntax = :expect
  end

  config.mock_with :rspec do |c|
    c.syntax = :expect
  end
end

is_jruby = RUBY_PLATFORM == 'java'
adapter = is_jruby ? 'jdbcsqlite3' : 'sqlite3'

# WithModel requires ActiveRecord::Base.connection to be established.
# If ActiveRecord already has a connection, as in a Rails app, this is unnecessary.
require 'active_record'
ActiveRecord::Base.establish_connection(adapter: adapter, database: ':memory:')

if defined?(I18n) && I18n.respond_to?(:enforce_available_locales=)
  I18n.enforce_available_locales = true
end

if ENV['LOGGER']
  require 'logger'
  ActiveRecord::Base.logger = Logger.new($stdout)
end

module SpecHelper
  module RailsTestCompatability
    require 'minitest'
    include Minitest::Assertions

    def assertions
      @assertions ||= 0
    end

    def assertions=(value)
      @assertions = value
    end
  end
end

Revert "JRuby: Update adapter 'jdbcsqlite3' -> 'sqlite3'"
Revert "JRuby: Update adapter 'jdbcsqlite3' -> 'sqlite3'"

This reverts commit 40efbed3da9ae4ee9903c47f3fd905dc8cf2b228.
