Module: ActiveSupport::Testing::Isolation

Defined in:
activesupport/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)


60
61
62
# File 'activesupport/lib/active_support/testing/isolation.rb', line 60

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

.included(klass) ⇒ Object

:nodoc:



52
53
54
55
56
57
58
# File 'activesupport/lib/active_support/testing/isolation.rb', line 52

def self.included(klass) #:nodoc:
  klass.extend(Module.new {
    def test_methods
      ParallelEach.new super
    end
  })
end

Instance Method Details

#_run_class_setupObject

class setup method should only happen in parent



66
67
68
69
70
71
72
73
# File 'activesupport/lib/active_support/testing/isolation.rb', line 66

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



75
76
77
78
79
80
81
# File 'activesupport/lib/active_support/testing/isolation.rb', line 75

def run
  serialized = run_in_isolation do
    super
  end

  Marshal.load(serialized)
end