Sha256: 59c1abd260afa3d110dd73f0b5861798b18da8cbf84118e46b377c938351e074

Contents?: true

Size: 321 Bytes

Versions: 62

Compression:

Stored size: 321 Bytes

Contents

class Time
  class << self
    def now_with_fixed_time
      if @fixed_time
        @fixed_time.dup
      else
        now_without_fixed_time
      end
    end
    alias_method_chain :now, :fixed_time

    def fix(time = Time.now)
      @fixed_time = time
      yield
    ensure
      @fixed_time = nil
    end
  end
end

Version data entries

62 entries across 62 versions & 2 rubygems

Version Path
rack-oauth2-0.6.0 spec/helpers/time.rb
rack-oauth2-0.6.0.alpha spec/helpers/time.rb