Merge branch 'speedier-tests' of https://github.com/Raven24/diaspora into Raven24-speedier-tests
This commit is contained in:
commit
3ecd920cd7
4 changed files with 42 additions and 0 deletions
|
|
@ -49,6 +49,7 @@ module ApplicationHelper
|
||||||
end
|
end
|
||||||
buf << [ javascript_include_tag('jquery_ujs') ]
|
buf << [ javascript_include_tag('jquery_ujs') ]
|
||||||
buf << [ javascript_tag("jQuery.ajaxSetup({'cache': false});") ]
|
buf << [ javascript_tag("jQuery.ajaxSetup({'cache': false});") ]
|
||||||
|
buf << [ javascript_tag("$.fx.off = true;") ] if Rails.env.test?
|
||||||
buf.join("\n").html_safe
|
buf.join("\n").html_safe
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -100,3 +100,12 @@ Spork.each_run do
|
||||||
CapybaraSettings.instance.restore
|
CapybaraSettings.instance.restore
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# https://makandracards.com/makandra/950-speed-up-rspec-by-deferring-garbage-collection
|
||||||
|
require File.join(File.dirname(__FILE__), "..", "..", "spec", "support", "deferred_garbage_collection")
|
||||||
|
Before do
|
||||||
|
DeferredGarbageCollection.start
|
||||||
|
end
|
||||||
|
After do
|
||||||
|
DeferredGarbageCollection.reconsider
|
||||||
|
end
|
||||||
|
|
|
||||||
|
|
@ -101,3 +101,13 @@ Spork.each_run do
|
||||||
AppConfig.load!
|
AppConfig.load!
|
||||||
AppConfig.setup!
|
AppConfig.setup!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# https://makandracards.com/makandra/950-speed-up-rspec-by-deferring-garbage-collection
|
||||||
|
RSpec.configure do |config|
|
||||||
|
config.before(:all) do
|
||||||
|
DeferredGarbageCollection.start
|
||||||
|
end
|
||||||
|
config.after(:all) do
|
||||||
|
DeferredGarbageCollection.reconsider
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
||||||
22
spec/support/deferred_garbage_collection.rb
Normal file
22
spec/support/deferred_garbage_collection.rb
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
|
||||||
|
# https://makandracards.com/makandra/950-speed-up-rspec-by-deferring-garbage-collection
|
||||||
|
class DeferredGarbageCollection
|
||||||
|
|
||||||
|
DEFERRED_GC_THRESHOLD = (ENV['DEFER_GC'] || 10.0).to_f
|
||||||
|
|
||||||
|
@@last_gc_run = Time.now
|
||||||
|
|
||||||
|
def self.start
|
||||||
|
GC.disable if DEFERRED_GC_THRESHOLD > 0
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.reconsider
|
||||||
|
if DEFERRED_GC_THRESHOLD > 0 && Time.now - @@last_gc_run >= DEFERRED_GC_THRESHOLD
|
||||||
|
GC.enable
|
||||||
|
GC.start
|
||||||
|
GC.disable
|
||||||
|
@@last_gc_run = Time.now
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
Loading…
Reference in a new issue