Skip to content

Commit 03626d2

Browse files
committed
Fixing spec require so that it does't cause bogus constant redefinition
1 parent 1ed3021 commit 03626d2

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

chef/spec/spec_helper.rb

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,21 @@
1717
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1818
#
1919

20-
require File.join(File.dirname(__FILE__), "..", "lib", "chef")
21-
Dir[File.join(File.dirname(__FILE__), '..', 'lib', 'chef', '**', '*.rb')].sort.each { |lib| require lib }
20+
$:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
21+
22+
require 'chef'
23+
24+
chef_lib_path = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
25+
Dir[
26+
File.expand_path(
27+
File.join(
28+
chef_lib_path, 'chef', '**', '*.rb'
29+
)
30+
)
31+
].sort.each do |lib|
32+
lib_short_path = lib.match("^#{chef_lib_path}#{File::SEPARATOR}(.+)$")[1]
33+
require lib_short_path
34+
end
2235
Dir[File.join(File.dirname(__FILE__), 'lib', '**', '*.rb')].sort.each { |lib| require lib }
2336

2437
Chef::Config.log_level(:error)

0 commit comments

Comments
 (0)