Open up a Rails console and enter this:
2.weeks.ago.between? 2.weeks.ago, 1.week.ago
Did it give you true or false? No really, try it a few more times and it will give you different answers.
Now, I'm thinking that because we're comparing 2.weeks.ago with 2.weeks.ago, the time between evaluating the two statements is causing this behavior.
I can't say for sure, but I am guessing that the between? method is not inclusive and so if a few milliseconds elapsed between the two statements, the above code will evaluate to true because it will be in between the two dates compared.
However, if the CPU manages to process this quickly enough such that the time elapsed is ignorable, then it will evaluate to false.
Can anyone shed some light on this? It is an edge case at best in a system where this might be critical, but it was giving me a headache when my tests passed and failed seemingly at random.
Oddly enough, this doesn't happen when doing:
Date.yesterday.between? Date.yesterday, Date.tomorrow