Skip to content

Commit

Permalink
(maint) Remove overstubbing
Browse files Browse the repository at this point in the history
Dir.glob behaves differently across platforms and ruby versions, don't
stub it.
  • Loading branch information
joshcooper committed Sep 27, 2021
1 parent 3828aab commit e0602f7
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions spec/unit/util/autoload_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,14 @@ def with_libdir(libdir)
end

describe "when loading all files" do
let(:basedir) { tmpdir('autoloader') }
let(:path) { File.join(basedir, @autoload.path, 'file.rb') }

before do
allow(@autoload.class).to receive(:search_directories).and_return([make_absolute("/a")])
allow(FileTest).to receive(:directory?).and_return(true)
allow(Dir).to receive(:glob).and_return([make_absolute("/a/foo/file.rb")])
allow(Puppet::FileSystem).to receive(:exist?).and_return(true)
@time_a = Time.utc(2010, 'jan', 1, 6, 30)
allow(File).to receive(:mtime).and_return(@time_a)
FileUtils.mkdir_p(File.dirname(path))
FileUtils.touch(path)

allow(@autoload.class).to receive(:loaded?).and_return(false)
allow(@autoload.class).to receive(:search_directories).and_return([basedir])
end

[RuntimeError, LoadError, SyntaxError].each do |error|
Expand All @@ -198,7 +197,7 @@ def with_libdir(libdir)
end

it "should require the full path to the file" do
expect(Kernel).to receive(:load).with(make_absolute("/a/foo/file.rb"), any_args)
expect(Kernel).to receive(:load).with(path, any_args)

@autoload.loadall(env)
end
Expand Down

0 comments on commit e0602f7

Please sign in to comment.