Class: Spring::Test::WatcherTest
- Inherits:
-
ActiveSupport::TestCase
- Object
- ActiveSupport::TestCase
- Spring::Test::WatcherTest
- Defined in:
- lib/spring/test/watcher_test.rb
Constant Summary collapse
- LATENCY =
0.001
- TIMEOUT =
1
Instance Attribute Summary collapse
-
#dir ⇒ Object
Returns the value of attribute dir.
Instance Method Summary collapse
- #assert_not_stale ⇒ Object
- #assert_stale ⇒ Object
- #setup ⇒ Object
- #teardown ⇒ Object
- #touch(file, mtime = nil) ⇒ Object
- #watcher ⇒ Object
- #watcher_class ⇒ Object
Instance Attribute Details
#dir ⇒ Object
Returns the value of attribute dir.
14 15 16 |
# File 'lib/spring/test/watcher_test.rb', line 14 def dir @dir end |
Instance Method Details
#assert_not_stale ⇒ Object
45 46 47 48 |
# File 'lib/spring/test/watcher_test.rb', line 45 def assert_not_stale sleep LATENCY * 10 assert !watcher.stale? end |
#assert_stale ⇒ Object
39 40 41 42 43 |
# 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 ⇒ Object
24 25 26 |
# File 'lib/spring/test/watcher_test.rb', line 24 def setup @dir = File.realpath(Dir.mktmpdir) end |
#teardown ⇒ Object
28 29 30 31 |
# File 'lib/spring/test/watcher_test.rb', line 28 def teardown FileUtils.remove_entry_secure @dir watcher.stop end |
#touch(file, mtime = nil) ⇒ Object
33 34 35 36 37 |
# File 'lib/spring/test/watcher_test.rb', line 33 def touch(file, mtime = nil) = {} [:mtime] = mtime if mtime FileUtils.touch(file, ) end |
#watcher ⇒ Object
20 21 22 |
# File 'lib/spring/test/watcher_test.rb', line 20 def watcher @watcher ||= watcher_class.new(dir, LATENCY) end |
#watcher_class ⇒ Object
16 17 18 |
# File 'lib/spring/test/watcher_test.rb', line 16 def watcher_class raise NotImplementedError end |