Sha256: 8f4128171fbea5d67d3f00e934b9aa9b7243186b61c57787486b14ad953dec0a

Contents?: true

Size: 868 Bytes

Versions: 2

Compression:

Stored size: 868 Bytes

Contents

= 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 (c) 2009 Brandon Dimcheff. See LICENSE for details.

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
bdimcheff-sandbox-0.1.1 README.rdoc
sandbox-0.1.1 README.rdoc