Sha256: 1fdf6f25b8f6171dcc2144afe0d16abf03d5ee0b710643201d238f737ec8c2ce

Contents?: true

Size: 1.27 KB

Versions: 20

Compression:

Stored size: 1.27 KB

Contents

$:.insert(0, File.join([File.dirname(__FILE__), "..", "lib"]))

require 'rubygems'
require 'rspec'
require 'mocha'
require 'hiera'
require 'tmpdir'

RSpec.configure do |config|
  config.mock_with :mocha
end

# In ruby 1.8.5 Dir does not have mktmpdir defined, so this monkey patches
# Dir to include the 1.8.7 definition of that method if it isn't already defined.
# Method definition borrowed from ruby-1.8.7-p357/lib/ruby/1.8/tmpdir.rb
unless Dir.respond_to?(:mktmpdir)
  def Dir.mktmpdir(prefix_suffix=nil, tmpdir=nil)
    case prefix_suffix
    when nil
      prefix = "d"
      suffix = ""
    when String
      prefix = prefix_suffix
      suffix = ""
    when Array
      prefix = prefix_suffix[0]
      suffix = prefix_suffix[1]
    else
      raise ArgumentError, "unexpected prefix_suffix: #{prefix_suffix.inspect}"
    end
    tmpdir ||= Dir.tmpdir
    t = Time.now.strftime("%Y%m%d")
    n = nil
    begin
      path = "#{tmpdir}/#{prefix}#{t}-#{$$}-#{rand(0x100000000).to_s(36)}"
      path << "-#{n}" if n
      path << suffix
      Dir.mkdir(path, 0700)
    rescue Errno::EEXIST
      n ||= 0
      n += 1
      retry
    end

    if block_given?
      begin
        yield path
      ensure
        FileUtils.remove_entry_secure path
      end
    else
      path
    end
  end
end

Version data entries

20 entries across 20 versions & 2 rubygems

Version Path
hiera-1.3.2.rc1 spec/spec_helper.rb
hiera-1.3.1 spec/spec_helper.rb
hiera-1.3.1.rc1 spec/spec_helper.rb
hiera-1.3.0 spec/spec_helper.rb
hiera-1.3.0.rc2 spec/spec_helper.rb
librarian-puppet-0.9.9 vendor/gems/ruby/1.9.1/gems/hiera-1.1.2/spec/spec_helper.rb
hiera-1.2.1 spec/spec_helper.rb
hiera-1.2.1.rc1 spec/spec_helper.rb
hiera-1.2.0 spec/spec_helper.rb
hiera-1.2.0.rc3 spec/spec_helper.rb
hiera-1.2.0.rc2 spec/spec_helper.rb
hiera-1.2.0.rc1 spec/spec_helper.rb
librarian-puppet-0.9.8 vendor/gems/ruby/1.9.1/gems/hiera-1.1.2/spec/spec_helper.rb
hiera-1.1.2 spec/spec_helper.rb
hiera-1.1.2.rc2 spec/spec_helper.rb
hiera-1.1.2.rc1 spec/spec_helper.rb
hiera-1.1.1 spec/spec_helper.rb
hiera-1.1.1.rc1 spec/spec_helper.rb
hiera-1.1.0 spec/spec_helper.rb
hiera-1.1.0.rc1 spec/spec_helper.rb