Module: ActiveSupport::Testing::Isolation

Defined in:
lib/active_support/testing/isolation.rb

Defined Under Namespace

Modules: Forking, Subprocess

Constant Summary collapse

@@class_setup_mutex =
Mutex.new

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.forking_env?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/active_support/testing/isolation.rb', line 14

def self.forking_env?
  !ENV["NO_FORK"] && ((RbConfig::CONFIG['host_os'] !~ /mswin|mingw/) && (RUBY_PLATFORM !~ /java/))
end

.included(klass) ⇒ Object

:nodoc:



8
9
10
11
12
# File 'lib/active_support/testing/isolation.rb', line 8

def self.included(klass) #:nodoc:
  klass.class_eval do
    parallelize_me!
  end
end

Instance Method Details

#_run_class_setupObject

class setup method should only happen in parent



20
21
22
23
24
25
26
27
# File 'lib/active_support/testing/isolation.rb', line 20

def _run_class_setup      # class setup method should only happen in parent
  @@class_setup_mutex.synchronize do
    unless defined?(@@ran_class_setup) || ENV['ISOLATION_TEST']
      self.class.setup if self.class.respond_to?(:setup)
      @@ran_class_setup = true
    end
  end
end

#runObject



29
30
31
32
33
34
35
# File 'lib/active_support/testing/isolation.rb', line 29

def run
  serialized = run_in_isolation do
    super
  end

  Marshal.load(serialized)
end