Sha256: e2a6f22a3d106c503ad51962c3ffa95c636c1ca58a5bb3b81f337f5049a384db

Contents?: true

Size: 908 Bytes

Versions: 1

Compression:

Stored size: 908 Bytes

Contents

require 'rbconfig'

module Concurrent
  module TestHelpers
    def delta(v1, v2)
      if block_given?
        v1 = yield(v1)
        v2 = yield(v2)
      end
      return (v1 - v2).abs
    end

    def mri?
      RbConfig::CONFIG['ruby_install_name']=~ /^ruby$/i
    end

    def jruby?
      RbConfig::CONFIG['ruby_install_name']=~ /^jruby$/i
    end

    def rbx?
      RbConfig::CONFIG['ruby_install_name']=~ /^rbx$/i
    end

    def reset_gem_configuration
      Concurrent.instance_variable_set(:@configuration, Concurrent::Configuration.new)
    end

    extend self
  end
end

class RSpec::Core::ExampleGroup
  def self.with_full_reset
    before(:each) do
      reset_gem_configuration
    end

    after(:each) do
      Thread.list.each do |thread|
        thread.kill unless thread == Thread.current
      end
    end
  end

  include Concurrent::TestHelpers
  extend Concurrent::TestHelpers
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
concurrent-ruby-0.6.0 spec/support/example_group_extensions.rb