Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Hide test_unit generators when other frameworks are assigned as test_framework

#5111

Given this in a Railtie:

config.generators.test_framework   :rspec

When I run script/rails generate
Then I get the following output

...
Please choose a generator below.

Rails:
  ...

Rspec:
  rspec:install

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

It would be nice if the test_unit:xxx generators were not visible here.

Need to make sure test_unit:integration DOES show up, however, if there is no integration_tool specified in a Railtie.

Reported by David Chelimsky · July 14th, 2010 @ 01:25 PM

State: new
Milestone: none
Assigned to: José Valim José Valim
Importance: Low

Activity

  1. Neeraj Singh
    Neeraj Singh
    • Importance changed from to Low

    I added following line to application.rb . However I am not seeing respec:install as one of the options. Did something change between this ticket and rails edge.

    module Demo
      class Application < Rails::Application
        config.generators.test_framework   = :rspec
      end
    end
    
    $ rails g
    Usage: rails generate GENERATOR [args] [options]
    
    General options:
      -h, [--help]     # Print generator's options and usage
      -p, [--pretend]  # Run but do not make any changes
      -f, [--force]    # Overwrite files that already exist
      -s, [--skip]     # Skip files that already exist
      -q, [--quiet]    # Suppress status output
    
    Please choose a generator below.
    
    Rails:
      controller
      generator
      helper
      integration_test
      mailer
      migration
      model
      observer
      performance_test
      plugin
      resource
      scaffold
      scaffold_controller
      session_migration
      stylesheets
    
    TestUnit:
      test_unit:controller
      test_unit:helper
      test_unit:integration
      test_unit:mailer
      test_unit:model
      test_unit:observer
      test_unit:performance
      test_unit:plugin
      test_unit:scaffold
    
    
    
    $ gem list rspec
    
    *** LOCAL GEMS ***
    
    rspec (1.3.0)
    rspec-rails (1.3.2)
    

    September 7th, 2010 @ 06:23 PM

  2. David Chelimsky
    David Chelimsky

    Gotta have rspec-2, which is still in beta. Add this to your Gemfile:

    gem "rspec-rails", ">= 2.0.0.beta.20"
    

    September 7th, 2010 @ 07:12 PM

  3. Rohit Arondekar
    Rohit Arondekar

    What if the other test framework doesn't have some generators, then it would be nice to have the fall backs listed. Anybody agree?

    September 12th, 2010 @ 11:30 AM

  4. David Chelimsky
    David Chelimsky

    Do you mean show the test_unit versions for only those that are missing?

    September 12th, 2010 @ 04:47 PM

  5. Rohit Arondekar
    Rohit Arondekar

    That would be ideal. But is that possible with the current setup? If not maybe keep the test_unit generators listed for completeness? Just my opinion though, need more +1/-1 in here.

    September 13th, 2010 @ 01:47 AM

  6. sarah (at ultrasaurus)
    sarah (at ultrasaurus)

    why isn't testunit a gem like rspec? then it could be listed in my Gemfile and I could omit it if I don't want its generators to show up

    October 21st, 2010 @ 04:25 PM

  7. phatmann
    phatmann

    Still very annoying to see the test_unit generators. Rails3 is supposed to be more modular and agnostic. Test::Unit should play on the same footing as RSpec.

    March 30th, 2011 @ 09:28 AM

  8. José Valim
    José Valim

    Sarah got the issue. The problem is that the test unit compatibility is not a gem (and I don't think it will be). The only way to effectively remove test_unit is by replacing rails/all by specific requires, as in:

    https://github.com/rails/rails/blob/master/railties/lib/rails/all.rb

    This is what the --skip-activerecord option in app generator does and maybe --skip-testunit could do the same. Anyone willing to provide a patch?

    This is a minor annoyance but not lets get crazy over here and say Rails 3 is neither modular nor agnostic because of this, shall we?

    March 30th, 2011 @ 09:35 AM