Sha256: 222123dd3e7778338bf7e53262bd3c268b4158913b5fd8e59219463b03d54f41

Contents?: true

Size: 550 Bytes

Versions: 1

Compression:

Stored size: 550 Bytes

Contents

require_relative "capture"

# Path to the `tmp/sandbox`.
def sandbox
  @sandbox ||= File.expand_path "../../../../../tmp/sandbox", __FILE__
end

# Clears `tmp/sandbox`.
def clear_sandbox
  FileUtils.rm_rf sandbox
end

# Re-creates `spec/sandbox`.
def prepare_sandbox
  clear_sandbox
  FileUtils.mkdir_p sandbox
end

# Runs code from `sandbox`.
def try_in_sandbox
  FileUtils.cd(sandbox) { capture(:stdout) { yield } }
end

# Runs cli from `sandbox`.
def run_in_sandbox(command)
  result = ""
  try_in_sandbox { result = `#{ command }` }
  result
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
uuids-1.4.1 spec/support/development/helpers/sandbox.rb