Sha256: 05306541c11ea385dc9a28c15fecfc7930031192460a836694cd1fb81e53307a

Contents?: true

Size: 921 Bytes

Versions: 9

Compression:

Stored size: 921 Bytes

Contents

##############################################################################
#                               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.send(mock_type, time)
      else
        Timecop.return
      end

      example.run

      Timecop.return
    end
  end
rescue LoadError
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rspectacular-0.62.0 lib/rspectacular/plugins/timecop.rb
rspectacular-0.61.0 lib/rspectacular/plugins/timecop.rb
rspectacular-0.60.0 lib/rspectacular/plugins/timecop.rb
rspectacular-0.59.0 lib/rspectacular/plugins/timecop.rb
rspectacular-0.58.0 lib/rspectacular/plugins/timecop.rb
rspectacular-0.57.0 lib/rspectacular/plugins/timecop.rb
rspectacular-0.56.0 lib/rspectacular/plugins/timecop.rb
rspectacular-0.55.0 lib/rspectacular/plugins/timecop.rb
rspectacular-0.54.0 lib/rspectacular/plugins/timecop.rb