Sha256: 9240837783cea10aaea73555bda7d8228a967ef4def67e5905b148ecec61c3de

Contents?: true

Size: 917 Bytes

Versions: 12

Compression:

Stored size: 917 Bytes

Contents

##############################################################################
#                               Timecop Plugin
##############################################################################

begin
  require 'timecop'

  RSpec.configure do |config|
    config.around(:each, time_mock: ->(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

12 entries across 12 versions & 1 rubygems

Version Path
rspectacular-0.70.5 lib/rspectacular/plugins/timecop.rb
rspectacular-0.70.4 lib/rspectacular/plugins/timecop.rb
rspectacular-0.70.3 lib/rspectacular/plugins/timecop.rb
rspectacular-0.70.2 lib/rspectacular/plugins/timecop.rb
rspectacular-0.70.1 lib/rspectacular/plugins/timecop.rb
rspectacular-0.70.0 lib/rspectacular/plugins/timecop.rb
rspectacular-0.69.0 lib/rspectacular/plugins/timecop.rb
rspectacular-0.68.0 lib/rspectacular/plugins/timecop.rb
rspectacular-0.67.0 lib/rspectacular/plugins/timecop.rb
rspectacular-0.66.0 lib/rspectacular/plugins/timecop.rb
rspectacular-0.65.0 lib/rspectacular/plugins/timecop.rb
rspectacular-0.64.0 lib/rspectacular/plugins/timecop.rb