Skip to content
Newer
Older
100644 52 lines (33 sloc) 1.08 KB
0e673a4 @jeremylightsmith moving to github
authored Mar 14, 2012
1 = Project: File Sandbox v0.4
2
3 == Description
4
5 File sandbox creates a space for your tests to safely hit the file system. It also makes it easier for them to do so. By cleaning up after them.
6
7 == Usage
8
9 in rspec :
10
11 require 'file_sandbox_behavior'
cf63187 @grosser Cleanup for RSpec2 and addition of Gemfile
grosser authored Mar 16, 2012
12
0e673a4 @jeremylightsmith moving to github
authored Mar 15, 2012
13 describe File do
14 include FileSandbox
cf63187 @grosser Cleanup for RSpec2 and addition of Gemfile
grosser authored Mar 16, 2012
15
0e673a4 @jeremylightsmith moving to github
authored Mar 15, 2012
16 it 'should read the contents of a file' do
17 sandbox.new :file => 'b/a.txt', :with_contents => 'some stuff'
cf63187 @grosser Cleanup for RSpec2 and addition of Gemfile
grosser authored Mar 16, 2012
18
0e673a4 @jeremylightsmith moving to github
authored Mar 15, 2012
19 sandbox['/b/a.txt'].contents.should == 'some stuff'
20 File.read(sandbox.root + "/b/a.txt").should == 'some stuff'
21 end
22 end
23
24 in test unit :
25
26 require 'test/unit'
27 require 'file_sandbox'
cf63187 @grosser Cleanup for RSpec2 and addition of Gemfile
grosser authored Mar 16, 2012
28
0e673a4 @jeremylightsmith moving to github
authored Mar 15, 2012
29 class MyFileTest < Test::Unit::TestCase
30 include FileSandbox
cf63187 @grosser Cleanup for RSpec2 and addition of Gemfile
grosser authored Mar 16, 2012
31
0e673a4 @jeremylightsmith moving to github
authored Mar 15, 2012
32 def test_read
33 in_sandbox do |sandbox|
34 sandbox.new :file => 'b/a.txt', :with_contents => 'some stuff'
cf63187 @grosser Cleanup for RSpec2 and addition of Gemfile
grosser authored Mar 16, 2012
35
0e673a4 @jeremylightsmith moving to github
authored Mar 15, 2012
36 assert_equal 'some stuff', File.read(sandbox.root + '/b/a.txt')
37 assert_equal 'some stuff', sandbox['/b/a.txt'].contents
38 end
39 end
40 end
cf63187 @grosser Cleanup for RSpec2 and addition of Gemfile
grosser authored Mar 16, 2012
41
0e673a4 @jeremylightsmith moving to github
authored Mar 15, 2012
42
43 == Contact
44
45 Author:: Jeremy Stell-Smith
46 Email:: jeremystellsmith@gmail.com
47 License:: LGPL License
48
49 == Home Page
50
cf63187 @grosser Cleanup for RSpec2 and addition of Gemfile
grosser authored Mar 16, 2012
51 http://onemanswalk.com
Something went wrong with that request. Please try again.