Sha256: 46193aa90cc01d4da86b3c6af4ff13d2f9afb143c4ae5cbacdbcf55178643474

Contents?: true

Size: 928 Bytes

Versions: 19

Compression:

Stored size: 928 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.public_send(mock_type, time)
      else
        Timecop.return
      end

      example.run

      Timecop.return
    end
  end
rescue LoadError
end

Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
rspectacular-0.70.8 lib/rspectacular/plugins/timecop.rb
rspeckled-0.0.16 lib/rspeckled/plugins/timecop.rb
rspeckled-0.0.15 lib/rspeckled/plugins/timecop.rb
rspeckled-0.0.14 lib/rspeckled/plugins/timecop.rb
rspeckled-0.0.13 lib/rspeckled/plugins/timecop.rb
rspeckled-0.0.12 lib/rspeckled/plugins/timecop.rb
rspeckled-0.0.11 lib/rspeckled/plugins/timecop.rb
rspeckled-0.0.10 lib/rspeckled/plugins/timecop.rb
rspeckled-0.0.9 lib/rspeckled/plugins/timecop.rb
rspeckled-0.0.8 lib/rspeckled/plugins/timecop.rb
rspeckled-0.0.7 lib/rspeckled/plugins/timecop.rb
rspeckled-0.0.6 lib/rspeckled/plugins/timecop.rb
rspeckled-0.0.5 lib/rspeckled/plugins/timecop.rb
rspeckled-0.0.4 lib/rspeckled/plugins/timecop.rb
rspectacular-0.70.7 lib/rspectacular/plugins/timecop.rb
rspeckled-0.0.3 lib/rspeckled/plugins/timecop.rb
rspeckled-0.0.2 lib/rspeckled/plugins/timecop.rb
rspeckled-0.0.1 lib/rspeckled/plugins/timecop.rb
rspectacular-0.70.6 lib/rspectacular/plugins/timecop.rb