class Rails::Generators::TestCase
Этот класс предоставляет TestCase для тестирования генераторов. Для настройки достаточно указать каталог назначения и задать генератор, который тестируется:
class AppGeneratorTest < Rails::Generators::TestCase
tests AppGenerator
destination File.expand_path("../tmp", __dir__)
end
Если перед запуском каждого теста необходимо убедиться, что корневой каталог назначения пуст, можно задать callback настройки:
class AppGeneratorTest < Rails::Generators::TestCase
tests AppGenerator
destination File.expand_path("../tmp", __dir__)
setup :prepare_destination
end
© 2004–2021 David Heinemeier Hansson
Licensed under the MIT License.