Last active
February 1, 2018 21:43
-
-
Save chrismanderson/2fb4d942ecb140c7080a3656d2643c49 to your computer and use it in GitHub Desktop.
test_helper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'simplecov' | |
SimpleCov::SourceFile.class_eval do | |
def project_filename | |
h = {} | |
4.times{ # maximum 4 times | |
GC.stat(h) | |
live_slots = h[:heap_live_slots] || h[:heap_live_slot] | |
old_objects = h[:old_objects] || h[:old_object] | |
remwb_unprotects = h[:remembered_wb_unprotected_objects] || h[:remembered_shady_object] | |
young_objects = live_slots - old_objects - remwb_unprotects | |
# p [[live_slots, old_objects, remwb_unprotects], [young_objects]] | |
break if young_objects < live_slots / 10 | |
disabled = GC.enable | |
GC.start(full_mark: false) | |
GC.disable if disabled | |
} | |
p [:debug, @filename, SimpleCov.root] | |
@filename.sub(/^#{SimpleCov.root}/, "") | |
end | |
end | |
ENV['RAILS_ENV'] ||= 'test' | |
require File.expand_path('../../config/environment', __FILE__) | |
require 'rails/test_help' | |
require 'mocha/mini_test' | |
require 'sidekiq/testing' | |
Dir[Rails.root.join("test/support/**/*.rb")].each { |f| require f } | |
Sidekiq::Testing.fake! | |
class ActiveSupport::TestCase | |
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. | |
fixtures :all | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment