about summary refs log tree commit diff
path: root/spec/spec_helper.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2017-08-24 13:31:55 +0200
committerGitHub <noreply@github.com>2017-08-24 13:31:55 +0200
commitc66fe2aeba84af5ab47c20298ddc8dceaf0e179f (patch)
tree2a07c5345ab567cc1409639874f15ccf8982118a /spec/spec_helper.rb
parentfbe1115114edb2d46c05b5065398b7234b9fb6a0 (diff)
Minor performance improvement for test suite (#4678)
Diffstat (limited to 'spec/spec_helper.rb')
-rw-r--r--spec/spec_helper.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 2bc462121..eecaec4ac 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,11 +1,15 @@
 require 'simplecov'
 
+GC.disable
+
 SimpleCov.start 'rails' do
   add_group 'Services', 'app/services'
   add_group 'Presenters', 'app/presenters'
   add_group 'Validators', 'app/validators'
 end
 
+gc_counter = -1
+
 RSpec.configure do |config|
   config.expect_with :rspec do |expectations|
     expectations.include_chain_clauses_in_custom_matcher_descriptions = true
@@ -22,8 +26,21 @@ RSpec.configure do |config|
   end
 
   config.after :suite do
+    gc_counter = 0
     FileUtils.rm_rf(Dir["#{Rails.root}/spec/test_files/"])
   end
+
+  config.after :each do
+    gc_counter += 1
+
+    if gc_counter > 19
+      GC.enable
+      GC.start
+      GC.disable
+
+      gc_counter = 0
+    end
+  end
 end
 
 def body_as_json