Sha256: c20b80a2fe3be455579bc42759c2d94636a1a2424801444ae350aec8da2b57a0
Contents?: true
Size: 1.11 KB
Versions: 3
Compression:
Stored size: 1.11 KB
Contents
require "helper" require "fileutils" require "active_support/core_ext/numeric/time" require "spring/application_watcher" class ApplicationWatcherTest < Test::Unit::TestCase def setup @dir = "/tmp/spring" FileUtils.mkdir(@dir) end def teardown FileUtils.rm_r(@dir) end def touch(file, mtime = nil) options = {} options[:mtime] = mtime if mtime FileUtils.touch(file, options) end def test_file_mtime file = "#{@dir}/omg" touch file, Time.now - 2.seconds watcher = Spring::ApplicationWatcher.new watcher.add_files [file] assert !watcher.stale? touch file, Time.now assert watcher.stale? end def test_glob FileUtils.mkdir("#{@dir}/1") FileUtils.mkdir("#{@dir}/2") watcher = Spring::ApplicationWatcher.new watcher.add_globs ["#{@dir}/1/*.rb", "#{@dir}/2/*"] assert !watcher.stale? touch "#{@dir}/1/foo", Time.now - 1.minute assert !watcher.stale? touch "#{@dir}/1/foo.rb", 2.seconds assert watcher.stale? watcher.reset assert !watcher.stale? touch "#{@dir}/2/foo", Time.now assert watcher.stale? end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
spring-0.0.5 | test/unit/application_watcher_test.rb |
spring-0.0.4 | test/unit/application_watcher_test.rb |
spring-0.0.3 | test/unit/application_watcher_test.rb |