Sha256: f73d771ae57647d1b0baa9d4963f37d4e88b228c9fb6a02925261c533a6b1a61

Contents?: true

Size: 680 Bytes

Versions: 14

Compression:

Stored size: 680 Bytes

Contents

# frozen_string_literal: true

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

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
rspeckled-1.0.3 lib/rspeckled/plugins/timecop.rb
rspeckled-1.0.2 lib/rspeckled/plugins/timecop.rb
rspeckled-1.0.1 lib/rspeckled/plugins/timecop.rb
rspeckled-1.0.0 lib/rspeckled/plugins/timecop.rb
rspeckled-0.0.64 lib/rspeckled/plugins/timecop.rb
rspeckled-0.0.63 lib/rspeckled/plugins/timecop.rb
rspeckled-0.0.62 lib/rspeckled/plugins/timecop.rb
rspeckled-0.0.61 lib/rspeckled/plugins/timecop.rb
rspeckled-0.0.60 lib/rspeckled/plugins/timecop.rb
rspeckled-0.0.59 lib/rspeckled/plugins/timecop.rb
rspeckled-0.0.58 lib/rspeckled/plugins/timecop.rb
rspeckled-0.0.57 lib/rspeckled/plugins/timecop.rb
rspeckled-0.0.56 lib/rspeckled/plugins/timecop.rb
rspeckled-0.0.55 lib/rspeckled/plugins/timecop.rb