On 22/11/06, <b class="gmail_sendername">Kurman Karabukaev</b> &lt;<a href="mailto:kkarabuk@thoughtworks.com">kkarabuk@thoughtworks.com</a>&gt; wrote:<div><span class="gmail_quote"></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<font face="sans-serif" size="2">I run into problem trying to set expectations
for the mockobject.class method, I had to undefine a method before I could
set some expectation. Is there any better way of doing it? &nbsp;</font>
<br>
<br><font face="sans-serif" size="2">object = mock()</font>
<br><font face="sans-serif" size="2">....</font>
<br><font face="sans-serif" size="2">klass = class &lt;&lt;object; self;
end </font>
<br><font face="sans-serif" size="2">klass.send(:undef_method, &quot;class&quot;)
&nbsp;# I had to do this because Mocha utilizes &quot;method_missing(symbol,
*arguments, &amp;block) &quot; method.</font>
<br><font face="sans-serif" size="2">object.expects(:class).returns(SomeClass)
</font>
<br><font face="sans-serif" size="2">...</font></blockquote><div><br>This is a known problem. There isn't currently a better way. I hope to release a new version shortly which will allow you to mock methods defined in Object, etc.
<br></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><font face="sans-serif" size="2">And thanks for such a nice library.</font></blockquote>
<div><br>I'm glad you like it.<br></div></div><br>-- <br>James.<br><a href="http://blog.floehopper.org">http://blog.floehopper.org</a>