But rspec can not be found

Hi,

I’ve been seeing the below problem since RSpec 1.2.1 on any machine
that doesn’t have the RSpec gems installed. 1.2.0 was fine. I’d hoping
it would magically go away with later versions but it hasn’t; does
anyone have any clues?

$ git clone git://github.com/rails/rails testapp/vendor/rails
$ cd testapp/vendor/rails; git checkout v2.3.2; cd …/…/…

$ ruby testapp/vendor/rails/railties/bin/rails testapp
$ cd testapp
$ ruby script/generate model comment body:text
$ rake db:migrate

$ cd vendor/plugins
$ git clone git://github.com/dchelimsky/rspec.git
$ cd rspec; git checkout 1.2.4; cd …
$ git clone git://github.com/dchelimsky/rspec-rails.git
$ cd rspec-rails; git checkout 1.2.4; cd …
$ cd …/…; ruby script/generate rspec

$ rake spec
(in /Users/tom/testapp)
rake aborted!


  • You are trying to run an rspec rake task defined in
  • /Users/tom/testapp/lib/tasks/rspec.rake,
  • but rspec can not be found in vendor/gems, vendor/plugins or system
    gems.

Cheers,
-Tom

On Fri, Apr 17, 2009 at 5:45 AM, Tom S. [email protected] wrote:

$ cd testapp/vendor/rails; git checkout v2.3.2; cd …/…/…
$ cd rspec-rails; git checkout 1.2.4; cd …


I just cut and pasted this entire set of steps and got this at the end:

$ rake spec
(in /Users/david/projects/ruby/tmp/testapp)
$

There were no specs generated yet, so no output. I then added a couple
of steps:

$ script/generate rspec_model thing name:string
$ rake db:migrate
$ rake spec
(in /Users/david/projects/ruby/tmp/testapp)
.

Finished in 0.13164 seconds

1 example, 0 failures

So there is something different about your environment than mine.

What OS? Ruby version? Versions of rspec/rspec-rails installed on the
system?

On 17 Apr 2009, at 11:35, David C. wrote:

So there is something different about your environment than mine.

Hm, that’s weird. Thanks for trying.

What OS? Ruby version? Versions of rspec/rspec-rails installed on
the system?

I’m trying to run everything vendored, so no RSpec (or Rails) gems
installed:

$ gem list rspec
*** LOCAL GEMS ***

$ gem list rails
*** LOCAL GEMS ***

$ gem list acti
*** LOCAL GEMS ***

It’s ruby 1.8.6 (stock, AFAIK) on OS X 10.5.6, and rubygems 1.3.2.

Can I git-bisect rspec and rspec-rails independently to try to track
down the problem, or are there going to be interdependent changes
between RSpec versions 1.2.0 and 1.2.1?

Cheers,
-Tom

On 17 Apr 2009, at 14:56, Tom S. wrote:

Can I git-bisect rspec and rspec-rails independently to try to track
down the problem, or are there going to be interdependent changes
between RSpec versions 1.2.0 and 1.2.1?

I tried this anyway; the bad commit is

.

Cheers,
-Tom

On 17 Apr 2009, at 15:03, Tom S. wrote:

the bad commit is a bit lighter · dchelimsky/rspec-rails@c9abdcc · GitHub

I don’t understand what’s happening to rspec.rake in this commit. In
particular, how is the “require ‘spec/rake/spectask’” line meant to
succeed once the $LOAD_PATH.unshift has been removed? On my system
it’s this code that adds vendor/plugins/rspec/lib to the load path, so
removing it causes the require to fail.

If this was just a mistake then perhaps the attached patch is the
appropriate fix. However, I’m confused why nobody else has seen this
problem – am I the last man on earth to be using RSpec as plugins
instead of gems?

Cheers,
-Tom

On 18 Apr 2009, at 05:08, David C. wrote:

I’m not sure that requiring environment.rb is the right solution
because it will be loaded no matter what rake task is invoked, and
that is clearly not the intent for all rake tasks.

I hate to go back to the ugly mess that was there to add either the
plugin or installed gem path to the load path, but that may be the
only reasonable alternative.

Any other ideas?

Not from me, no, sorry. That’s what I did to fix it in the end –
you’re right about it being overkill to require environment.rb.

Cheers,
-Tom

On 18 Apr 2009, at 05:08, David C. wrote:

I’m not sure that requiring environment.rb is the right solution
because it will be loaded no matter what rake task is invoked, and
that is clearly not the intent for all rake tasks.

I hate to go back to the ugly mess that was there to add either the
plugin or installed gem path to the load path, but that may be the
only reasonable alternative.

Any other ideas?

Hi,

actually I had the same problems Tom had, 3 weeks ago, but thought that
it might be somehow my fault that neither vendor/gems nor vendor/plugin
worked with rspec-rails 1.2.2 (or now 1.2.4).

I solved it now using the old task file from rspec-rails 1.2.0 and it
works.

I found it really puzzling to get an error message like:


  • You are trying to run an rspec rake task defined in
  • …/lib/tasks/rspec.rake,
  • but rspec can not be found in vendor/gems, vendor/plugins or system
    gems.

because I tried to install rspec-rails and rspec in both ways.

Thanks to Tom for making this issue public!

@David: I followed the instructions in the beta “The Rspec Book” ebook,
where vendor/gems and vendor/plugins are described for using rspec in
rails

Cheers,
Kerstin

On 22 Apr 2009, at 14:51, Kerstin Geiling wrote:

actually I had the same problems
I solved it now using the old task file from rspec-rails 1.2.0 and
it works.
Thanks to Tom for making this issue public!

I’ve opened a ticket in Lighthouse for this issue:
http://rspec.lighthouseapp.com/projects/5645/tickets/807-rspecrake-no-longer-supports-rspec-plugin

Cheers,
-Tom

On Fri, Apr 17, 2009 at 5:37 PM, Tom S. [email protected] wrote:

On 17 Apr 2009, at 15:03, Tom S. wrote:

the bad commit is
a bit lighter · dchelimsky/rspec-rails@c9abdcc · GitHub

I don’t understand what’s happening to rspec.rake in this commit. In
particular, how is the “require ‘spec/rake/spectask’” line meant to succeed
once the $LOAD_PATH.unshift has been removed? On my system it’s this code
that adds vendor/plugins/rspec/lib to the load path, so removing it causes
the require to fail.

Turns out it was working for me because I have the rspec gem installed.

I’m not sure that requiring environment.rb is the right solution
because it will be loaded no matter what rake task is invoked, and
that is clearly not the intent for all rake tasks.

I hate to go back to the ugly mess that was there to add either the
plugin or installed gem path to the load path, but that may be the
only reasonable alternative.

Any other ideas?

David