Rails 4 remove test generators (especially test_un

2019-03-27 16:24发布

问题:

How I can remove test_unit generators to make them disappear from the rails generate list?

I have already tried some ways that did not work for me:

config.generators do |g|
  g.test_framework nil
end

create app with -T option.

My rails g output:

[a lot of other generators skipped]

    TestUnit:
      test_unit:controller
      test_unit:helper
      test_unit:integration
      test_unit:mailer
      test_unit:model
      test_unit:plugin
      test_unit:scaffold

回答1:

In your config/application.rb where you have the generations settings, you can hide some of the generators you don't want to see. For example:

config.generators do |g|
  g.hidden_namespaces << :test_unit << :erb
  g.test_framework :mini_test
  g.template_engine :slim
  # ...
end