Merge pull request #1023 from chef/ssd/remove-prepare_load_path

Remove SourceReader::Inspec#prepare_load_path
This commit is contained in:
Christoph Hartmann 2016-09-07 10:43:45 +02:00 committed by GitHub
commit 9f980cff99

View file

@ -34,7 +34,6 @@ module SourceReaders
@tests = load_tests @tests = load_tests
@libraries = load_libs @libraries = load_libs
prepare_load_paths
end end
private private
@ -52,27 +51,5 @@ module SourceReaders
end end
Hash[tests.map { |x| [x, @target.read(x)] }] Hash[tests.map { |x| [x, @target.read(x)] }]
end end
# Ensure each test directory exists on the $LOAD_PATH. This
# will ensure traditional RSpec-isms like `require 'spec_helper'`
# continue to work. The method outlined here is only meant to be temporary!
def prepare_load_paths
t = @target
t = @target.parent unless @target.parent.nil?
unless t.is_a?(Fetchers::Local)
return # no need to mess with load-paths if this is not on disk
end
rel_dirs = (@libraries.keys + @tests.keys)
.map { |x| File.dirname(x) }.uniq
abs_dirs = rel_dirs.map { |x| @target.abs_path(x) }
.find_all { |x| File.directory?(x) }
.map { |x| File.expand_path(x) }
abs_dirs.each do |dir|
$LOAD_PATH.unshift dir unless $LOAD_PATH.include?(dir)
end
end
end end
end end