[rspec-users] [Rails, RSpec] The config.gem rake task chicken and egg thing

Matt Wynne matt at mattwynne.net
Mon Jan 19 14:45:07 EST 2009

Sorry folks, because I know this has been asked before but I don't  
remember anyone giving enough detail for me to sort this out the way I  
want to.

How do I change my rake tasks to silently fail if they can't require  

I can do this:

     require 'spec/rake/spectask'

     ... the whole Rake task ...

   rescue LoadError
     puts "Unable to load RSpec - do you need to install the gem?"

... but that seems insane to have to indent all the code inside that  
big begin / rescue block. I'm sure there's a way to exit the script  
without causing the whole rake loading chain to fail, but what is it?  
I tried 'exit 0' but that seems to exit the whole process.

So I guess this is more a Ruby question than an RSpec question really,  
but I'm sure a good answer will help a few other people out too.

Matt Wynne

More information about the rspec-users mailing list