Skip to content

Add test coverage for String filter boundary inputs - #57562

Merged
fatkodima merged 1 commit into
rails:mainfrom
hammadxcm:test-string-filter-edge-cases
Jun 4, 2026
Merged

fatkodima merged 1 commit into
rails:mainfrom
hammadxcm:test-string-filter-edge-cases

Conversation

@hammadxcm

Copy link
Copy Markdown
Contributor

Adds coverage for several untested no-op / boundary inputs to the String filter methods in active_support/core_ext/string/filters.rb. All test-only; no production code changes.

  • String#remove with no patterns returns an unchanged copy (a distinct object, not the receiver)
  • String#remove! with no patterns returns self unchanged
  • String#truncate_words with a zero word count returns the string unchanged
  • String#truncate_words with a negative word count returns the string unchanged

The existing remove/remove! tests only passed matching patterns, and truncate_words was only tested with positive counts (and counts ≥ the word count), so these boundary cases were unexercised.

Cover untested no-op/boundary inputs to the String filter methods in
active_support/core_ext/string/filters.rb:

- remove with no patterns returns an unchanged copy (a distinct object)
- remove! with no patterns returns self unchanged
- truncate_words with a zero word count returns the string unchanged
- truncate_words with a negative word count returns the string unchanged
@fatkodima
fatkodima merged commit 9aa5903 into rails:main Jun 4, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants