Class: Rails::Generators::TestCase

Inherits:
ActiveSupport::TestCase show all
Includes:
FileUtils, Rails::Generators::Testing::Assertions, Rails::Generators::Testing::Behaviour, Rails::Generators::Testing::SetupAndTeardown
Defined in:
railties/lib/rails/generators/test_case.rb

Overview

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

Constant Summary

Constants inherited from ActiveSupport::TestCase

ActiveSupport::TestCase::Assertion

Method Summary

Methods included from Rails::Generators::Testing::Assertions

#assert_class_method, #assert_field_default_value, #assert_field_type, #assert_file, #assert_instance_method, #assert_migration, #assert_no_file, #assert_no_migration

Methods included from Rails::Generators::Testing::SetupAndTeardown

#setup, #teardown

Methods included from Rails::Generators::Testing::Behaviour

#create_generated_attribute, #generator, #run_generator

Methods included from ActiveSupport::Concern

#append_features, extended, #included

Methods inherited from ActiveSupport::TestCase

#assert_nothing_raised, for_tag

Methods included from ActiveSupport::Testing::Declarative

extended, #test

Methods included from ActiveRecord::TestFixtures

#after_teardown, #before_setup, #enlist_fixture_connections, #run_in_transaction?, #setup_fixtures, #teardown_fixtures

Methods included from ActiveSupport::Testing::TimeHelpers

#travel, #travel_back, #travel_to

Methods included from ActiveSupport::Testing::Deprecation

#assert_deprecated, #assert_not_deprecated, #collect_deprecations

Methods included from ActiveSupport::Testing::Assertions

#assert_difference, #assert_no_difference, #assert_not

Methods included from ActiveSupport::Testing::SetupAndTeardown

#after_teardown, #before_setup

Methods included from ActiveSupport::Testing::TaggedLogging

#before_setup