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)


12
13
14
# File 'lib/active_support/testing/isolation.rb', line 12

def self.forking_env?
  !ENV["NO_FORK"] && Process.respond_to?(:fork)
end

.included(klass) ⇒ Object

:nodoc:



6
7
8
9
10
# File 'lib/active_support/testing/isolation.rb', line 6

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



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

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



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

def run
  serialized = run_in_isolation do
    super
  end

  Marshal.load(serialized)
end