I have a project with a model-controller pair that were created with the scaffold generator. The model is Species, so the matching controller is SpeciesController. This is the expected result of the inflection, however it means I have two automatically generated test classes with the same name: test/models/species_test.rb: SpeciesTest < ActiveSupport::TestCase and test/system/species_test.rb: SpeciesTest < ApplicationSystemTestCase.
On their own, these tests run fine (both rails test and rails test:system run as expected) but when they are both run (rails test:all), I get an error because of the name clash:
test/system/species_test.rb:3:in ‘’: superclass mismatch for class SpeciesTest (TypeError)
Obviously one of these classes needs to be renamed, and my hunch is the system test, but what is the “right” way to rename this class? Is there a standard way to handle such a name conflict, or is this ultimately a blindspot of the current framework naming conventions?
I believe the issue is because the word Species is an irregular plural.
From what I see in the docs the “normal” convention is that model tests
use the singular form, for example: test/models/article_test.rb
And the system tests use the plural form, for example: test/system/articles_test.rb
There might be a way to solve this by passing some option to the generator but I believe the fastest solution would be to rename the system test to a different name.
Yes, the issue is the noun where the plural is the same as the singular (what I believe ActiveSupport inflection calls “uncountable” despite not being necessarily the exact right label linguistically), and you are correct that the system test should be named differently. This is the core of my question, in a highly-opinionated framework where naming is fairly rigid, I am asking if there is a preferred naming scheme for this test, and also wondering if this is an issue that the framework should flag when the tests are generated.