aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2015-11-09 09:11:13 -0800
committerXavier Noria <fxn@hashref.com>2015-11-09 09:11:13 -0800
commit9a59beac6feced4e51fdddb5761208472be71719 (patch)
treee337775131d3394c25fce10bb94fb4c9e527ad54 /activesupport
parentab0c915ab54538f66406edc44070c1bdeacdd844 (diff)
downloadrails-9a59beac6feced4e51fdddb5761208472be71719.tar.gz
rails-9a59beac6feced4e51fdddb5761208472be71719.tar.bz2
rails-9a59beac6feced4e51fdddb5761208472be71719.zip
adds more tests for the file monitors
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/test/file_update_checker_with_enumerable_test_cases.rb60
1 files changed, 60 insertions, 0 deletions
diff --git a/activesupport/test/file_update_checker_with_enumerable_test_cases.rb b/activesupport/test/file_update_checker_with_enumerable_test_cases.rb
index 1518562d7c..250fd90dde 100644
--- a/activesupport/test/file_update_checker_with_enumerable_test_cases.rb
+++ b/activesupport/test/file_update_checker_with_enumerable_test_cases.rb
@@ -130,4 +130,64 @@ module FileUpdateCheckerWithEnumerableTestCases
assert !checker.execute_if_updated
assert_equal 0, i
end
+
+ def test_does_not_assume_files_exist_on_instantiation
+ i = 0
+
+ non_existing = "#{@tmpdir}/non_existing.rb"
+ checker = new_checker([non_existing]) { i += 1 }
+
+ touch(non_existing)
+ wait
+
+ assert checker.execute_if_updated
+ assert_equal 1, i
+ end
+
+ def test_detects_files_in_new_subdirectories
+ i = 0
+
+ checker = new_checker([], @tmpdir => :rb) { i += 1 }
+
+ subdir = "#{@tmpdir}/subdir"
+ mkdir(subdir)
+ wait
+
+ assert !checker.execute_if_updated
+ assert_equal 0, i
+
+ touch("#{subdir}/nested.rb")
+ wait
+
+ assert checker.execute_if_updated
+ assert_equal 1, i
+ end
+
+ def test_looked_up_extensions_are_inherited_in_subdirectories_not_listening_to_them
+ i = 0
+
+ subdir = "#{@tmpdir}/subdir"
+ mkdir(subdir)
+
+ checker = new_checker([], @tmpdir => :rb, subdir => :txt) { i += 1 }
+
+ touch("#{@tmpdir}/new.txt")
+ wait
+
+ assert !checker.execute_if_updated
+ assert_equal 0, i
+
+ # subdir does not look for Ruby files, but its parent @tmpdir does.
+ touch("#{subdir}/nested.rb")
+ wait
+
+ assert checker.execute_if_updated
+ assert_equal 1, i
+
+ touch("#{subdir}/nested.txt")
+ wait
+
+ assert checker.execute_if_updated
+ assert_equal 2, i
+ end
end