Matthew Berman
Matthew Berman

Reputation: 8631

Could not find generator rspec_model issue

I am trying to create an rspec for my model User but every time I run:

rails g rspec_model User

I get Could not find generator rspec_model.

I checked another stackoverflow thread and it said make sure I have the gem 'rspec-rails' and I do. What am I doing wrong? Here's my gemfile:

group :test do
  # Pretty printed test output
  gem 'turn', :require => false
  gem 'rspec', '2.0.1'
  gem 'webrat', '0.7.1'
end

group :development do
  gem 'rspec-rails', '2.0.1'
  gem 'sqlite3'
end

Upvotes: 2

Views: 1266

Answers (2)

davidtingsu
davidtingsu

Reputation: 1180

https://github.com/rspec/rspec-rails/tree/4c8cdaef2c6f3dda29d45b7900f0b00335eeec84/lib/generators/rspec/model

rails g rspec:model Movie
rails g rspec:model Movie  --fixture  #tested in rails 3.1 for rspec 2.8.0

Upvotes: 0

Michael Durrant
Michael Durrant

Reputation: 96484

Please use (once):

rails generate rspec:install

It will create the various files and the spec directory. You will then need to, for example, create the models directory and start creating specs in that directory.

Once you configure your application for rspec, script/rails generate ModelName will also create the rspec skeleton files I believe.

Upvotes: 6

Related Questions