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", __dir__)
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", __dir__)
  setup :prepare_destination
end

Constant Summary

Constants inherited from ActiveSupport::TestCase

ActiveSupport::TestCase::Assertion

Constants included from ActiveSupport::Testing::Assertions

ActiveSupport::Testing::Assertions::UNTRACKED

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, #class_methods, extended, #included

Methods inherited from ActiveSupport::TestCase

parallelize, parallelize_setup, parallelize_teardown, test_order, test_order=

Methods included from ActiveSupport::Testing::Declarative

#test

Methods included from ActiveSupport::Testing::FileFixtures

#file_fixture

Methods included from ActiveSupport::Testing::TimeHelpers

#after_teardown, #freeze_time, #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_changes, #assert_difference, #assert_no_changes, #assert_no_difference, #assert_not, #assert_nothing_raised

Methods included from ActiveSupport::Testing::TaggedLogging

#before_setup