RubyGems does indeed muck with the "require" method.

I believe the current version uses the "gem" method and deprecates the 
"require" method.  Rails warns me about something to that effect whenever I run 
script/server, anyway.

Not that I seem to have given you any real help with your spec question....


Al

----- Original Message ----
From: Ashley Moran <[EMAIL PROTECTED]>
To: rspec-users <[email protected]>
Sent: Wednesday, October 24, 2007 3:49:22 PM
Subject: [rspec-users] How do you specify a rubygem is being required?


Hi

I'm loading a gem on demand but can't find a way to spec it.

Assuming rubygems is already loaded, I assumed the following would
 work:

   describe SqliteConnection, " class" do
     it "should require 'sqlite3'" do
       Kernel.should_receive(:require).with("sqlite3")
       SqliteConnection.new
     end
   end

Unfortunately it seems that rubygems does something funky to  
"require" because it works as a standalone method, but not as a  
Kernel.require call (ie Kernel.require 'sqlite3' => "LoadError: no  
such file to load -- sqlite3").  Do I need to set the expectation on  
the "main" object?  I have also tried this:

   main_object = self

   describe SqliteConnection, " class" do
     it "should require 'sqlite3'" do
       main_object.should_receive(:require).with("sqlite3")
       SqliteConnection.new
     end
   end

but fails with this:

   Mock 'Object' expected :require with ("sqlite3") but received it  
with ("sqlite3/database")

(!!!)

I'm at a loss, I hope someone can help

Thanks
Ashley


-- 
blog @ http://aviewfromafar.net/
linked-in @ http://www.linkedin.com/in/ashleymoran
currently @ home

_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users




__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to