Class: Rails::Generators::TestCase
| Relationships & Source Files | |
| Super Chains via Extension / Inclusion / Inheritance | |
| Class Chain: 
          self,
          ::ActiveSupport::TestCase,
          ::ActiveSupport::DescendantsTracker,
          ::ActiveSupport::Testing::Declarative,
          Minitest::Test
         | |
| Instance Chain: 
          self,
          FileUtils,
          Testing::Assertions,
          Testing::SetupAndTeardown,
          Testing::Behaviour,
          ::ActiveSupport::TestCase,
          ::ActiveRecord::TestFixtures,
          ::ActiveSupport::Testing::TimeHelpers,
          ::ActiveSupport::Testing::Assertions,
          ::ActiveSupport::Callbacks,
          ::ActiveSupport::Testing::SetupAndTeardown,
          Minitest::Test
         | |
| Inherits: | ActiveSupport::TestCase 
 | 
| 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.("../tmp", File.dirname(__FILE__))
endIf 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.("../tmp", File.dirname(__FILE__))
  setup :prepare_destination
endConstant Summary
::ActiveSupport::Callbacks - Inherited
::ActiveSupport::TestCase - Inherited
Testing::Behaviour - Attributes & Methods
- .current_path rw
- #current_path rw
- .current_path? ⇒ Boolean rw
- #current_path? ⇒ Boolean rw
- .default_arguments rw
- #default_arguments rw
- .default_arguments? ⇒ Boolean rw
- #default_arguments? ⇒ Boolean rw
- .destination_root rw
- #destination_root rw
- .destination_root? ⇒ Boolean rw
- #destination_root? ⇒ Boolean rw
- .generator_class rw
- #generator_class rw
- .generator_class? ⇒ Boolean rw
- #generator_class? ⇒ Boolean rw
Class Attribute Summary
::ActiveSupport::TestCase - Inherited
| .config, .config?, .fixture_class_names, .fixture_class_names?, .fixture_path, .fixture_path?, .fixture_table_names, .fixture_table_names?, .pre_loaded_fixtures, .pre_loaded_fixtures?, | |
| .test_order | Returns the order in which test cases are run. | 
| .test_order= | Sets the order in which test cases are run. | 
| .use_instantiated_fixtures, .use_instantiated_fixtures?, .use_transactional_fixtures, .use_transactional_fixtures? | |
Class Method Summary
::ActiveSupport::TestCase - Inherited
::ActiveSupport::DescendantsTracker - Inherited
| clear, descendants, direct_descendants, | |
| store_inherited | This is the only method that is not thread safe, but is only ever called during the eager loading phase. | 
::ActiveSupport::Testing::Declarative - Extended
Instance Attribute Summary
::ActiveSupport::TestCase - Inherited
::ActiveRecord::TestFixtures - Included
Instance Method Summary
Testing::Assertions - Included
| #assert_class_method | Asserts the given class method exists in the given content. | 
| #assert_directory | Alias for Testing::Assertions#assert_file. | 
| #assert_field_default_value | Asserts the given attribute type gets a proper default value: | 
| #assert_field_type | Asserts the given attribute type gets translated to a field type properly: | 
| #assert_file | Asserts a given file exists. | 
| #assert_instance_method | Asserts the given method exists in the given content. | 
| #assert_method | Alias for Testing::Assertions#assert_instance_method. | 
| #assert_migration | Asserts a given migration exists. | 
| #assert_no_directory | Alias for Testing::Assertions#assert_no_file. | 
| #assert_no_file | Asserts a given file does not exist. | 
| #assert_no_migration | Asserts a given migration does not exist. | 
Testing::Behaviour - Included
| #create_generated_attribute | Create a GeneratedAttribute by supplying the attribute type and, optionally, the attribute name: | 
| #generator | Instantiate the generator. | 
| #run_generator | Runs the generator configured for this class. | 
::ActiveSupport::TestCase - Inherited
| #assert_no_match, #assert_not_empty, #assert_not_equal, #assert_not_in_delta, #assert_not_in_epsilon, #assert_not_includes, #assert_not_instance_of, #assert_not_kind_of, #assert_not_nil, #assert_not_operator, #assert_not_predicate, #assert_not_respond_to, #assert_not_same, | |
| #assert_nothing_raised | Fails if the block raises an exception. | 
| #assert_raise | test/unit backwards compatibility methods. | 
| #method_name | |
::ActiveRecord::TestFixtures - Included
::ActiveSupport::Testing::TimeHelpers - Included
| #travel | Changes current time to the time in the future or in the past by a given time difference by stubbing  | 
| #travel_back | Returns the current time back to its original state, by removing the stubs added by  | 
| #travel_to | Changes current time to the given time by stubbing  | 
::ActiveSupport::Testing::Assertions - Included
| #assert_difference | Test numeric difference between the return value of an expression as a result of what is evaluated in the yielded block. | 
| #assert_no_difference | Assertion that the numeric result of evaluating an expression is not changed before and after invoking the passed in block. | 
| #assert_not | Assert that an expression is not truthy. | 
::ActiveSupport::Callbacks - Inherited
| #run_callbacks | Runs the callbacks for the given event. | 
Class Attribute Details
.current_path (rw)
[ GitHub ]# File 'railties/lib/rails/generators/testing/behaviour.rb', line 15
class_attribute :destination_root, :current_path, :generator_class, :default_arguments
    .current_path?  ⇒ Boolean  (rw)
  
  [ GitHub ]
