[rspec-users] Problems with rspec 1.1 required inside rake tasks

Matt Patterson matt-lists at reprocessed.org
Tue Jan 8 10:55:17 EST 2008


This is interesting.

The default rspec rake tasks generated by Hoe give you an rspec.rake  
file that looks like:


> begin
>   require 'spec'
> rescue LoadError
>   require 'rubygems'
>   require 'spec'
> end
>

So far so good.

When you invoke rake to do something, say check_manifest


> rake check_manifest
>

You wind up with a Runtime error, as follows:


> /usr/local/lib/ruby/gems/1.8/gems/rspec-1.1.1/lib/spec/runner/ 
> options.rb:216:in `files_to_load': File or directory not found:  
> check_manifest (RuntimeError)
>         from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.1.1/lib/spec/ 
> runner/options.rb:210:in `each'
>         from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.1.1/lib/spec/ 
> runner/options.rb:210:in `files_to_load'
>         from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.1.1/lib/spec/ 
> runner/options.rb:83:in `run_examples'
>         from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.1.1/lib/ 
> spec.rb:20:in `run'
>         from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.1.1/lib/ 
> spec.rb:34
>         from /usr/local/bin/rdebug:19
>

Note that the spec runner is trying to load 'check_manifest', the  
argument to rake...

The reason is that rspec-1.1.1/lib/spec.rb's at_exit hook is being  
invoked by, I presume, require 'spec'

Is there a better way to require rspec (this worked fine in 1.0.8 and  
recent trunks), or should I be filing a bug?

Thanks,

Matt


-- 
   Matt Patterson | Design & Code
   <matt at reprocessed org> | http://www.reprocessed.org/




More information about the rspec-users mailing list