Skip to content

Commit 6370eab

Browse files
author
Alex Evanczuk
committed
Allow skipping changing directory to tmpdir when using packs/rspec/support
1 parent 27bdcc1 commit 6370eab

3 files changed

Lines changed: 13 additions & 7 deletions

File tree

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
packs-specification (0.0.9)
4+
packs-specification (0.0.10)
55
sorbet-runtime
66

77
GEM

lib/packs/rspec/support.rb

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,18 @@
1010

1111
# Eventually, we could make this opt-in via metadata so someone can use this support without affecting all their tests.
1212
config.around do |example|
13-
prefix = [File.basename($0), Process.pid].join('-') # rubocop:disable Style/SpecialGlobalVars
14-
tmpdir = Dir.mktmpdir(prefix)
15-
Dir.chdir(tmpdir) do
13+
if example.metadata[:skip_chdir_to_tmpdir]
1614
example.run
15+
else
16+
begin
17+
prefix = [File.basename($0), Process.pid].join('-') # rubocop:disable Style/SpecialGlobalVars
18+
tmpdir = Dir.mktmpdir(prefix)
19+
Dir.chdir(tmpdir) do
20+
example.run
21+
end
22+
ensure
23+
FileUtils.rm_rf(tmpdir)
24+
end
1725
end
18-
ensure
19-
FileUtils.rm_rf(tmpdir)
2026
end
2127
end

packs-specification.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Gem::Specification.new do |spec|
22
spec.name = 'packs-specification'
3-
spec.version = '0.0.9'
3+
spec.version = '0.0.10'
44
spec.authors = ['Gusto Engineers']
55
spec.email = ['dev@gusto.com']
66
spec.summary = 'The specification for packs in the `rubyatscale` ecosystem.'

0 commit comments

Comments
 (0)