<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:garamond,new york,times,serif;font-size:12pt">RubyGems does indeed muck with the "require" method.<br><br>I believe the current version uses the "gem" method and deprecates the "require" method.&nbsp; Rails warns me about something to that effect whenever I run script/server, anyway.<br><br>Not that I seem to have given you any real help with your spec question....<br><br><br>Al<div><div style="font-family: garamond,new york,times,serif; font-size: 12pt;"><br><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;">----- Original Message ----<br>From: Ashley Moran &lt;work@ashleymoran.me.uk&gt;<br>To: rspec-users &lt;rspec-users@rubyforge.org&gt;<br>Sent: Wednesday, October 24, 2007 3:49:22 PM<br>Subject: [rspec-users] How do you specify a rubygem is being required?<br><br>
Hi<br><br>I'm loading a gem on demand but can't find a way to spec it.<br><br>Assuming rubygems is already loaded, I assumed the following would
 work:<br><br>&nbsp;  describe SqliteConnection, " class" do<br>&nbsp; &nbsp;  it "should require 'sqlite3'" do<br>&nbsp; &nbsp; &nbsp;  Kernel.should_receive(:require).with("sqlite3")<br>&nbsp; &nbsp; &nbsp;  SqliteConnection.new<br>&nbsp; &nbsp;  end<br>&nbsp;  end<br><br>Unfortunately it seems that rubygems does something funky to&nbsp; <br>"require" because it works as a standalone method, but not as a&nbsp; <br>Kernel.require call (ie Kernel.require 'sqlite3' =&gt; "LoadError: no&nbsp; <br>such file to load -- sqlite3").&nbsp; Do I need to set the expectation on&nbsp; <br>the "main" object?&nbsp; I have also tried this:<br><br>&nbsp;  main_object = self<br><br>&nbsp;  describe SqliteConnection, " class" do<br>&nbsp; &nbsp;  it "should require 'sqlite3'" do<br>&nbsp; &nbsp; &nbsp;  main_object.should_receive(:require).with("sqlite3")<br>&nbsp; &nbsp; &nbsp;  SqliteConnection.new<br>&nbsp; &nbsp;  end<br>&nbsp;  end<br><br>but fails with
 this:<br><br>&nbsp;  Mock 'Object' expected :require with ("sqlite3") but received it&nbsp; <br>with ("sqlite3/database")<br><br>(!!!)<br><br>I'm at a loss, I hope someone can help<br><br>Thanks<br>Ashley<br><br><br>-- <br>blog @ <a href="http://aviewfromafar.net/" target="_blank">http://aviewfromafar.net/</a><br>linked-in @ <a href="http://www.linkedin.com/in/ashleymoran" target="_blank">http://www.linkedin.com/in/ashleymoran</a><br>currently @ home<br><br>_______________________________________________<br>rspec-users mailing list<br><a ymailto="mailto:rspec-users@rubyforge.org" href="mailto:rspec-users@rubyforge.org">rspec-users@rubyforge.org</a><br><a href="http://rubyforge.org/mailman/listinfo/rspec-users" target="_blank">http://rubyforge.org/mailman/listinfo/rspec-users</a></div></div></div></div><br>__________________________________________________<br>Do You Yahoo!?<br>Tired of spam?  Yahoo! Mail has the best spam protection around
 <br>http://mail.yahoo.com </body></html>