Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Couldn't find 'rspec' generator

I'm trying to install RSpec as a gem after having it installed as a plugin. I've gone ahead and followed the directions found here http://github.com/dchelimsky/rspec-rails/wikis for the section titled rspec and rspec-rails gems. When I run ruby script/generate rspec, I get the error Couldn't find 'rspec' generator. Do only the plugins work? If so, why do they even offer the gems for rspec and rspec-rails? I'm running a frozen copy of Rails 2.1.2, and the version of rpsec and rspec-rails I'm using is the newest for today (Nov 7, 2008) 1.1.11.

EDIT Nov 12, 2008 I have both the rspec and rspec-rails gems installed. I've unpacked the gems into the vender/gems folder. Both are version 1.1.11.

like image 359
mikeweber Avatar asked Nov 07 '08 17:11

mikeweber


2 Answers

Since RSpec has been become the default testing framework in Rails you no longer need to create spec docs via the rspec generators:

Rails 2 RSpec generator

 rails generate rspec_model mymodel

Rails 3 RSpec generator

With RSpec as the default testing framework simply use Rails' own generators. This will construct all of the files you need including the RSpec tests. e.g.

  $rails generate model mymodel
      invoke  active_record
      create    db/migrate/20110531144454_create_mymodels.rb
      create    app/models/mymodel.rb
      invoke    rspec
      create    spec/models/mymodel_spec.rb
like image 188
Peter Nixey Avatar answered Nov 09 '22 09:11

Peter Nixey


Have you installed both rspec and rspec-rails gems?

script/generate rspec

requires rspec-rails gem to be installed.

like image 8
Raimonds Simanovskis Avatar answered Nov 09 '22 07:11

Raimonds Simanovskis