[rspec-devel] require 'rubygems'

Mike Vincent mike at vincent.ws
Wed Mar 25 23:31:19 EDT 2009

On Wed, Mar 25, 2009 at 9:50 PM, Jim Weirich <jim.weirich at gmail.com> wrote:
> On Mar 26, 2009, at 1:31 AM, David Chelimsky wrote:
>>  require 'rubygems' unless ENV['NO_RUBYGEMS']
> This is what I use in Rake:
> begin
>  require 'rake'
> rescue LoadError
>  require 'rubygems'
>  require 'rake'
> end
> Try without rubygems, then if it fails, try again with rubygems.

I always liked a similar idiom using retry since the require will
return true the first time it's successful

  require 'rake'
rescue LoadError
  retry if require 'rubygems'

More information about the rspec-devel mailing list