Skip to content

Commit

Permalink
Create spec temp dir helper
Browse files Browse the repository at this point in the history
  • Loading branch information
apexatoll committed Sep 24, 2023
1 parent f761cab commit 47b4e33
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ def load_support_files!
config.order = :random

config.include FileHelper
config.include TempDirHelper
end
15 changes: 15 additions & 0 deletions spec/support/temp_dir_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module TempDirHelper
RSpec.configure do |config|
config.around(with_temp_dir: true) do |spec|
self.class.class_eval { attr_reader :temp_dir }

Dir.mktmpdir do |temp_dir|
@temp_dir = temp_dir

spec.run

remove_instance_variable(:@temp_dir)
end
end
end
end

0 comments on commit 47b4e33

Please sign in to comment.