class

Rails::Generators::TestCase

v4.1.8 - Show latest stable - Superclass: ActiveSupport::TestCase

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

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

If you want to ensure your destination root is clean before running each test, you can set a setup callback:

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

Included modules

  • FileUtils
  • Rails::Generators::Testing::Assertions
  • Rails::Generators::Testing::Behaviour
  • Rails::Generators::Testing::SetupAndTeardown

Files

  • railties/lib/rails/generators/test_case.rb