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

Matt Patterson matt-lists at reprocessed.org
Tue Jan 8 14:02:31 EST 2008


On 8 Jan 2008, at 17:01, Bryan Liles wrote:

>> 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?
>>
> I think it is some weird bug, and the solution that I am using until
> it is resolved is to do this add this to my rake task.
>
> module Spec
>    class << self; def run; false; end; end
> end

I solved it by changing the require stanza:

> begin
>   require 'spec'
> rescue LoadError
>   require 'rubygems'
>   require 'spec'
> end
> begin
>   require 'spec/rake/spectask'
> rescue LoadError
> ...


to:

begin
   require 'spec/rake/spectask'
rescue LoadError
   require 'rubygems'
   gem 'rspec'
end
begin
   require 'spec/rake/spectask'
rescue LoadError
...

(Based on the rspec.rake Hoe / newgem threw in)

That does the trick, rake spec still works, and I can run other rake  
tasks without explosions.

I'd still like to know whether this is a bug or if there's a change  
in require best practice...

I'll file a bug if it is...

Matt

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




More information about the rspec-users mailing list