diff options
author | Xavier Noria <fxn@hashref.com> | 2015-12-09 03:07:49 +0100 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2015-12-09 03:07:49 +0100 |
commit | 92a9744f8132f46b0e5f49fa5b4d8c66b4e861cb (patch) | |
tree | 312dce7c4e613094ced1ae963bbff4b2f4962593 /activesupport/test/file_evented_update_checker_test.rb | |
parent | a61e4ae58d65d43a97e90bdb02b6c407791e3c53 (diff) | |
download | rails-92a9744f8132f46b0e5f49fa5b4d8c66b4e861cb.tar.gz rails-92a9744f8132f46b0e5f49fa5b4d8c66b4e861cb.tar.bz2 rails-92a9744f8132f46b0e5f49fa5b4d8c66b4e861cb.zip |
renames AS::FileEventedUpdateChecker to AS::EventedFileUpdateChecker
Better English.
Diffstat (limited to 'activesupport/test/file_evented_update_checker_test.rb')
-rw-r--r-- | activesupport/test/file_evented_update_checker_test.rb | 155 |
1 files changed, 0 insertions, 155 deletions
diff --git a/activesupport/test/file_evented_update_checker_test.rb b/activesupport/test/file_evented_update_checker_test.rb deleted file mode 100644 index ec3a7e28f3..0000000000 --- a/activesupport/test/file_evented_update_checker_test.rb +++ /dev/null @@ -1,155 +0,0 @@ -require 'abstract_unit' -require 'pathname' -require 'file_update_checker_shared_tests' - -class FileEventedUpdateCheckerTest < ActiveSupport::TestCase - include FileUpdateCheckerSharedTests - - def setup - skip if ENV['LISTEN'] == '0' - super - end - - def new_checker(files = [], dirs = {}, &block) - ActiveSupport::FileEventedUpdateChecker.new(files, dirs, &block).tap do - wait - end - end - - def teardown - super - Listen.stop - end - - def wait - sleep 1 - end - - def touch(files) - super - wait # wait for the events to fire - end - - def rm_f(files) - super - wait - end -end - -class FileEventedUpdateCheckerPathHelperTest < ActiveSupport::TestCase - def pn(path) - Pathname.new(path) - end - - setup do - @ph = ActiveSupport::FileEventedUpdateChecker::PathHelper.new - end - - test '#xpath returns the expanded path as a Pathname object' do - assert_equal pn(__FILE__).expand_path, @ph.xpath(__FILE__) - end - - test '#normalize_extension returns a bare extension as is' do - assert_equal 'rb', @ph.normalize_extension('rb') - end - - test '#normalize_extension removes a leading dot' do - assert_equal 'rb', @ph.normalize_extension('.rb') - end - - test '#normalize_extension supports symbols' do - assert_equal 'rb', @ph.normalize_extension(:rb) - end - - test '#longest_common_subpath finds the longest common subpath, if there is one' do - paths = %w( - /foo/bar - /foo/baz - /foo/bar/baz/woo/zoo - ).map { |path| pn(path) } - - assert_equal pn('/foo'), @ph.longest_common_subpath(paths) - end - - test '#longest_common_subpath returns the root directory as an edge case' do - paths = %w( - /foo/bar - /foo/baz - /foo/bar/baz/woo/zoo - /wadus - ).map { |path| pn(path) } - - assert_equal pn('/'), @ph.longest_common_subpath(paths) - end - - test '#longest_common_subpath returns nil for an empty collection' do - assert_nil @ph.longest_common_subpath([]) - end - - test '#existing_parent returns the most specific existing ascendant' do - wd = Pathname.getwd - - assert_equal wd, @ph.existing_parent(wd) - assert_equal wd, @ph.existing_parent(wd.join('non-existing/directory')) - assert_equal pn('/'), @ph.existing_parent(pn('/non-existing/directory')) - end - - test '#filter_out_descendants returns the same collection if there are no descendants (empty)' do - assert_equal [], @ph.filter_out_descendants([]) - end - - test '#filter_out_descendants returns the same collection if there are no descendants (one)' do - assert_equal ['/foo'], @ph.filter_out_descendants(['/foo']) - end - - test '#filter_out_descendants returns the same collection if there are no descendants (several)' do - paths = %w( - /Rails.root/app/controllers - /Rails.root/app/models - /Rails.root/app/helpers - ).map { |path| pn(path) } - - assert_equal paths, @ph.filter_out_descendants(paths) - end - - test '#filter_out_descendants filters out descendants preserving order' do - paths = %w( - /Rails.root/app/controllers - /Rails.root/app/controllers/concerns - /Rails.root/app/models - /Rails.root/app/models/concerns - /Rails.root/app/helpers - ).map { |path| pn(path) } - - assert_equal paths.values_at(0, 2, 4), @ph.filter_out_descendants(paths) - end - - test '#filter_out_descendants works on path units' do - paths = %w( - /foo/bar - /foo/barrrr - ).map { |path| pn(path) } - - assert_equal paths, @ph.filter_out_descendants(paths) - end - - test '#filter_out_descendants deals correctly with the root directory' do - paths = %w( - / - /foo - /foo/bar - ).map { |path| pn(path) } - - assert_equal paths.values_at(0), @ph.filter_out_descendants(paths) - end - - test '#filter_out_descendants preserves duplicates' do - paths = %w( - /foo - /foo/bar - /foo - ).map { |path| pn(path) } - - assert_equal paths.values_at(0, 2), @ph.filter_out_descendants(paths) - end -end |