Project

sandbox

0.01
No commit activity in last 3 years
No release in over 3 years
A really small filesystem sandbox
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

sandbox¶ ↑

Sandbox is a very small library that creates a folder in tmp for you to be able to perform tests. Your temporary path will be available while the play block is executing. When you’re done, it will clean it up for you.

Sandbox.play do |path|
  FileUtils.touch(File.join(path, 'foo'))
end

# path has been deleted

It will clean up even if you have an exception:

Sandbox.play do |path|
  # do stuff in path
  raise "boom"
end

# path has been deleted

You can also use the Sandbox object directly if necessary:

sbox = Sandbox.new
  # do stuff
sbox.close  # deletes sandbox

This could be useful for RSpec:

before(:each) do
  @sbox = Sandbox.new
end

after(:each) do
  @sbox.close
end

# specs using @sbox (with a new sandbox for each spec)

Copyright¶ ↑

Copyright © 2009 Brandon Dimcheff. See LICENSE for details.