Remove all non word characters from screenshot filenames
Screenshot filenames are derived from test names which can contain special characters. These special characters may not be supported by CI systems like Github Actions. Replacing all non word characters ensures compatibility.
This commit is contained in:
parent
be52c380aa
commit
bccf42baf8
@ -62,7 +62,7 @@ def unique
|
||||
end
|
||||
|
||||
def image_name
|
||||
sanitized_method_name = method_name.tr("/\\", "--")
|
||||
sanitized_method_name = method_name.gsub(/[^\w]+/, "-")
|
||||
name = "#{unique}_#{sanitized_method_name}"
|
||||
name[0...225]
|
||||
end
|
||||
|
@ -158,12 +158,12 @@ def setup
|
||||
end
|
||||
end
|
||||
|
||||
test "slashes and backslashes are replaced with dashes in paths" do
|
||||
slash_test = DrivenBySeleniumWithChrome.new("x/y\\z")
|
||||
test "Non word characters are replaced with dashes in paths" do
|
||||
non_word_chars_test = DrivenBySeleniumWithChrome.new("x/y\\z?<br>-span")
|
||||
|
||||
Rails.stub :root, Pathname.getwd do
|
||||
assert_equal Rails.root.join("tmp/screenshots/0_x-y-z.png").to_s, slash_test.send(:image_path)
|
||||
assert_equal Rails.root.join("tmp/screenshots/0_x-y-z.html").to_s, slash_test.send(:html_path)
|
||||
assert_equal Rails.root.join("tmp/screenshots/0_x-y-z-br-span.png").to_s, non_word_chars_test.send(:image_path)
|
||||
assert_equal Rails.root.join("tmp/screenshots/0_x-y-z-br-span.html").to_s, non_word_chars_test.send(:html_path)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user