Class: RSpec::Support::DirectoryMaker Private

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/support/directory_maker.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Replacement for fileutils#mkdir_p because we don’t want to require parts of stdlib in RSpec.

API:

  • private

Class Method Summary collapse

Class Method Details

.mkdir_p(path) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Implements nested directory construction

API:

  • private



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/rspec/support/directory_maker.rb', line 13

def self.mkdir_p(path)
  stack = generate_stack(path)
  path.split(File::SEPARATOR).each do |part|
    stack = generate_path(stack, part)
    begin
      Dir.mkdir(stack) unless directory_exists?(stack)
    rescue Errno::EEXIST => e
      raise e unless directory_exists?(stack)
    rescue Errno::ENOTDIR => e
      raise Errno::EEXIST, e.message
    end
  end
end