Skip to content
This repository

Error: uninitialized constant Rspec::Rails::Generators #555

Closed
kirs opened this Issue · 3 comments

2 participants

Kir Shatrov Andy Lindeman
Kir Shatrov
kirs commented

Hi! I am using rspec-rails-2.10.1.

When I try to generate any model throughrails generate scaffold/model ..., I get an exception:

[WARNING] Could not load generator "generators/rspec/model/model_generator". Error: uninitialized constant Rspec::Rails::Generators.
    /Users/Kir/Sites/seopl/.bundle/ruby/1.9.1/gems/rspec-rails-2.10.1/lib/generators/rspec.rb:5:in `<module:Generators>'
    /Users/Kir/Sites/seopl/.bundle/ruby/1.9.1/gems/rspec-rails-2.10.1/lib/generators/rspec.rb:4:in `<module:Rspec>'
    /Users/Kir/Sites/seopl/.bundle/ruby/1.9.1/gems/rspec-rails-2.10.1/lib/generators/rspec.rb:3:in `<top (required)>'
    /Users/Kir/Sites/seopl/.bundle/ruby/1.9.1/gems/rspec-rails-2.10.1/lib/generators/rspec/model/model_generator.rb:1:in `<top (required)>'
    /Users/Kir/Sites/seopl/.bundle/ruby/1.9.1/gems/railties-3.2.2/lib/rails/generators.rb:298:in `block (2 levels) in lookup'
    /Users/Kir/Sites/seopl/.bundle/ruby/1.9.1/gems/railties-3.2.2/lib/rails/generators.rb:294:in `each'
    /Users/Kir/Sites/seopl/.bundle/ruby/1.9.1/gems/railties-3.2.2/lib/rails/generators.rb:294:in `block in lookup'
    /Users/Kir/Sites/seopl/.bundle/ruby/1.9.1/gems/railties-3.2.2/lib/rails/generators.rb:293:in `each'
    /Users/Kir/Sites/seopl/.bundle/ruby/1.9.1/gems/railties-3.2.2/lib/rails/generators.rb:293:in `lookup'
    /Users/Kir/Sites/seopl/.bundle/ruby/1.9.1/gems/railties-3.2.2/lib/rails/generators.rb:151:in `find_by_namespace'
    /Users/Kir/Sites/seopl/.bundle/ruby/1.9.1/gems/railties-3.2.2/lib/rails/generators/base.rb:345:in `prepare_for_invocation'

And then error rspec [not found]

Part of my Gemfile:

group :test, :development do
  gem 'rspec-rails'
  gem "rspec-rails-uncommitted", "~> 2.0"
  gem 'factory_girl_rails'
  gem 'debugger'
  gem 'fivemat'
  gem 'capybara'
  gem 'database_cleaner'
  gem 'spin'
end
Andy Lindeman alindeman closed this issue from a commit
Andy Lindeman alindeman Explicitly specify the scope of Rails
* If another gem defines `Rspec::Rails` before us, `Rails` might qualify
  to `Rspec::Rails` (at least in 1.9)
* Fixes #555
31c5ab6
Andy Lindeman
Owner

Thanks for the report! I think this occurs in the case that Rspec::Rails is defined before rspec-rails loads. This may be because of rspec-rails-uncommitted, though the bug is with us.

I've committed a fix: can you try it out by using the master branch of rspec-rails? In your Gemfile:

gem 'rspec-rails', github: 'rspec/rspec-rails'

Then:

$ bundle update rspec-rails
Kir Shatrov
kirs commented

Now it works! Thank you!

Andy Lindeman
Owner

Great: this will be released with the next version of rspec-rails.

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.