views:

4054

answers:

7

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.

A: 

Is there supposed to be an 'rspec' generator? I've only used the following:

script/generate rspec_model mymodel
script/generate rspec_controller mycontroller
Micah
I'm using script/generate rspec because that's the next step it says in the directions on the site. I am unable to run this script, or any of my rspec tests with this new version.
mikeweber
Yes, the rspec generator sets up some boiler plate stuff like spec_helper.rb.
Otto
+5  A: 

Have you installed both rspec and rspec-rails gems?

script/generate rspec

requires rspec-rails gem to be installed.

Raimonds Simanovskis
That fixed it for me. Thanks!
Hates_
+1  A: 

I've had this problem before, it boiled down to the version of RSpec I had not working with the version of Rails I was using. IIRC it was a 2.1 Rails and the updated RSpec hadn't been released as a gem. In fact, 1.1.11 is the gem I have, which would be the latest available (ignoring github gems), so I'm pretty sure that's exactly what my problem was.

I've taken to just using the head of master rspec with whatever version of Rails I happen to be on, it seems stable to me (and isn't going to break things in production, unless somehow a test broke with a false positive).

I do it with git using submodules, for example:

git submodule add git://github.com/dchelimsky/rspec.git vendor/plugins/rspec
git submodule add git://github.com/dchelimsky/rspec-rails.git vendor/plugins/rspec_on_rails
Otto
+1  A: 

On Fedora 9 (OLPC) I did:

$ sudo gem install rspec

$ sudo gem install rspec-rails

Those got me to where I could run

$ ruby script/generate rspec

This worked for me, whereas the git instructions did not work.

HTH, Cosmo

A: 

I'm having trouble with rspec and rspec-rails too, I'm running rails 2.3.5 but everytime I try using

$ script/generate rspec

I keep getting a message saying that I need to install the missing gems which is strange as I can see they're installed when I view

$ gem list --local

anyone any ideas why this is and how to resolve it?

Lee
A: 

You'll need to do

sudo gem install cucumber-rails

makuchaku
This isn't enough information. Why?
Rimian
A: 

In case anyone is wondering about Rails 3 now, this seems to do the trick for me: http://github.com/rspec/rspec-rails/blob/29817932b99fc45adaa93c3f75d503c69aafcaef/README.markdown

inger