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

Generated requests specs are not consistent with naming #2355

Closed
eloyesp opened this issue Jun 17, 2020 · 5 comments
Closed

Generated requests specs are not consistent with naming #2355

eloyesp opened this issue Jun 17, 2020 · 5 comments

Comments

@eloyesp
Copy link
Contributor

eloyesp commented Jun 17, 2020

We noticed while working on tpope/vim-rails#368 , that generators does use a different naming scheme for requests specs.

For example, for a Posts Controller, the scaffold generator use spec/requests/posts_spec.rb, while using the controller generator does create spec/requests/posts_request_spec.rb.

There is a shared example for requests specs here that does use the first naming, that might be re-used everywhere to have a consistent naming scheme.

It seems like a minor issue, what are your opinions about this?

@pirj
Copy link
Member

pirj commented Jun 17, 2020

A fix is much appreciated. Thanks for reporting!

@klyonrad
Copy link
Contributor

klyonrad commented Jul 4, 2020

A more broad question @pirj @JonRowe

Is there some basic idea about when the spec files should get the type suffix and when not?
Even when we don't answer that question I think that the file naming style for controller and request specs should be similar.

When I made the changes to favor the request specs (see PRs #2262 and #2288) I oriented myself on how the controller spec file names were and still are (spec/controllers/foo_controller_spec.rb).
It felt a bit off to me because it looks soo redundant but if you look at the scaffold generator you can see that this behaviour is also there for the routing specs and the view specs. The exception to this convention are the model specs 🤔

The thinking that I can come up with is that people often type in only a file name to open and it could become confusing when both the model spec files and are named similarly (post_spec and posts_spec)`

@JonRowe
Copy link
Member

JonRowe commented Jul 4, 2020

Controller specs are named foo_controller_spec.rb only because the classes are FooController if you are not in a direct 1 to 1 relationship with a class you don't need to be so strict about your naming, that said I'd probably still match it to the noun of the controller.

klyonrad added a commit to klyonrad/rspec-rails that referenced this issue Aug 21, 2020
JonRowe pushed a commit that referenced this issue Aug 26, 2020
pirj pushed a commit that referenced this issue Sep 2, 2020
@klyonrad
Copy link
Contributor

This is closed wih #2378

@JonRowe JonRowe closed this as completed Sep 25, 2020
@JonRowe
Copy link
Member

JonRowe commented Sep 25, 2020

Good spot, this should have been autoclosed.

This was referenced Mar 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants