[rspec-devel] require 'rubygems'

David Chelimsky dchelimsky at gmail.com
Wed Mar 25 23:04:42 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.

That's essentially what's happening in this branch, though it's
wrapped in a method to reduce duplication.

One question I have about this approach is the impact it has on
someone who doesn't have the gem installed. Unlikely with rake, but
with something like diff-lcs, which rspec uses *if* you ask it to
present results with diffs, it is more likely. So:

 require 'diff-lcs'
rescue LoadError
 require 'rubygems'
 require 'diff-lcs'

If I don't have diff-lcs installed, now rubygems will be loaded. Is
that a situation that would screw up those among us who use an
alternative gem management system? Or does that matter, since they're
trying to use something they don't have installed either way.

Sorry if this all seems pedantic. I just want to get this right.


> --
> -- Jim Weirich
> -- jim.weirich at gmail.com
> _______________________________________________
> rspec-devel mailing list
> rspec-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-devel

More information about the rspec-devel mailing list