Module: ActiveSupport::Testing::Isolation::Forking

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

Instance Method Summary collapse

Instance Method Details

#run_in_isolation(&blk) ⇒ Object



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'activesupport/lib/active_support/testing/isolation.rb', line 84

def run_in_isolation(&blk)
  read, write = IO.pipe

  pid = fork do
    read.close
    yield
    write.puts [Marshal.dump(self.dup)].pack("m")
    exit!
  end

  write.close
  result = read.read
  Process.wait2(pid)
  return result.unpack("m")[0]
end