- Notifications
You must be signed in to change notification settings - Fork 631
/
Copy pathhelper.rb
49 lines (35 loc) · 970 Bytes
/
helper.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# frozen_string_literal: true
require"minitest/autorun"
require"fileutils"
require"pathname"
TEST_DIR=File.expand_path(__dir__)
TEMP_DIR=File.join(TEST_DIR,"tmp")
defsetup_tempdir
FileUtils.mkdir_p(TEMP_DIR)
File.exist?(TEMP_DIR) ? TEMP_DIR : nil
end
defchdir_tempdir
setup_tempdirunlessFile.exist?(TEMP_DIR)
Dir.chdir(TEMP_DIR)
end
defteardown_tempdir
FileUtils.rm_rf(TEMP_DIR)ifFile.exist?(TEMP_DIR)
end
defcreate_file(path,content)
raise"path must be relative"unlessPathname.new(path).relative?
dir=File.dirname(path)
FileUtils.mkdir_p(dir)
File.write(path,content)
end
deflinter_output
stdout,_stderr=capture_io{Linter.new(exit_on_errors: false).run}
stdout
end
deffile_must_exist(filename)
assertFile.exist?(filename),
"Expected file `#{filename}' to exist."
end
deffile_wont_exist(filename)
assert !File.exist?(filename),
"Expected file `#{filename}' to not exist."
end