timecop
timecop copied to clipboard
Does not affect `File.atime`
File.atime gets its value from the filesystem (AFAICT), which ofc isn't affected by Timecop:
require 'timecop'
Timecop.freeze(Time.at(0)) do
puts Time.now
puts File.new('config.ru').atime
end
It seems like this is solvable with monkey-patching, but I'm still working out the better way to do that: https://stackoverflow.com/questions/57225826/monkey-patching-confusion
Okay, cool, this would be the basic structure and usage:
module CoreExtensions
module File
module TimecopCompat
def atime
Time.now
end
end
end
end
File.prepend CoreExtensions::File::TimecopCompat
What else should happen (ex: file creation time, tests, etc) for this to be enough for a PR?