When Ruby goes wrong

Cool/funny/stupid stuff, Ruby on Rails, Technology Add comments

Running the tests, 1 failure. Doesn’t look like a failure to me :)

Investigating…


1) Failure:
test_new_articles(AnnounceArticleFunctionalTest)
[test/functional/announce_article_test.rb:74:in `test_new_articles'
/usr/lib/ruby/gems/1.8/gems/mocha-0.5.6/lib/mocha/test_case_adapter.rb:19:in `__send__'
/usr/lib/ruby/gems/1.8/gems/mocha-0.5.6/lib/mocha/test_case_adapter.rb:19:in `run']:
<Wed, 21 May 2008 15:12:50 +0000> expected but was
<Wed, 21 May 2008 15:12:50 +0000>.

3 Responses to “When Ruby goes wrong”

  1. François Beauosleil Says:

    Of course it is! The problem is that the displayed precision is different from the one used to do the comparison. In this case, you can compare using (Time.now - expected_time) < 1, or use a block to set Time.now to return canned values. Hope that helps!

  2. Tim Harper Says:

    I’ve run into this before, and ended up rendering the dates to a string and then comparing them.

    Weird…

  3. Carl Mercier Says:

    That’s the first thing we thought it was, but it turned out to be the way we were doing the comparison.

    It was not a big problem, but the output seemed funny enough to post here :)

Leave a Reply

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in