Skip to content

Commit

Permalink
Allow skipping changing directory to tmpdir when using packs/rspec/su…
Browse files Browse the repository at this point in the history
…pport
  • Loading branch information
Alex Evanczuk committed Aug 11, 2023
1 parent 27bdcc1 commit 6370eab
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
packs-specification (0.0.9)
packs-specification (0.0.10)
sorbet-runtime

GEM
Expand Down
16 changes: 11 additions & 5 deletions lib/packs/rspec/support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,18 @@

# Eventually, we could make this opt-in via metadata so someone can use this support without affecting all their tests.
config.around do |example|
prefix = [File.basename($0), Process.pid].join('-') # rubocop:disable Style/SpecialGlobalVars
tmpdir = Dir.mktmpdir(prefix)
Dir.chdir(tmpdir) do
if example.metadata[:skip_chdir_to_tmpdir]
example.run
else
begin
prefix = [File.basename($0), Process.pid].join('-') # rubocop:disable Style/SpecialGlobalVars
tmpdir = Dir.mktmpdir(prefix)
Dir.chdir(tmpdir) do
example.run
end
ensure
FileUtils.rm_rf(tmpdir)
end
end
ensure
FileUtils.rm_rf(tmpdir)
end
end
2 changes: 1 addition & 1 deletion packs-specification.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |spec|
spec.name = 'packs-specification'
spec.version = '0.0.9'
spec.version = '0.0.10'
spec.authors = ['Gusto Engineers']
spec.email = ['[email protected]']
spec.summary = 'The specification for packs in the `rubyatscale` ecosystem.'
Expand Down

0 comments on commit 6370eab

Please sign in to comment.