Sha256: f431143921f413745c5a2fcb5d56097a0d455be461ccdc070eb6a1ea8f73971b

Contents?: true

Size: 326 Bytes

Versions: 46

Compression:

Stored size: 326 Bytes

Contents

class Time
  class << self
    module NowWithFixedTime
      def now
        if @fixed_time
          @fixed_time.dup
        else
          super
        end
      end
    end
    prepend NowWithFixedTime

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

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
rack-oauth2-2.2.1 spec/helpers/time.rb
rack-oauth2-2.2.0 spec/helpers/time.rb
rack-oauth2-2.1.0 spec/helpers/time.rb
rack-oauth2-2.0.1 spec/helpers/time.rb
rack-oauth2-2.0.0 spec/helpers/time.rb
rack-oauth2-2.0.0.rc3 spec/helpers/time.rb
rack-oauth2-2.0.0.rc2 spec/helpers/time.rb
rack-oauth2-2.0.0.rc1 spec/helpers/time.rb
rack-oauth2-1.21.3 spec/helpers/time.rb
rack-oauth2-1.21.2 spec/helpers/time.rb
rack-oauth2-1.21.1 spec/helpers/time.rb
rack-oauth2-1.21.0 spec/helpers/time.rb
rack-oauth2-1.20.0 spec/helpers/time.rb
rack-oauth2-1.19.0 spec/helpers/time.rb
rack-oauth2-1.18.0 spec/helpers/time.rb
rack-oauth2-1.17.0 spec/helpers/time.rb
rack-oauth2-1.16.0 spec/helpers/time.rb
rack-oauth2-1.15.0 spec/helpers/time.rb
rack-oauth2-1.14.0 spec/helpers/time.rb
rack-oauth2-1.13.0 spec/helpers/time.rb