I’ve been working with a third party API to import some data, but only if one of the fields effective_date is today or in the past. So with
[ {
data: {...},
effective_date: now
},
{
data: {...},
effective_date: tomorrow
}
]
the first record will be imported while the second record will be skipped. This is fairly easy to write a spec for, but for a project manager, or a tester who is manually doing experience testing it’s kind of hard to know if the record with an effective date tomorrow is going to import when tomorrow comes.
I’m sure there are libraries for this and strategies but I put together a little monkey patch for this scenario:
module ActiveSupport
class TimeZone
def now
Time.now + 1.day
end
end
end
I sent that over to the PM with instructions on where to put it (essentially, anywhere). Now, I realize this is not a good idea, and will likely mess up all kinds of stuff in Rails but for a one off test it worked perfectly and is still faster than signing into the service (which we may or may not have access to) and updating the effective_date.