I noticed when trying to generate a Rails scaffold for a model name that begins with a vowel sound that the generated test name did not inflect the English indefinite article correctly.
# bin/rails g scaffold Author
# resulting test in est/system/authors_test.rb
# rest of test class
test "creating a Author" do
# body omitted
end
test "updating a Author" do
# body omitted
end
test "destroying a Author" do
# body omitted
end
I opened a Github issue for the lack of agreement on the generated test and have a simple fix in a pull request that fixes the issue by editing out the indefinite article, but I think it would be beneficial to have this type of inflection in ActiveSupport. (Something like ActiveSupport::Inflector#indefinitize)
Considerations:
- In English there are words that begin with a vowel but not a vowel sound (a universe) and words that begin with a consonant but have a vowel sound (an honor). This could be solved by adding new configuration options to active_support/inflector/inflections
inflect.begins_with_vowel_sound(/regex/)
- The inflection of the indefinite article (and the definite article) requires gender in the romance languages. A solution that solves for it would need to be able to handle locale options.
- Setting up something to handle gender agreement for languages that use them would require integration with a dictionary of some sort because placing all of the gendered nouns in a language in config is not viable.