модуль ActiveSupport::Testing::FileFixtures
Добавляет простой доступ к образцовым файлам, называемым файловыми фикстурами. File фикстуры — это обычные файлы, хранящиеся в ActiveSupport::TestCase.file_fixture_path.
File фикстуры представлены в виде Pathname объектов. Это упрощает извлечение конкретной информации:
file_fixture("example.txt").read # get the file's content
file_fixture("example.mp3").size # get the file size
Открытые методы экземпляров
# File activesupport/lib/active_support/testing/file_fixtures.rb, line 26
def file_fixture(fixture_name)
path = Pathname.new(File.join(file_fixture_path, fixture_name))
if path.exist?
path
else
msg = "the directory '%s' does not contain a file named '%s'"
raise ArgumentError, msg % [file_fixture_path, fixture_name]
end
end Возвращает Pathname к файлу фикстуры с именем fixture_name.
Вызывает ArgumentError если fixture_name не найден.
© 2004–2021 David Heinemeier Hansson
Licensed under the MIT License.