跳至內文 跳至搜尋

此類別提供一個 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
包含的模組