By default, minitest-rails enables the Minitest::Spec DSL within Rails TestCase classes (like ActiveSupport::TestCase). When you use standard Rails generators (model, controller, etc.), they will generate tests using the Spec DSL.
Generator Options
- Disable Spec DSL: If you want to generate tests without the
Minitest::Spec DSL, use the --no-spec flag. - Skip Fixtures: To generate a model without a corresponding fixture file, use the
--skip-fixture flag.
Setting Defaults
You can configure your Rails application to always use standard Minitest (without Spec DSL) and skip fixtures by adding the following to config/application.rb:
config.generators do |g|
g.test_framework :minitest, spec: false, fixture: false
end
# Example: Generating a model with Spec DSL (default)
rails generate model User
# Example: Generating a model without Spec DSL
rails generate model User --no-spec
# Example: Generating a model without a fixture
rails generate model User --skip-fixture