Merge pull request #249 from chef/schisamo/load-path-fix

ensure all test directories are on the runner $LOAD_PATH
This commit is contained in:
Dominik Richter 2015-11-20 13:55:40 +01:00
commit ff16a8ef27

View file

@ -52,6 +52,14 @@ module Inspec
tests = items.find_all { |i| i[:type] == :test }
libs = items.find_all { |i| i[:type] == :library }
# Ensure each test directory exists on the $LOAD_PATH. This
# will ensure traditional RSpec-isms like `require 'spec_helper'`
# continue to work.
tests.flatten.each do |test|
test_directory = File.dirname(test[:ref])
$LOAD_PATH.unshift test_directory unless $LOAD_PATH.include?(test_directory)
end
# add all tests (raw) to the runtime
tests.flatten.each do |test|
add_content(test, libs)