module ActiveSupport::Testing::Isolation::Forking - activesupport-4.2.3 Documentation

# module ActiveSupport::Testing::Isolation::Forking

### Public Instance Methods

run_in_isolation() { || ... } click to toggle source

    # File lib/active_support/testing/isolation.rb, line 38
    def run_in_isolation(&blk)
      read, write = IO.pipe
      read.binmode
      write.binmode

      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