Skip to content

Commit

Permalink
Consider the multibyte value in the method name of system test
Browse files Browse the repository at this point in the history
`String#[]` returns a value that considers multibyte value. But maximum
filename length use bytes. So if applications use multibyte value to a
method name, currently check doesn't work expected.

This PR fixes to use `String#byteslice` instead of `String#[]`. Also,
added `String#scrub` to avoid generating an invalid byte sequence.
  • Loading branch information
y-yagi committed Nov 23, 2020
1 parent 934276b commit fa5a3ed
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rspec/rails/example/system_example_group.rb
Expand Up @@ -41,7 +41,7 @@ def method_name
@method_name ||= [
self.class.name.underscore,
RSpec.current_example.description.underscore
].join("_").tr(CHARS_TO_TRANSLATE.join, "_")[0...200] + "_#{rand(1000)}"
].join("_").tr(CHARS_TO_TRANSLATE.join, "_").byteslice(0...200).scrub("") + "_#{rand(1000)}"
end

# Delegates to `Rails.application`.
Expand Down

0 comments on commit fa5a3ed

Please sign in to comment.