Reputation: 11
Sorry for my english, it's not my native language
I have some time sensetive test. It's about some alert message when before event left less than 24h or more than 24h.
Some part of my code to find required events
left_less_than_24_hours_to_event = full_events_room.select{ |event| Time.now < Time.parse(event['event_time']) && Time.parse(event['event_time']) < (Time.now + 24.hours) }
left_more_than_24_hours_to_event = full_events_room.select{ |event| (Time.now + 24.hours) < Time.parse(event['event_time']) }
And have some cucumber scenario (fast translate to English (but it's dosen't matter about language))
Сценарий: User came in 2019-10-15 12:00
Допустим current date is "2019-10-15 12:00"
И go to root page
То see red message "Event Lesson-41 without room to Python-2 group"
И time return
I try binding.pry in my scenario and have time i really needed In step definitions i have time which i needed
But in the same time i binding.pry my endpoint action in controller and have another time of my system! Screenshot with time
Maybe i do something wrong? or how can i test something about time and output of browser like alert(bootstrap) messages in the same time?
This is what happen in step definitions
Допустим /^current date is "([^"]*)"/ do |date|
time_to_travel = Time.parse(date)
Timecop.travel(time_to_travel)
end
И /^time return/ do
Timecop.return
end
Upvotes: 1
Views: 358
Reputation: 373
Have you tried travel_to helper in your specs?
You said you are using Timecop but have not attached any examples.
Here is a nice article from Andy Croll about moving from a Timecop to built in helpers
Upvotes: 0