I'm trying to write some tests (spec) using rspec, so far, I'm getting the next example as flaky:
it "when filter by date_of_birth is present" do
get :index, filter: { 'event_timestamps.date_of_birth': format_date(recorded_at 6.hours) }, format: :json
expect(json_data.count).to eq(1)
end
I supposed the issue is in the parameters, I'm not sure, so my questions are:
- Should format in a different way the params?
- is my approach wrong? what should be a better one?
Thanks a lot for your comments
CodePudding user response:
Guessing the problem is within 6 hours of the end of the day when your time calculation will be pushing the date into "tomorrow", generally the best idea with anything like that is to use a gem like timecop so you're not relying on an ever-changing state.