diff options
Diffstat (limited to 'spec/support/tmpdir.rb')
-rw-r--r-- | spec/support/tmpdir.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/support/tmpdir.rb b/spec/support/tmpdir.rb new file mode 100644 index 00000000000..ea8e26d2878 --- /dev/null +++ b/spec/support/tmpdir.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +module TmpdirHelper + def mktmpdir + @tmpdir_helper_dirs ||= [] + @tmpdir_helper_dirs << Dir.mktmpdir + @tmpdir_helper_dirs.last + end + + def self.included(base) + base.after do + if @tmpdir_helper_dirs + FileUtils.rm_rf(@tmpdir_helper_dirs) + @tmpdir_helper_dirs = nil + end + end + end +end |