internetee-registry/config/initializers/file_exists_alias.rb
oleghasjanov 3b594cf30d fix tests
2025-04-16 11:47:52 +03:00

11 lines
No EOL
913 B
Ruby
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# В Ruby метод File.exist? является основным, а File.exists? - устаревшим алиасом.
# Однако в некоторых тестах или библиотеках может использоваться именно File.exists?.
# Этот инициализатор добавляет алиас, чтобы оба метода работали корректно.
if !File.respond_to?(:exist?) && File.respond_to?(:exists?)
# Если exist? не определен, но exists? определен - добавляем алиас exist? -> exists?
File.singleton_class.send(:alias_method, :exist?, :exists?)
elsif !File.respond_to?(:exists?) && File.respond_to?(:exist?)
# Если exists? не определен, но exist? определен - добавляем алиас exists? -> exist?
File.singleton_class.send(:alias_method, :exists?, :exist?)
end