aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorJack Nagel2015-04-28 22:36:54 -0400
committerJack Nagel2015-04-28 22:36:54 -0400
commitba26567b0309d70030df9929d949c7988b250c4c (patch)
tree9e9cf5aba283bd7f5cada801803019c43c86fb34 /Library
parenta9725657394ee985e7fd4107dcbd253fe1253452 (diff)
downloadbrew-ba26567b0309d70030df9929d949c7988b250c4c.tar.bz2
Manage sandbox test resources in setup/teardown
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/test/test_sandbox.rb24
1 files changed, 12 insertions, 12 deletions
diff --git a/Library/Homebrew/test/test_sandbox.rb b/Library/Homebrew/test/test_sandbox.rb
index eb1ac233d..0e76d0b8c 100644
--- a/Library/Homebrew/test/test_sandbox.rb
+++ b/Library/Homebrew/test/test_sandbox.rb
@@ -4,25 +4,25 @@ require "sandbox"
class SandboxTest < Homebrew::TestCase
def setup
skip "sandbox not implemented" unless Sandbox.available?
+ @sandbox = Sandbox.new
+ @dir = Pathname.new(Dir.mktmpdir)
+ @file = @dir/"foo"
+ end
+
+ def teardown
+ @dir.rmtree
end
def test_allow_write
- s = Sandbox.new
- testpath = Pathname.new(TEST_TMPDIR)
- foo = testpath/"foo"
- s.allow_write foo
- s.exec "touch", foo
- assert_predicate foo, :exist?
- foo.unlink
+ @sandbox.allow_write @file
+ @sandbox.exec "touch", @file
+ assert_predicate @file, :exist?
end
def test_deny_write
- s = Sandbox.new
- testpath = Pathname.new(TEST_TMPDIR)
- bar = testpath/"bar"
shutup do
- assert_raises(ErrorDuringExecution) { s.exec "touch", bar }
+ assert_raises(ErrorDuringExecution) { @sandbox.exec "touch", @file }
end
- refute_predicate bar, :exist?
+ refute_predicate @file, :exist?
end
end