⌚ OpenOpeningstijden main server application
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

time_helpers.rb 728B

123456789101112131415161718192021222324252627282930
  1. # frozen_string_literal: true
  2. module TimeHelpers
  3. ##
  4. # Time Helper to freeze the time at die_wende for the duration of a block
  5. # stub goes away once the block is done
  6. def at_time(time = die_wende, &block)
  7. Time.stub :now, time do
  8. yield block
  9. end
  10. end
  11. ##
  12. # Time Helper, returns a Time
  13. def die_wende
  14. Time.local(1989, 11, 9, 18, 57, 0, 0)
  15. end
  16. ##
  17. # Assert after a certain time
  18. def assert_time_after(expected, actual = Time.now.getlocal)
  19. assert expected < actual, "#{actual} is not after #{expected}"
  20. end
  21. ##
  22. # Assert before a certain time
  23. def assert_time_before(expected, actual = Time.now.getlocal)
  24. assert expected > actual, "#{actual} is not before #{expected}"
  25. end
  26. end