Sha256: a2ee4dd8ddbeddf0812c8822ae6f5e659b2564b6d241ed04e80b851c70e96e40
Contents?: true
Size: 733 Bytes
Versions: 2
Compression:
Stored size: 733 Bytes
Contents
# encoding: utf-8 require "yaml" # Returns the path to the temporary `tmp/sandbox`. # @return [String] The absolute path. def sandbox @sandbox ||= File.expand_path "tmp/sandbox" end # Clears the temporary `tmp/sandbox`. def clear_sandbox FileUtils.rm_rf sandbox end # Re-creates the temporary `tmp/sandbox`. def prepare_sandbox clear_sandbox FileUtils.mkdir_p sandbox end # Runs code from the temporary `tmp/sandbox`. def try_in_sandbox FileUtils.cd(sandbox) { yield } end # Reads file in sandbox and returns file content. # Returns a blank string when the file is absent. # @return [String] The content. def read_in_sandbox(filename) file = Dir[File.join(sandbox, filename)].first file ? File.read(file) : "" end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
hexx-rspec-0.5.2 | lib/hexx-rspec/initializers/sandbox/helpers.rb |
hexx-rspec-0.5.1 | lib/hexx-rspec/initializers/sandbox/helpers.rb |