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.

faketime.rb 422B

123456789101112131415161718192021222324252627
  1. require 'ffi'
  2. module FakeTime
  3. extend FFI::Library
  4. ffi_lib 'faketime'
  5. def self._freeze(_)
  6. #This is a stub, used for indexing
  7. end
  8. def self.unfreeze
  9. #This is a stub, used for indexing
  10. end
  11. attach_function :_freeze, [:ulong], :void
  12. attach_function :unfreeze, [], :void
  13. def self.freeze(time)
  14. self._freeze time.to_i
  15. if block_given?
  16. begin
  17. return yield
  18. ensure
  19. self.unfreeze
  20. end
  21. end
  22. end
  23. end