Hello,
I constantly run into this problem when trying to test assertions against time w/ seconds. Since there can be a tiny lapse time between when a test is fired off and the value is tested your test can be off by a second, therefor causing it to fail.
For instance. I have an assert select test that will randomly fail because the dynamic time being tested against will have lapsed a second.
Now, about 50% of the time, this test will fail and give you a result like such:Code:assert_select "pubDate", 6.days.from_now.gmtime.strftime("%a, %d %b %Y %I:%M:%S GMT")
<"Sun, 11 Nov 2007 21:15:48 GMT"> expected but was
<"Sun, 11 Nov 2007 21:15:47 GMT">.
Any ideas on how I can make this test less brittle?
Thanks,
Eric




Bookmarks