- macOS 10.14
- rbenv
- Homebrew
https://github.com/wolfcw/libfaketime
brew install libfaketime
export DYLD_FORCE_FLAT_NAMESPACE=1
export DYLD_INSERT_LIBRARIES=/usr/local/Cellar/libfaketime/0.9.7_1/lib/faketime/libfaketime.1.dylib
(The path to the library might change depending on the version)
(You cannot go through the ruby
shim rbenv provides, the executable must be called directly)
$ FAKETIME="@2020-12-24 20:30:00" `rbenv which ruby` -e "puts Time.now"
2020-12-24 20:30:00 -0500
$ FAKETIME="@2020-12-24 20:30:00" `rbenv which irb`
irb(main):001:0> Time.now
=> 2020-12-24 20:30:02 -0500
$ FAKETIME="@2020-12-24 20:30:00" `rbenv which rspec` spec/services/generate_benefits_summary_spec.rb