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)
|
|
|
|
|
|
|
|
require 'minitest/reporters'
|
|
|
|
require 'minitest/autorun'
|
|
|
|
|
|
|
|
MiniTest::Reporters.use! Minitest::Reporters::DefaultReporter.new
|
2018-12-03 16:24:37 -05:00
|
|
|
|
2013-05-10 23:43:53 -04:00
|
|
|
$TESTING = true
|
2015-10-21 12:29:58 -04:00
|
|
|
# disable minitest/parallel threads
|
|
|
|
ENV["N"] = "0"
|
|
|
|
|
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
|
|
|
|
add_filter "/test/"
|
2014-02-01 18:04:20 -05:00
|
|
|
add_filter "/myapp/"
|
2013-04-12 16:57:24 -04:00
|
|
|
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
|
|
|
|
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
|
|
|
|
logger = Logger.new(out)
|
|
|
|
logger.level = lvl
|
|
|
|
Sidekiq.logger = logger
|
|
|
|
yield
|
|
|
|
out.string
|
|
|
|
ensure
|
|
|
|
Sidekiq.logger = old
|
|
|
|
end
|
|
|
|
end
|
2015-10-21 12:29:58 -04:00
|
|
|
|
|
|
|
def with_logging(lvl=Logger::DEBUG)
|
|
|
|
old = Sidekiq.logger.level
|
|
|
|
begin
|
|
|
|
Sidekiq.logger.level = lvl
|
|
|
|
yield
|
|
|
|
ensure
|
|
|
|
Sidekiq.logger.level = old
|
|
|
|
end
|
|
|
|
end
|