# File 'railties/lib/rails/generators/testing/behaviour.rb', line 15
class_attribute :destination_root, :current_path, :generator_class, :default_arguments
.default_arguments (rw)
[ GitHub ]# File 'railties/lib/rails/generators/testing/behaviour.rb', line 15
class_attribute :destination_root, :current_path, :generator_class, :default_arguments
    .default_arguments?  ⇒ Boolean  (rw)
  
  [ GitHub ]
# File 'railties/lib/rails/generators/testing/behaviour.rb', line 15
class_attribute :destination_root, :current_path, :generator_class, :default_arguments
.destination_root (rw)
[ GitHub ]# File 'railties/lib/rails/generators/testing/behaviour.rb', line 15
class_attribute :destination_root, :current_path, :generator_class, :default_arguments
    .destination_root?  ⇒ Boolean  (rw)
  
  [ GitHub ]
# File 'railties/lib/rails/generators/testing/behaviour.rb', line 15
class_attribute :destination_root, :current_path, :generator_class, :default_arguments
.generator_class (rw)
[ GitHub ]# File 'railties/lib/rails/generators/testing/behaviour.rb', line 15
class_attribute :destination_root, :current_path, :generator_class, :default_arguments
    .generator_class?  ⇒ Boolean  (rw)
  
  [ GitHub ]
# File 'railties/lib/rails/generators/testing/behaviour.rb', line 15
class_attribute :destination_root, :current_path, :generator_class, :default_arguments
Instance Attribute Details
#current_path (rw)
[ GitHub ]# File 'railties/lib/rails/generators/testing/behaviour.rb', line 15
class_attribute :destination_root, :current_path, :generator_class, :default_arguments
    #current_path?  ⇒ Boolean  (rw)
  
  [ GitHub ]
# File 'railties/lib/rails/generators/testing/behaviour.rb', line 15
class_attribute :destination_root, :current_path, :generator_class, :default_arguments
#default_arguments (rw)
[ GitHub ]# File 'railties/lib/rails/generators/testing/behaviour.rb', line 15
class_attribute :destination_root, :current_path, :generator_class, :default_arguments
    #default_arguments?  ⇒ Boolean  (rw)
  
  [ GitHub ]
# File 'railties/lib/rails/generators/testing/behaviour.rb', line 15
class_attribute :destination_root, :current_path, :generator_class, :default_arguments
#destination_root (rw)
[ GitHub ]# File 'railties/lib/rails/generators/testing/behaviour.rb', line 15
class_attribute :destination_root, :current_path, :generator_class, :default_arguments
    #destination_root?  ⇒ Boolean  (rw)
  
  [ GitHub ]
# File 'railties/lib/rails/generators/testing/behaviour.rb', line 15
class_attribute :destination_root, :current_path, :generator_class, :default_arguments
#generator_class (rw)
[ GitHub ]# File 'railties/lib/rails/generators/testing/behaviour.rb', line 15
class_attribute :destination_root, :current_path, :generator_class, :default_arguments
    #generator_class?  ⇒ Boolean  (rw)
  
  [ GitHub ]
# File 'railties/lib/rails/generators/testing/behaviour.rb', line 15
class_attribute :destination_root, :current_path, :generator_class, :default_arguments