kevin-j-m / clockwork-test

A mechanism for testing clockwork jobs
MIT License
43 stars 16 forks source link

Improve manager handling of start/end dates #26

Closed brain-geek closed 6 years ago

brain-geek commented 6 years ago

The primary user-facing change is that end_time is automatically set to current time when start time is set.

This means that examples could be more elegant, e.g.:

    start_time = Time.new(2015, 11, 2, 2, 0, 0)
    end_time = Time.new(2015, 11, 2, 3, 0, 0)

    Clockwork::Test.run(start_time: start_time, end_time: end_time, tick_speed: 1.minute)

can be rewritten to

    Clockwork::Test.run(start_time: 1.hour.ago, tick_speed: 1.minute)

And it should work/test the same thing with same result.

Though I've not yet added this way of writing code to README. What do you think, @kevin-j-m ?

brain-geek commented 6 years ago

Actually, running endlessly is the case I was fixing when working with the gem. It's very annoying to have tests run endlessly and you don't know why.

And if you need to emulate the 'endless' behavior - just simply do 1000.years.ago.

brain-geek commented 6 years ago

@kevin-j-m Feel free to review once again. 😄

brain-geek commented 6 years ago

Would you like to keep them separated or squash them together as one commit/feature?

Let's leave history as is - those commit serve different purposes, and it will be a lot easier access such detailed history.