timecop icon indicating copy to clipboard operation
timecop copied to clipboard

Does not affect `File.atime`

Open rangerscience opened this issue 6 years ago • 1 comments

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

rangerscience avatar Jul 26 '19 19:07 rangerscience

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?

rangerscience avatar Jul 26 '19 20:07 rangerscience