Skip to content

Repository files navigation

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.playdo|path|FileUtils.touch(File.join(path, 'foo'))
end# path has been deleted

It will clean up even if you have an exception:

Sandbox.playdo|path|# do stuff in pathraise"boom"end# path has been deleted

You can also use the Sandbox object directly if necessary:

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

This could be useful for RSpec:

before(:each) do@sbox = Sandbox.newendafter(:each) do@sbox.closeend# specs using @sbox (with a new sandbox for each spec)

Copyright © 2009 Brandon Dimcheff. See LICENSE for details.

About

A very simple filesystem sandbox for your tests

Resources

Stars

17 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages