Skip to Content Skip to Search

This class provides a TestCase for testing generators. To set up, you need just to configure the destination and set which generator is being tested:

class AppGeneratorTest < Rails::Generators::TestCase
  tests AppGenerator
  setup do
    self.class.destination Dir.mktmpdir("generators", Rails.root.join("tmp").to_s)
  end
  teardown { FileUtils.remove_entry(destination_root) }
end

The setup callback creates a fresh destination root for each test, and teardown removes it after the test.

Included Modules