Skip to content

Instantly share code, notes, and snippets.

@chrismanderson
Last active February 1, 2018 21:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrismanderson/2fb4d942ecb140c7080a3656d2643c49 to your computer and use it in GitHub Desktop.
Save chrismanderson/2fb4d942ecb140c7080a3656d2643c49 to your computer and use it in GitHub Desktop.
test_helper
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