Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Remove tmp dir after spec run

  • Loading branch information...
commit 943040af2c69d4458eb85c349efcc77903fb9ac7 1 parent 8b9e2ed
@mynyml authored
Showing with 13 additions and 18 deletions.
  1. +11 −17 test/event_handlers/test_darwin.rb
  2. +2 −1  test/test_helper.rb
View
28 test/event_handlers/test_darwin.rb
@@ -14,26 +14,16 @@ def restart() end #noop
class DarwinEventHandlerTest < MiniTest::Unit::TestCase
include Watchr
- private
-
def tempfile(name)
- file = Tempfile.new(name, tmpdir.to_s)
+ file = Tempfile.new(name, @root.to_s)
Pathname(file.path)
ensure
file.close
end
- # TODO clean up tmpdirs after tests run
- def tmpdir
- @@_tmpdir ||= Pathname(Dir.mktmpdir("watchrspecs_"))
- end
- alias :root :tmpdir
-
- #at_exit { @@_tmpdir.delete }
-
- public
-
def setup
+ @root = Pathname(Dir.mktmpdir("WATCHR_SPECS-"))
+
@now = Time.now
@handler = EventHandler::Darwin.new
@@ -41,6 +31,10 @@ def setup
@bar = tempfile('bar').expand_path
end
+ def teardown
+ FileUtils.remove_entry_secure(@root.to_s)
+ end
+
test "listening triggers listening state" do
@handler.expects(:start)
@handler.listen([])
@@ -74,7 +68,7 @@ def setup
@handler.listen [ @foo, @bar ]
@handler.expects(:notify).with(@foo, :deleted)
- @handler.on_change [root]
+ @handler.on_change [@root]
end
test "modified file event" do
@@ -82,7 +76,7 @@ def setup
@handler.expects(:notify).with(@foo, :modified)
@handler.listen [ @foo, @bar ]
- @handler.on_change [root]
+ @handler.on_change [@root]
end
test "accessed file event" do
@@ -90,7 +84,7 @@ def setup
@handler.expects(:notify).with(@foo, :accessed)
@handler.listen [ @foo, @bar ]
- @handler.on_change [root]
+ @handler.on_change [@root]
end
test "changed file event" do
@@ -98,7 +92,7 @@ def setup
@handler.expects(:notify).with(@foo, :changed)
@handler.listen [ @foo, @bar ]
- @handler.on_change [root]
+ @handler.on_change [@root]
end
## internal
View
3  test/test_helper.rb
@@ -1,6 +1,7 @@
require 'pathname'
+require 'tmpdir'
require 'tempfile'
-require 'set'
+require 'fileutils'
require 'minitest/autorun'
require 'mocha'
Please sign in to comment.
Something went wrong with that request. Please try again.