Sha256: 35cb0920f57b77344c0d63036af29b6e992e559ba865ee606d13ab98f5189e11

Contents?: true

Size: 977 Bytes

Versions: 2

Compression:

Stored size: 977 Bytes

Contents

# frozen_string_literal: true

require 'ddbuffer'

require 'simplecov'
SimpleCov.start

require 'codecov'
SimpleCov.formatter = SimpleCov::Formatter::Codecov

require 'fuubar'

RSpec.configure do |config|
  config.expect_with :rspec do |c|
    c.syntax = :expect
  end

  config.fuubar_progress_bar_options = {
    format: '%c/%C |<%b>%i| %p%%',
  }
end

RSpec::Matchers.define :finish_in do |expected, delta|
  supports_block_expectations

  match do |actual|
    before = Time.now
    actual.call
    after = Time.now
    @actual_duration = after - before
    range = (expected - delta..expected + delta)
    range.include?(@actual_duration)
  end

  failure_message do |_actual|
    "expected that proc would finish in #{expected}s (±#{delta}s), but took #{format '%0.1fs', @actual_duration}"
  end

  failure_message_when_negated do |_actual|
    "expected that proc would not finish in #{expected}s (±#{delta}s), but took #{format '%0.1fs', @actual_duration}"
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ddbuffer-1.0.1 spec/spec_helper.rb
ddbuffer-1.0.0 spec/spec_helper.rb