test/unit/application_watcher_test.rb in spring-0.0.5 vs test/unit/application_watcher_test.rb in spring-0.0.6
- old
+ new
@@ -1,11 +1,11 @@
require "helper"
require "fileutils"
require "active_support/core_ext/numeric/time"
require "spring/application_watcher"
-class ApplicationWatcherTest < Test::Unit::TestCase
+class ApplicationWatcherTest < ActiveSupport::TestCase
def setup
@dir = "/tmp/spring"
FileUtils.mkdir(@dir)
end
@@ -17,11 +17,11 @@
options = {}
options[:mtime] = mtime if mtime
FileUtils.touch(file, options)
end
- def test_file_mtime
+ test "file mtime" do
file = "#{@dir}/omg"
touch file, Time.now - 2.seconds
watcher = Spring::ApplicationWatcher.new
watcher.add_files [file]
@@ -29,10 +29,22 @@
assert !watcher.stale?
touch file, Time.now
assert watcher.stale?
end
- def test_glob
+ test "tolerates enoent" do
+ file = "#{@dir}/omg"
+ touch file
+
+ watcher = Spring::ApplicationWatcher.new
+ watcher.add_files [file]
+
+ assert !watcher.stale?
+ FileUtils.rm(file)
+ assert watcher.stale?
+ end
+
+ test "accepts glob patterns" do
FileUtils.mkdir("#{@dir}/1")
FileUtils.mkdir("#{@dir}/2")
watcher = Spring::ApplicationWatcher.new
watcher.add_globs ["#{@dir}/1/*.rb", "#{@dir}/2/*"]