Spec-Zone.ru › Ruby on Rails 6.1

класс Rails::Generators::TestCase

Родитель:
ActiveSupport::TestCase
Включенные модули:
Rails::Generators::Testing::Behaviour, Rails::Generators::Testing::SetupAndTeardown, Rails::Generators::Testing::Assertions

Этот класс предоставляет TestCase для тестирования генераторов. Для настройки необходимо только настроить целевой каталог и указать, какой генератор тестируется:

class AppGeneratorTest < Rails::Generators::TestCase
  tests AppGenerator
  destination File.expand_path("../tmp", __dir__)
end

Если вы хотите убедиться, что корень целевого каталога чистый перед запуском каждого теста, вы можете установить обратный вызов настройки:

class AppGeneratorTest < Rails::Generators::TestCase
  tests AppGenerator
  destination File.expand_path("../tmp", __dir__)
  setup :prepare_destination
end

© 2004–2020 David Heinemeier Hansson
Licensed under the MIT License.

Spec-Zone.ru

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