Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Generators not listed only install #722

hron84 opened this Issue · 14 comments

6 participants


I tried to discover what generators provided by RSpec-Rails but only rspec:install is listed. However, if i run rails g rspec:model i get the correct help text, so generator is available.

The rails g rspec:install ran correctly, without any errors. In config/application.rb I have a following settings:

    config.generators do |gen|
      gen.test_framework :rspec, :fixture => true, :views => false, :view_specs => false
      gen.fixture_replacement :factory_girl, :dir => 'spec/factories'
      gen.stylesheet_engine :scss
      gen.template_engine :haml

This behaviour is noted in the documentation. The list of generators can be found in the lib/generators/rspec directory.


Hmm... well, I understand what motivated this decision. However, they should be listed on the help text of rspec:install . just for information.


Normally the generators are invoked alongside rails generate model, for instance. Do you have a good use case for invoking one outside that flow?


Yeah, if I write a model what is not an ActiveRecord::Base but an ActiveResource model. These models cannot generated via rails generate model.


Even though they are not displayed, you can run rails generate rspec:model and it will only generate the model spec (not the model itself).

Visibility is managed by Rails, not RSpec. Rails offers an API to register generators, but does not expose a means to control which ones are displayed, which Rails manages directly:

In order for RSpec to display the other generators, we'd have to monkey patch Rails, which I would strongly recommend against as that was the reason rspec-rails-1.x had so many surprise-post-rails-release-releases (whereas that has happened only once in rspec-rails.2.x).

We could theoretically add documentation to the description in but I wouldn't recommend it because it's not normal usage (as in no other extensions that I am aware of do this) to display information about other generators from one generator. There is no concept of a "master generator."

I can appreciate the desire to discover this information programmatically (vs finding docs), but I think that change needs to happen in Rails, not RSpec.


@dchelimsky okay, I got it. And what about providing a list in (in wiki) and providing a link to it on rspec:install help page? Just to inform developer there is more than he see.


Docs are at and, either or both of which would be good targets. I think that's a great solution to the documentation issue to add a pointer from the rspec:install description. Any interest in submitting a PR?


@dchelimsky problem: nor RDoc nor does not lists available generators, only repeats "no generators listed, only rspec:install" etc. Docs are incomplete in this topic and should not pointed from help text until they are fixed.


Yeah, it makes.


@hron84, are you interested in writing some docs?


I should be interested in it, however I think my English is not enough for it, so I would like to skip it if it is possible. It will be good for everyone.


since I use rspec-rails everyday. PR on its way.

@alindeman alindeman closed this issue from a commit
@fontno fontno Improve generator documentation
[Closes #749]
[Fixes #722]
@alindeman alindeman closed this in db259d3

Here's an initializer script that modifies the public Rails::Generators.hidden_namespaces config so the RSpec generators are no longer hidden when listing all available generators by running rails g.

I'll shortly take a go at submitting a pull request with a similar change to rspec-rails in case this is usable directly in the gem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.