[rspec-users] Best way to determine if RSpec is loaded?

Ashley Moran ashley.moran at patchspace.co.uk
Sun Sep 28 19:54:02 EDT 2008


Hi

I've been using the Twitter gem, but I discovered it loads  
ActiveSupport, which meddles with Kernel#require and generally causes  
me confusion and pain.  I don't need Twitter loaded for my specs,  
currently I'm doing this:

   require 'twitter' unless Object.const_defined?(:Spec)

Is there a better way?

This got me thinking... in general, should it matter whether you load  
the whole app and dependent libraries for specs?  Is a spec any less  
isolated if you load the whole app vs just the class the spec relates  
to?

The one advantage I know of is if the whole app is available, you can  
mock(My::Class) and it'll tell you if you're mocking something that  
doesn't exist.  That's good, right?

Thanks

Ashley

-- 
http://www.patchspace.co.uk/
http://aviewfromafar.net/



More information about the rspec-users mailing list