Skip to content

Commit d7f0305

Browse files
committed
improve tempfile handling in tests
1 parent 2a277c5 commit d7f0305

File tree

2 files changed

+4
-33
lines changed

2 files changed

+4
-33
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
*.swp
33
doc
44
pkg/*.gem
5-
spec/tmp
65

76
# skip Gemfile.lock since this is a gem
87
Gemfile.lock

spec/spec_helper.rb

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,46 +6,18 @@
66
Vips.set_debug ENV["DEBUG"]
77
# Vips.leak_set true
88

9-
module Spec
10-
module Path
11-
def set_root(path)
12-
@root = Pathname.new(path).expand_path
13-
end
14-
15-
def sample(*path)
16-
root.join "samples", *path
17-
end
18-
19-
def tmp(*path)
20-
root.join "tmp", "working", *path
21-
end
22-
23-
extend self
24-
25-
private
26-
27-
def root
28-
@root ||= set_root(File.expand_path("..", __FILE__))
29-
end
30-
end
31-
end
32-
339
def simg(name)
34-
Spec::Path.sample(name).to_s
10+
File.join(File.expand_path("..", __FILE__), "samples", name)
3511
end
3612

3713
def timg(name)
38-
Spec::Path.tmp(name).to_s
14+
File.join(@temp_dir, name)
3915
end
4016

4117
RSpec.configure do |config|
42-
config.include Spec::Path
43-
4418
config.around do |example|
45-
Dir.mktmpdir do |dir|
46-
set_root(dir)
47-
FileUtils.mkdir_p(Spec::Path.sample)
48-
FileUtils.mkdir_p(Spec::Path.tmp)
19+
Dir.mktmpdir("ruby-vips-spec-") do |dir|
20+
@temp_dir = dir
4921
example.run
5022
end
5123
end

0 commit comments

Comments
 (0)