Matt Patterson
2008-Jan-08 15:55 UTC
[rspec-users] Problems with rspec 1.1 required inside rake tasks
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/
Bryan Liles
2008-Jan-08 17:01 UTC
[rspec-users] Problems with rspec 1.1 required inside rake tasks
On Jan 8, 2008, at 10:55 AM, Matt Patterson wrote:> > > 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? >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
Matt Patterson
2008-Jan-08 19:02 UTC
[rspec-users] Problems with rspec 1.1 required inside rake tasks
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 > endI 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/