2015-12-31 18:33:35 -05:00
|
|
|
# frozen_string_literal: true
|
2018-12-03 16:24:37 -05:00
|
|
|
|
2018-12-07 11:59:42 -05:00
|
|
|
require 'bundler/setup'
|
|
|
|
Bundler.require(:default, :test)
|
|
|
|
|
2019-09-10 18:22:30 -04:00
|
|
|
require 'minitest/pride'
|
2018-12-07 11:59:42 -05:00
|
|
|
require 'minitest/autorun'
|
|
|
|
|
2013-05-10 23:43:53 -04:00
|
|
|
$TESTING = true
|
2015-10-21 12:29:58 -04:00
|
|
|
# disable minitest/parallel threads
|
2021-09-01 14:07:19 -04:00
|
|
|
ENV["MT_CPU"] = "0"
|
2015-10-21 12:29:58 -04:00
|
|
|
ENV["N"] = "0"
|
2020-06-03 19:06:57 -04:00
|
|
|
# Disable any stupid backtrace cleansers
|
|
|
|
ENV["BACKTRACE"] = "1"
|
2015-10-21 12:29:58 -04:00
|
|
|
|
2015-07-10 15:35:02 -04:00
|
|
|
if ENV["COVERAGE"]
|
2012-01-24 01:07:21 -05:00
|
|
|
require 'simplecov'
|
2013-04-12 16:57:24 -04:00
|
|
|
SimpleCov.start do
|
2020-01-31 13:19:20 -05:00
|
|
|
enable_coverage :branch
|
2013-04-12 16:57:24 -04:00
|
|
|
add_filter "/test/"
|
2014-02-01 18:04:20 -05:00
|
|
|
add_filter "/myapp/"
|
2013-04-12 16:57:24 -04:00
|
|
|
end
|
2020-06-19 20:10:01 -04:00
|
|
|
if ENV['CI']
|
|
|
|
require 'codecov'
|
|
|
|
SimpleCov.formatter = SimpleCov::Formatter::Codecov
|
|
|
|
end
|
2012-01-24 01:07:21 -05:00
|
|
|
end
|
2018-12-03 16:24:37 -05:00
|
|
|
|
2018-12-07 11:59:42 -05:00
|
|
|
ENV['REDIS_URL'] ||= 'redis://localhost/15'
|
2012-02-14 12:00:26 -05:00
|
|
|
|
2019-09-03 14:13:04 -04:00
|
|
|
Sidekiq.logger = ::Logger.new(STDOUT)
|
2012-05-15 22:44:35 -04:00
|
|
|
Sidekiq.logger.level = Logger::ERROR
|
2012-03-14 00:19:46 -04:00
|
|
|
|
2015-07-12 13:51:34 -04:00
|
|
|
def capture_logging(lvl=Logger::INFO)
|
|
|
|
old = Sidekiq.logger
|
|
|
|
begin
|
|
|
|
out = StringIO.new
|
2019-09-03 14:13:04 -04:00
|
|
|
logger = ::Logger.new(out)
|
2015-07-12 13:51:34 -04:00
|
|
|
logger.level = lvl
|
|
|
|
Sidekiq.logger = logger
|
|
|
|
yield
|
|
|
|
out.string
|
|
|
|
ensure
|
|
|
|
Sidekiq.logger = old
|
|
|
|
end
|
|
|
|
end
|