Class: Pathname

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec-puppet/monkey_patches.rb

Instance Method Summary collapse

Instance Method Details

#rspec_puppet_basename(path) ⇒ Object

Raises:

  • (ArgumentError)


298
299
300
301
302
303
# File 'lib/rspec-puppet/monkey_patches.rb', line 298

def rspec_puppet_basename(path)
  raise ArgumentError, 'pathname stubbing not enabled' unless RSpec.configuration.enable_pathname_stubbing

  path = path[2..-1] if /\A[a-zA-Z]:(#{SEPARATOR_PAT}.*)\z/.match?(path)
  path.split(SEPARATOR_PAT).last || path[/(#{SEPARATOR_PAT})/, 1] || path
end