public
Description: A very simple filesystem sandbox for your tests
Homepage:
Clone URL: git://github.com/bdimcheff/sandbox.git
name age message
file .gitignore Fri Feb 13 21:59:48 -0800 2009 Refactored sandbox so it will work with rspec [bdimcheff]
file LICENSE Fri Feb 13 08:16:27 -0800 2009 Initial commit to sandbox. [bdimcheff]
file README.rdoc Fri Feb 13 21:59:48 -0800 2009 Refactored sandbox so it will work with rspec [bdimcheff]
file Rakefile Fri Feb 13 11:09:29 -0800 2009 hanna rdocs [bdimcheff]
file VERSION.yml Mon Feb 23 15:51:44 -0800 2009 Version bump to 0.1.1 [bdimcheff]
directory features/ Fri Feb 13 08:16:27 -0800 2009 Initial commit to sandbox. [bdimcheff]
directory lib/ Mon Apr 20 08:25:57 -0700 2009 Ruby 1.9.1 compat - need to require 'digest/sha... [dkastner]
file sandbox.gemspec Mon Feb 23 15:51:55 -0800 2009 Regenerated gemspec for version 0.1.1 [bdimcheff]
directory spec/ Wed Mar 04 18:45:28 -0800 2009 automatic directory changing option [bdimcheff]
README.rdoc

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.