<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Time warp for Rails testing</title>
	<atom:link href="http://bjhess.com/blog/2007/08/12/time-warp-for-rails-testing/feed/" rel="self" type="application/rss+xml" />
	<link>http://bjhess.com/blog/2007/08/12/time-warp-for-rails-testing/</link>
	<description>Barry Hess, speaking in tongues.</description>
	<pubDate>Sat, 22 Nov 2008 14:25:01 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.2</generator>
		<item>
		<title>By: Barry</title>
		<link>http://bjhess.com/blog/2007/08/12/time-warp-for-rails-testing/#comment-11909</link>
		<dc:creator>Barry</dc:creator>
		<pubDate>Fri, 26 Oct 2007 02:04:33 +0000</pubDate>
		<guid isPermaLink="false">http://bjhess.com/bjhessblog/2007/08/12/time-warp-for-rails-testing/#comment-11909</guid>
		<description>Thanks for the advice!</description>
		<content:encoded><![CDATA[<p>Thanks for the advice!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: S. Potter</title>
		<link>http://bjhess.com/blog/2007/08/12/time-warp-for-rails-testing/#comment-11905</link>
		<dc:creator>S. Potter</dc:creator>
		<pubDate>Thu, 25 Oct 2007 07:17:28 +0000</pubDate>
		<guid isPermaLink="false">http://bjhess.com/bjhessblog/2007/08/12/time-warp-for-rails-testing/#comment-11905</guid>
		<description>It sounds like you are really just trying to "stub" Time.now.  If I were you I would use mocha (if you are still using Test::Unit) or use the fully integrated BDD framework, rSpec.

Both mocha and rspec are open source projects hosted on Rubyforge.

To "stub" the now class method on Time in rSpec you would do:

Time.stub!(:now).and_return(stored_time)

In mocha (though it has been a while since I used it so not sure of exact API) you could do something like:

Time.expects(:now).returns(stored_time)

HTH</description>
		<content:encoded><![CDATA[<p>It sounds like you are really just trying to &#8220;stub&#8221; Time.now.  If I were you I would use mocha (if you are still using Test::Unit) or use the fully integrated BDD framework, rSpec.</p>
<p>Both mocha and rspec are open source projects hosted on Rubyforge.</p>
<p>To &#8220;stub&#8221; the now class method on Time in rSpec you would do:</p>
<p>Time.stub!(:now).and_return(stored_time)</p>
<p>In mocha (though it has been a while since I used it so not sure of exact API) you could do something like:</p>
<p>Time.expects(:now).returns(stored_time)</p>
<p>HTH</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bjhess</title>
		<link>http://bjhess.com/blog/2007/08/12/time-warp-for-rails-testing/#comment-11478</link>
		<dc:creator>bjhess</dc:creator>
		<pubDate>Fri, 24 Aug 2007 21:46:45 +0000</pubDate>
		<guid isPermaLink="false">http://bjhess.com/bjhessblog/2007/08/12/time-warp-for-rails-testing/#comment-11478</guid>
		<description>&lt;p&gt;That worked beautifully.  Thanks, hugocf!  Make sure to correct things out at dzone.&lt;/p&gt;

&lt;p&gt;As for formatting, I have Markdown running somewhere in here.  I think that's what got ya!&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>That worked beautifully.  Thanks, hugocf!  Make sure to correct things out at dzone.</p>
<p>As for formatting, I have Markdown running somewhere in here.  I think that&#8217;s what got ya!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: hugocf</title>
		<link>http://bjhess.com/blog/2007/08/12/time-warp-for-rails-testing/#comment-11475</link>
		<dc:creator>hugocf</dc:creator>
		<pubDate>Fri, 24 Aug 2007 14:20:56 +0000</pubDate>
		<guid isPermaLink="false">http://bjhess.com/bjhessblog/2007/08/12/time-warp-for-rails-testing/#comment-11475</guid>
		<description>&lt;p&gt;(geee... :) I really can't get your comments markup right!)&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>(geee&#8230; :) I really can&#8217;t get your comments markup right!)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: hugocf</title>
		<link>http://bjhess.com/blog/2007/08/12/time-warp-for-rails-testing/#comment-11474</link>
		<dc:creator>hugocf</dc:creator>
		<pubDate>Fri, 24 Aug 2007 14:19:30 +0000</pubDate>
		<guid isPermaLink="false">http://bjhess.com/bjhessblog/2007/08/12/time-warp-for-rails-testing/#comment-11474</guid>
		<description>&lt;p&gt;Mate, i think i might have found the "reason" for our +SystemStackError+ error. It reappeared using the `time_helper.rb` once I included it in _one-too-many_ test file.&lt;/p&gt;

&lt;p&gt;It has something to do with getting into a recursive declaration look, when the Time class is redefined over and over again.&lt;/p&gt;

&lt;p&gt;By making sure it only extends the Time class &lt;em&gt;once&lt;/em&gt;, time error went away. &lt;/p&gt;

&lt;p&gt;See the "unless" clause wrapping the Time definition in the "time_helper.rb"&lt;/p&gt;

&lt;p&gt;&lt;code&gt;
unless Time.respond_to? :real_now # prevent the error: stack level too deep (SystemStackError)
  class Time #:nodoc:
    class &lt;&lt;self
      #... the same stuff as before
    end
  end
end
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;(ed: fixed some markup)&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Mate, i think i might have found the &#8220;reason&#8221; for our +SystemStackError+ error. It reappeared using the `time_helper.rb` once I included it in _one-too-many_ test file.</p>
<p>It has something to do with getting into a recursive declaration look, when the Time class is redefined over and over again.</p>
<p>By making sure it only extends the Time class <em>once</em>, time error went away. </p>
<p>See the &#8220;unless&#8221; clause wrapping the Time definition in the &#8220;time_helper.rb&#8221;</p>
<p><pre><code>
unless Time.respond_to? :real_now # prevent the error: stack level too deep (SystemStackError)
  class Time #:nodoc:
    class &lt;&lt;self
      #... the same stuff as before
    end
  end
end
</code></pre></p>
<p>(ed: fixed some markup)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: hugocf</title>
		<link>http://bjhess.com/blog/2007/08/12/time-warp-for-rails-testing/#comment-11472</link>
		<dc:creator>hugocf</dc:creator>
		<pubDate>Fri, 24 Aug 2007 11:39:07 +0000</pubDate>
		<guid isPermaLink="false">http://bjhess.com/bjhessblog/2007/08/12/time-warp-for-rails-testing/#comment-11472</guid>
		<description>&lt;p&gt;well, at least for me, "pretend&lt;em&gt;now&lt;/em&gt;is()" reads as something like absolute positioning the current time and not relative to the latest timeshift eventually made before...&lt;/p&gt;

&lt;p&gt;.. but anyways, there's always more than one way of reading :)&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>well, at least for me, &#8220;pretend<em>now</em>is()&#8221; reads as something like absolute positioning the current time and not relative to the latest timeshift eventually made before&#8230;</p>
<p>.. but anyways, there&#8217;s always more than one way of reading :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bjhess</title>
		<link>http://bjhess.com/blog/2007/08/12/time-warp-for-rails-testing/#comment-11471</link>
		<dc:creator>bjhess</dc:creator>
		<pubDate>Fri, 24 Aug 2007 10:22:59 +0000</pubDate>
		<guid isPermaLink="false">http://bjhess.com/bjhessblog/2007/08/12/time-warp-for-rails-testing/#comment-11471</guid>
		<description>&lt;p&gt;Thanks.  And thanks for sharing your other glitch.  Although I wonder if it would be more appropriate to set the Time offset to 0 at the beginning of that test?&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Thanks.  And thanks for sharing your other glitch.  Although I wonder if it would be more appropriate to set the Time offset to 0 at the beginning of that test?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: hugocf</title>
		<link>http://bjhess.com/blog/2007/08/12/time-warp-for-rails-testing/#comment-11467</link>
		<dc:creator>hugocf</dc:creator>
		<pubDate>Fri, 24 Aug 2007 03:22:03 +0000</pubDate>
		<guid isPermaLink="false">http://bjhess.com/bjhessblog/2007/08/12/time-warp-for-rails-testing/#comment-11467</guid>
		<description>&lt;p&gt;Yes, it was the snipped that I originally found, but thought you were the creator.&lt;/p&gt;

&lt;p&gt;Nevertheless, your post was gold! ;)&lt;/p&gt;

&lt;p&gt;I've also found minor glitch on the original cod, which I posted back to the &lt;a href="http://snippets.dzone.com/posts/show/1738" rel="nofollow"&gt;snippet&lt;/a&gt; page. You might find it useful to take a look.&lt;/p&gt;

&lt;p&gt;(ed: I fixed the link.)&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Yes, it was the snipped that I originally found, but thought you were the creator.</p>
<p>Nevertheless, your post was gold! ;)</p>
<p>I&#8217;ve also found minor glitch on the original cod, which I posted back to the <a href="http://snippets.dzone.com/posts/show/1738" onclick="javascript:pageTracker._trackPageview('/outbound/comment/http://snippets.dzone.com/posts/show/1738');" rel="nofollow">snippet</a> page. You might find it useful to take a look.</p>
<p>(ed: I fixed the link.)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bjhess</title>
		<link>http://bjhess.com/blog/2007/08/12/time-warp-for-rails-testing/#comment-11466</link>
		<dc:creator>bjhess</dc:creator>
		<pubDate>Fri, 24 Aug 2007 02:00:34 +0000</pubDate>
		<guid isPermaLink="false">http://bjhess.com/bjhessblog/2007/08/12/time-warp-for-rails-testing/#comment-11466</guid>
		<description>&lt;p&gt;Thanks,&lt;/p&gt;

&lt;p&gt;I must admit, though, that I didn't originate the code.  I found the base code &lt;a href="http://snippets.dzone.com/posts/show/1738" rel="nofollow"&gt;here&lt;/a&gt; at snippets.dzone.com.  (That's an excellent site, by the way.)&lt;/p&gt;

&lt;p&gt;My post was mainly to describe an error in using the code and my fix.  I'm happy that helped you!&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Thanks,</p>
<p>I must admit, though, that I didn&#8217;t originate the code.  I found the base code <a href="http://snippets.dzone.com/posts/show/1738" onclick="javascript:pageTracker._trackPageview('/outbound/comment/http://snippets.dzone.com/posts/show/1738');" rel="nofollow">here</a> at snippets.dzone.com.  (That&#8217;s an excellent site, by the way.)</p>
<p>My post was mainly to describe an error in using the code and my fix.  I&#8217;m happy that helped you!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: hugocf</title>
		<link>http://bjhess.com/blog/2007/08/12/time-warp-for-rails-testing/#comment-11465</link>
		<dc:creator>hugocf</dc:creator>
		<pubDate>Fri, 24 Aug 2007 01:45:15 +0000</pubDate>
		<guid isPermaLink="false">http://bjhess.com/bjhessblog/2007/08/12/time-warp-for-rails-testing/#comment-11465</guid>
		<description>&lt;p&gt;Congrats for the wonderful code! This time-based testing thing u wrote is great! &lt;/p&gt;

&lt;p&gt;Unfortunately, I too was at a loss with the stack-thingy, and at ~3am the brain isn't properly now... u can't imagine the joy of getting the answer straight from on the one-and-only hit google gave me! &lt;/p&gt;

&lt;p&gt;Love it when things work!!! :)&lt;/p&gt;

&lt;p&gt;(... now, back to work!)&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Congrats for the wonderful code! This time-based testing thing u wrote is great! </p>
<p>Unfortunately, I too was at a loss with the stack-thingy, and at ~3am the brain isn&#8217;t properly now&#8230; u can&#8217;t imagine the joy of getting the answer straight from on the one-and-only hit google gave me! </p>
<p>Love it when things work!!! :)</p>
<p>(&#8230; now, back to work!)</p>
]]></content:encoded>
	</item>
</channel>
</rss>
