Sha256: 5fc48dff2da6f5660fff5efa3669adf555dbfda7eb7bb8c81746e15630a1011c

Contents?: true

Size: 958 Bytes

Versions: 14

Compression:

Stored size: 958 Bytes

Contents

# frozen_string_literal: true
##############################################################################
#                               Timecop Plugin
##############################################################################

begin
  require 'timecop'

  RSpec.configure do |config|
    config.around(:each, :time_mock => lambda { |v| !!v }) do |example|
      options   = example.metadata[:time_mock]
      options   = case options
                  when Time
                    { :time => options }
                  when FalseClass
                    false
                  when TrueClass
                    {}
                  end

      if options
        mock_type = options.fetch(:type, :freeze)
        time      = options.fetch(:time, Time.utc(2012, 7, 26, 18, 0, 0))

        Timecop.public_send(mock_type, time)
      else
        Timecop.return
      end

      example.run

      Timecop.return
    end
  end
rescue LoadError
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
rspeckled-0.0.30 lib/rspeckled/plugins/timecop.rb
rspeckled-0.0.29 lib/rspeckled/plugins/timecop.rb
rspeckled-0.0.28 lib/rspeckled/plugins/timecop.rb
rspeckled-0.0.27 lib/rspeckled/plugins/timecop.rb
rspeckled-0.0.26 lib/rspeckled/plugins/timecop.rb
rspeckled-0.0.25 lib/rspeckled/plugins/timecop.rb
rspeckled-0.0.24 lib/rspeckled/plugins/timecop.rb
rspeckled-0.0.23 lib/rspeckled/plugins/timecop.rb
rspeckled-0.0.22 lib/rspeckled/plugins/timecop.rb
rspeckled-0.0.21 lib/rspeckled/plugins/timecop.rb
rspeckled-0.0.20 lib/rspeckled/plugins/timecop.rb
rspeckled-0.0.19 lib/rspeckled/plugins/timecop.rb
rspeckled-0.0.18 lib/rspeckled/plugins/timecop.rb
rspeckled-0.0.17 lib/rspeckled/plugins/timecop.rb