DavyJonesLocker / client_side_validations

Client Side Validations made easy for Ruby on Rails
MIT License
2.68k stars 404 forks source link

Issues related to JS Regexp conversions #927

Closed tagliala closed 6 months ago

tagliala commented 7 months ago

Rubocop minitest started reporting offenses of unexecutable tests placed outside of the test class

Unfortunately, there were some tests related to Regexp conversion that were never executed.

At the moment, two tests are failing (actually it is the same in both form_for and form_with), and they are related to "escaped space"

Ref: https://github.com/DavyJonesLocker/client_side_validations/actions/runs/7232584071

Long story short:

Expected: "\\ "
Actual:   " "

This can actually be a false positive and the escaped space is returned as a space to remove a redundant escape char

@jaynetics do you have any suggestion?

It is possible to replicate on chore/update-dependencies branch by running

rake test:ruby TESTOPTS="-n/test_field_with_format_escaped_space/"

Also, a commit https://github.com/jaynetics/js_regex/commit/ba77cc4590e413ea83d12b2dd0615d9a0b8d876b in js_regex fixed an issue with another test, test_extended_mode_regexp_with_escaped_whitespace_as_json:

--- expected
+++ actual
@@ -1 +1 @@
-{:source=>"[ a] ", :options=>""}
+{:source=>"[\\x20a] ", :options=>""}