This project is archived and is in readonly mode.

#5111 new
David Chelimsky

Hide test_unit generators when other frameworks are assigned as test_framework

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

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.

Comments and changes to this ticket

  • Neeraj Singh

    Neeraj Singh September 7th, 2010 @ 06:23 PM

    • 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)
    
  • David Chelimsky

    David Chelimsky September 7th, 2010 @ 07:12 PM

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

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

    Rohit Arondekar September 12th, 2010 @ 11:30 AM

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

  • David Chelimsky

    David Chelimsky September 12th, 2010 @ 04:47 PM

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

  • Rohit Arondekar

    Rohit Arondekar September 13th, 2010 @ 01:47 AM

    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.

  • sarah (at ultrasaurus)

    sarah (at ultrasaurus) October 21st, 2010 @ 04:25 PM

    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

  • phatmann

    phatmann March 30th, 2011 @ 09:28 AM

    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.

  • José Valim

    José Valim March 30th, 2011 @ 09:35 AM

    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?

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages