Top Level Namespace

Defined Under Namespace

Modules: Hexx

Instance Method Summary collapse

Instance Method Details

#clear_sandboxObject

Clears the temporary tmp/sandbox.



11
12
13
# File 'lib/hexx-rspec/initializers/sandbox/helpers.rb', line 11

def clear_sandbox
  FileUtils.rm_rf sandbox
end

#prepare_sandboxObject

Re-creates the temporary tmp/sandbox.



16
17
18
19
# File 'lib/hexx-rspec/initializers/sandbox/helpers.rb', line 16

def prepare_sandbox
  clear_sandbox
  FileUtils.mkdir_p sandbox
end

#read_in_sandbox(filename) ⇒ String

Reads file in sandbox and returns file content. Returns a blank string when the file is absent.

Returns:

  • The content.



29
30
31
32
# File 'lib/hexx-rspec/initializers/sandbox/helpers.rb', line 29

def read_in_sandbox(filename)
  file = Dir[File.join(sandbox, filename)].first
  file ? File.read(file) : ""
end

#sandboxString

Returns the path to the temporary tmp/sandbox.

Returns:

  • The absolute path.



6
7
8
# File 'lib/hexx-rspec/initializers/sandbox/helpers.rb', line 6

def sandbox
  @sandbox ||= File.expand_path "tmp/sandbox"
end

#try_in_sandboxObject

Runs code from the temporary tmp/sandbox.



22
23
24
# File 'lib/hexx-rspec/initializers/sandbox/helpers.rb', line 22

def try_in_sandbox
  FileUtils.cd(sandbox) { yield }
end