Class: Rails::Generators::TestCase
| Relationships & Source Files | |
| Super Chains via Extension / Inclusion / Inheritance | |
|
Class Chain:
self,
::ActiveSupport::TestCase,
::ActiveSupport::Testing::Declarative,
Minitest::Test
|
|
|
Instance Chain:
self,
FileUtils,
Testing::Assertions,
Testing::SetupAndTeardown,
Testing::Behavior,
::ActiveSupport::TestCase,
::ActiveSupport::Testing::FileFixtures,
::ActiveSupport::Testing::TimeHelpers,
::ActiveSupport::Testing::ConstantStubbing,
::ActiveSupport::Testing::Deprecation,
::ActiveSupport::Testing::ErrorReporterAssertions,
::ActiveSupport::Testing::Assertions,
::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 set up, you need just to configure the destination and set which generator is being tested:
class AppGeneratorTest < Rails::Generators::TestCase
tests AppGenerator
destination File.("../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.("../tmp", __dir__)
setup :prepare_destination
end
Constant Summary
::ActiveSupport::TestCase - Inherited
Testing::Behavior - 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
| .file_fixture_path, .file_fixture_path?, | |
| .test_order | Returns the order in which test cases are run. |
| .test_order= | Sets the order in which test cases are run. |
Class Method Summary
::ActiveSupport::TestCase - Inherited
| .fixture_paths | Returns the |
| .fixture_paths= | Sets the given path to the fixture set. |
| .parallelize | Parallelizes the test suite. |
| .parallelize_setup | Set up hook for parallel testing. |
| .parallelize_teardown | Clean up hook for parallel testing. |
::ActiveSupport::Testing::Declarative - Extended
Instance Attribute Summary
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_initializer | Asserts a given initializer 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::Behavior - Included
| #create_generated_attribute | Create a |
| #generator | Instantiate the generator. |
| #run_generator | Runs the generator configured for this class. |
| #prepare_destination | Clears all files and directories in destination. |
::ActiveSupport::TestCase - Inherited
| #assert_no_match | Alias for: refute_match |
| #assert_not_empty | Alias for: refute_empty |
| #assert_not_equal | Alias for: refute_equal |
| #assert_not_in_delta | Alias for: refute_in_delta |
| #assert_not_in_epsilon | Alias for: refute_in_epsilon |
| #assert_not_includes | Alias for: refute_includes |
| #assert_not_instance_of | Alias for: refute_instance_of |
| #assert_not_kind_of | Alias for: refute_kind_of |
| #assert_not_nil | Alias for: refute_nil |
| #assert_not_operator | Alias for: refute_operator |
| #assert_not_predicate | Alias for: refute_predicate |
| #assert_not_respond_to | Alias for: refute_respond_to |
| #assert_not_same | Alias for: refute_same |
| #method_name | |
::ActiveSupport::Testing::FileFixtures - Included
| #file_fixture | Returns a |
::ActiveSupport::Testing::TimeHelpers - Included
| #after_teardown, | |
| #freeze_time | Calls |
| #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 |
| #unfreeze_time | |
::ActiveSupport::Testing::ConstantStubbing - Included
| #stub_const | Changes the value of a constant for the duration of a block. |
::ActiveSupport::Testing::Deprecation - Included
| #assert_deprecated | Asserts that a matching deprecation warning was emitted by the given deprecator during the execution of the yielded block. |
| #assert_not_deprecated | Asserts that no deprecation warnings are emitted by the given deprecator during the execution of the yielded block. |
| #collect_deprecations | Returns the return value of the block and an array of all the deprecation warnings emitted by the given Rails.deprecator during the execution of the yielded block. |
::ActiveSupport::Testing::ErrorReporterAssertions - Included
| #assert_error_reported | Assertion that the block should cause at least one exception to be reported to Rails.error. |
| #assert_no_error_reported | Assertion that the block should not cause an exception to be reported to Rails.error. |
::ActiveSupport::Testing::Assertions - Included
| #assert_changes | Assertion that the result of evaluating an expression is changed before and after invoking the passed in block. |
| #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_changes | Assertion that the result of evaluating an expression is not changed before and after invoking the passed in 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 | Asserts that an expression is not truthy. |
| #assert_nothing_raised | Assertion that the block should not raise an exception. |
| #assert_raise | |
| #assert_raises | Asserts that a block raises one of |
Class Attribute Details
.current_path (rw)
[ GitHub ]# File 'railties/lib/rails/generators/testing/behavior.rb', line 21
class_attribute :current_path, default: File.(Dir.pwd)
.current_path? ⇒ Boolean (rw)
[ GitHub ]
# File 'railties/lib/rails/generators/testing/behavior.rb', line 21
class_attribute :current_path, default: File.(Dir.pwd)
.default_arguments (rw)
[ GitHub ]# File 'railties/lib/rails/generators/testing/behavior.rb', line 22
class_attribute :default_arguments, default: []
.default_arguments? ⇒ Boolean (rw)
[ GitHub ]
# File 'railties/lib/rails/generators/testing/behavior.rb', line 22
class_attribute :default_arguments, default: []
.destination_root (rw)
[ GitHub ]# File 'railties/lib/rails/generators/testing/behavior.rb', line 23
class_attribute :destination_root
.destination_root? ⇒ Boolean (rw)
[ GitHub ]
# File 'railties/lib/rails/generators/testing/behavior.rb', line 23
class_attribute :destination_root
.generator_class (rw)
[ GitHub ]# File 'railties/lib/rails/generators/testing/behavior.rb', line 24
class_attribute :generator_class
.generator_class? ⇒ Boolean (rw)
[ GitHub ]
# File 'railties/lib/rails/generators/testing/behavior.rb', line 24
class_attribute :generator_class
Instance Attribute Details
#current_path (rw)
[ GitHub ]# File 'railties/lib/rails/generators/testing/behavior.rb', line 21
class_attribute :current_path, default: File.(Dir.pwd)
#current_path? ⇒ Boolean (rw)
[ GitHub ]
# File 'railties/lib/rails/generators/testing/behavior.rb', line 21
class_attribute :current_path, default: File.(Dir.pwd)
#default_arguments (rw)
[ GitHub ]# File 'railties/lib/rails/generators/testing/behavior.rb', line 22
class_attribute :default_arguments, default: []
#default_arguments? ⇒ Boolean (rw)
[ GitHub ]
# File 'railties/lib/rails/generators/testing/behavior.rb', line 22
class_attribute :default_arguments, default: []
#destination_root (rw)
[ GitHub ]# File 'railties/lib/rails/generators/testing/behavior.rb', line 23
class_attribute :destination_root
#destination_root? ⇒ Boolean (rw)
[ GitHub ]
# File 'railties/lib/rails/generators/testing/behavior.rb', line 23
class_attribute :destination_root
#generator_class (rw)
[ GitHub ]# File 'railties/lib/rails/generators/testing/behavior.rb', line 24
class_attribute :generator_class
#generator_class? ⇒ Boolean (rw)
[ GitHub ]
# File 'railties/lib/rails/generators/testing/behavior.rb', line 24
class_attribute :generator_class