Open andysellick opened 1 year ago
There's an interesting inconsistency in government-frontend
that's worth documenting. The component test files are in test/components
so I looked into moving them into spec/components
to match the gem.
We use two different systems for tests - RSpec and Minitest, and which directory the test should go in is related to the system. government-frontend
uses Minitest, so the tests are in test/
, and if we wanted to move them we'd have to rewrite them in RSpec first. That's probably not worth the effort for the sake of component auditing.
I was having a quick look at this issue and how we can try to avoid using incorrect file names in the future.
When I followed the documentation to Create a new component in the application, I ran the command below to generate a new component:
rails generate govuk_publishing_components:component new_component_name
However, the file name for the component view template included hyphens instead of underscores.
government-frontend % rails generate govuk_publishing_components:component new_component_name
create app/views/components/_new-component-name.html.erb
create app/views/components/docs/new-component-name.yml
create app/assets/stylesheets/components/_new-component-name.scss
This could also be worth looking into further, but might be beyond the scope of this issue.
I'm doing a bit of a spike into making the component auditing report on components within applications, prompted by recent conversations. Turns out that our naming and file location conventions for components within the gem aren't always being followed by applications. Here's some (very) initial investigations.
For component templates:
_component_name.html.erb
app/views/govuk_publishing_components/components/
_component-name.html.erb
app/views/components/
_component-name.html.erb
app/views/components/
For component test files:
component_name_spec.rb
spec/components/
component_name.html.erb_spec.rb
spec/views/components/
component_name_spec.rb
spec/components/
This inconsistency is going to make auditing components in applications difficult, as we'd have to include specific details of all of these things on a per-application basis within the auditing. I'll have a look at whether applications could be restructured slightly instead.