Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pluralize 'spec(s) per process' #792

Merged
merged 1 commit into from
Dec 4, 2020
Merged

Conversation

brchristian
Copy link
Contributor

@brchristian brchristian commented Dec 4, 2020

Thank you for your contribution!

Checklist

  • Feature branch is up-to-date with master (if not - rebase it).
  • Added tests.
  • Added an entry to the Changelog if the new
    code introduces user-observable changes.
  • Update Readme.md when cli options are changed

Copy link
Owner

@grosser grosser left a comment

Choose a reason for hiding this comment

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

that would only work in rails ... so need some hand-rolled pluralize method

@brchristian
Copy link
Contributor Author

brchristian commented Dec 4, 2020

@grosser Ah, I had thought it was in Ruby, but maybe I’m wrong about that!

How about something simple like the following?

"#{name}#{'s' if tests_per_process > 1} per process"

or maybe

"#{name}#{'s' unless tests_per_process == 1} per process"

@grosser
Copy link
Owner

grosser commented Dec 4, 2020

that works ... can put it into a pluralize method to make it clearer :)

@brchristian
Copy link
Contributor Author

Good point! Although I would worry about namespacing conflicts with the Rails one. Because it only gets used in this one place, maybe it’s best to just do it inline. If we find ourselves using it in other places we can always DRY it up later. That’s my thinking! But LMK if you disagree and I am happy to create a method. Otherwise I have force-pushed and I think we’re looking good.

@brchristian
Copy link
Contributor Author

Actually, you’ve convinced me! Pluralize version has now been force-pushed. :)

Comment on lines 148 to 152
def pluralize(n, singular, plural=nil)
if n == 1
"1 #{singular}"
elsif plural
"#{n} #{plural}"
Copy link
Owner

Choose a reason for hiding this comment

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

we never pass plural 🤷

Suggested change
def pluralize(n, singular, plural=nil)
if n == 1
"1 #{singular}"
elsif plural
"#{n} #{plural}"
def pluralize(n, singular)
if n == 1
"1 #{singular}"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The idea was to include future proofing for weird stuff like person/people. :) If it’s cleaner to remove it, no problem!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, pushed with your changes!

@@ -142,7 +142,17 @@ def report_number_of_tests(groups)
num_processes = groups.size
num_tests = groups.map(&:size).inject(0, :+)
tests_per_process = (num_processes == 0 ? 0 : num_tests / num_processes)
puts "#{num_processes} processes for #{num_tests} #{name}s, ~ #{tests_per_process} #{name}s per process"
puts "#{pluralize(num_processes, 'process'} for #{pluralize(num_tests, name)}, ~ #{pluralize(tests_per_process, name)} per process"
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
puts "#{pluralize(num_processes, 'process'} for #{pluralize(num_tests, name)}, ~ #{pluralize(tests_per_process, name)} per process"
puts "#{pluralize(num_processes, 'process')} for #{pluralize(num_tests, name)}, ~ #{pluralize(tests_per_process, name)} per process"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whoops, you’re 100% correct! Sorry about that. Force-pushed!

@grosser
Copy link
Owner

grosser commented Dec 4, 2020

tests need some fixes since they assert specs and it's now spec

@brchristian
Copy link
Contributor Author

Tests are now updated with regex!

@grosser grosser merged commit 54cc798 into grosser:master Dec 4, 2020
@grosser
Copy link
Owner

grosser commented Dec 4, 2020

thx, will be in next release whenever that comes around :)

@brchristian brchristian deleted the pluralize branch December 4, 2020 05:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants