Spec-Zone.ru › Ruby on Rails 7.2

модуль 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_fixture(fixture_name) Показать исходный код
# 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.

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API