class Spring::Test::WatcherTest

Constants

LATENCY
TIMEOUT

Attributes

dir[RW]

Public Instance Methods

assert_not_stale() click to toggle source
# File lib/spring/test/watcher_test.rb, line 45
def assert_not_stale
  sleep LATENCY * 10
  assert !watcher.stale?
end
assert_stale() click to toggle source
# File lib/spring/test/watcher_test.rb, line 39
def assert_stale
  timeout = Time.now + TIMEOUT
  sleep LATENCY until watcher.stale? || Time.now > timeout
  assert watcher.stale?
end
setup() click to toggle source
# File lib/spring/test/watcher_test.rb, line 24
def setup
  @dir = File.realpath(Dir.mktmpdir)
end
teardown() click to toggle source
# File lib/spring/test/watcher_test.rb, line 28
def teardown
  FileUtils.remove_entry_secure @dir
  watcher.stop
end
touch(file, mtime = nil) click to toggle source
# File lib/spring/test/watcher_test.rb, line 33
def touch(file, mtime = nil)
  options = {}
  options[:mtime] = mtime if mtime
  FileUtils.touch(file, options)
end
watcher() click to toggle source
# File lib/spring/test/watcher_test.rb, line 20
def watcher
  @watcher ||= watcher_class.new(dir, LATENCY)
end
watcher_class() click to toggle source
# File lib/spring/test/watcher_test.rb, line 16
def watcher_class
  raise NotImplementedError
end