Skip to content

Commit 44a7ae2

Browse files
committed
Name test methods from relative paths
Full path name of the source directory is a useless noise as tests.
1 parent 9192d9a commit 44a7ae2

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

test/parse_test.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,16 @@ def test_parse_takes_file_path
3434
assert_equal filepath, find_source_file_node(parsed_result.value).filepath
3535
end
3636

37-
Dir[File.expand_path("fixtures/**/*.txt", __dir__)].each do |filepath|
38-
relative = filepath.delete_prefix("#{File.expand_path("fixtures", __dir__)}/")
37+
base = File.join(__dir__, "fixtures")
38+
Dir["**/*.txt", base: base].each do |relative|
3939
next if known_failures.include?(relative)
4040

41+
filepath = File.join(base, relative)
4142
snapshot = File.expand_path(File.join("snapshots", relative), __dir__)
4243
directory = File.dirname(snapshot)
4344
FileUtils.mkdir_p(directory) unless File.directory?(directory)
4445

45-
define_method "test_filepath_#{filepath}" do
46+
define_method "test_filepath_#{relative}" do
4647
# First, read the source from the filepath. Use binmode to avoid converting CRLF on Windows,
4748
# and explicitly set the external encoding to UTF-8 to override the binmode default.
4849
source = File.read(filepath, binmode: true, external_encoding: Encoding::UTF_8)

0 commit comments

Comments
 (0)