Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Allow pluralize to handle words that end with s. #2779

Merged
merged 1 commit into from
Nov 16, 2020
Merged

Allow pluralize to handle words that end with s. #2779

merged 1 commit into from
Nov 16, 2020

Conversation

joshuapinter
Copy link
Contributor

Use Case:

We have a custom formatter that we use with parallel_tests to get a cleaner output from the various test processes.

We make use of RSpec::Core::Formatters::Helpers.pluralize in there to display the number of remaining processes left.

However, instead of getting "processes", we get "processs".

Looking into the pluralize method definition, it simple adds an "s" to the end of the provided String, unless the count is equal to 1.

Without accounting for all the different words that are possible, which something like Rails would do, we just extended this to add "es" if the provided String ends in "s" already.

We also added tests for words that end in "s" and words that do not end in "s".

Copy link
Member

@JonRowe JonRowe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, could you just sort out the white spacing, I don't really want this to become a full on complex pluraliser, it was just supposed to be a basic one, but I think this is common enough that I don't mind adding this one case.

@joshuapinter
Copy link
Contributor Author

Thanks, could you just sort out the white spacing, I don't really want this to become a full on complex pluraliser, it was just supposed to be a basic one, but I think this is common enough that I don't mind adding this one case.

100%. Just enough to catch most of the common cases.

Use Case:

We have a custom formatter that we use with `parallel_tests` to get a cleaner output from the various test processes.

We make use of `RSpec::Core::Formatters::Helpers.pluralize` in there to display the number of remaining processes left.

However, instead of getting "processes", we get "processs".

Looking into the `pluralize` method definition, it simple adds an "s" to the end of the provided String, unless the count is equal to 1.

Without accounting for all the different words that are possible, which something like Rails would do, we just extended this to add "es" if the provided String ends in "s" already.

We also added tests for words that end in "s" and words that do not end in "s".
@JonRowe JonRowe merged commit 2bda6b7 into rspec:main Nov 16, 2020
JonRowe added a commit that referenced this pull request Nov 16, 2020
@joshuapinter
Copy link
Contributor Author

👍

@joshuapinter joshuapinter deleted the pluralize_words_ending_in_s branch November 16, 2020 17:19
@joshuapinter joshuapinter restored the pluralize_words_ending_in_s branch November 16, 2020 17:19
@joshuapinter joshuapinter deleted the pluralize_words_ending_in_s branch November 16, 2020 17:19
@joshuapinter joshuapinter restored the pluralize_words_ending_in_s branch November 16, 2020 17:19
@joshuapinter joshuapinter deleted the pluralize_words_ending_in_s branch November 16, 2020 17:19
pirj pushed a commit that referenced this pull request Nov 26, 2020
pirj pushed a commit that referenced this pull request Nov 26, 2020
pirj pushed a commit that referenced this pull request Nov 27, 2020
pirj pushed a commit that referenced this pull request Nov 27, 2020
pirj pushed a commit that referenced this pull request Nov 27, 2020
yujinakayama pushed a commit to yujinakayama/rspec-monorepo that referenced this pull request Oct 6, 2021
…_words_ending_in_s

Allow `pluralize` to handle words that end with s.

---
This commit was imported from rspec/rspec-core@2bda6b7.
yujinakayama pushed a commit to yujinakayama/rspec-monorepo that referenced this pull request Oct 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants