-
-
Notifications
You must be signed in to change notification settings - Fork 383
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
Let :A edit requests spec #368
Comments
Do request tests map cleanly to controllers? |
Yes.
|
Uh are you sure you didn't screw that up? |
Sorry, I meant |
So the name of the spec doesn't have |
Brining this issue back to life. They usually map |
@teoljungberg can you cite an OSS project or 2 that does this? |
@tpope not from the top of my head. I've seen it in a few client projects though |
Here's a projection I use to resolve this issue (for those interested). let g:rails_projections = {
\ "app/controllers/*_controller.rb": {
\ "test": [
\ "spec/requests/{}_spec.rb",
\ "spec/controllers/{}_controller_spec.rb",
\ "test/controllers/{}_controller_test.rb"
\ ],
\ "alternate": [
\ "spec/requests/{}_spec.rb",
\ "spec/controllers/{}_controller_spec.rb",
\ "test/controllers/{}_controller_test.rb"
\ ],
\ },
\ "spec/requests/*_spec.rb": {
\ "command": "request",
\ "alternate": "app/controllers/{}_controller.rb",
\ "template": "require 'rails_helper'\n\n" .
\ "RSpec.describe '{}' do\nend",
\ },
\ } |
FWIW, rspec-rails follows this convention.
https://relishapp.com/rspec/rspec-rails/v/3-7/docs/request-specs/request-spec |
Seems irrelevant to a filename conversation but ok. |
It seems that there is no alternate defined on the request spec file so going from spec to controller does not work. |
This also supports feature and system tests, by defining projections. tpope/vim-rails#368 (comment)
When using @teoljungberg rails projections placed in
|
It seems that requests specs are generated by default now by
As far as I understand, it seems that requests specs should be first in the alternate list. |
@eloyesp That seems like what is created when you generate a scaffold. When you generate a controller, it seems to be using a different format
|
The same can be done for rake tasks with RSpec. let g:rails_projections = {
\ 'lib/tasks/*.rake': {
\ 'alternate': 'spec/lib/tasks/{}_spec.rb'
\ },
\ 'spec/lib/tasks/*_spec.rb': {
\ 'alternate': 'lib/tasks/{}.rake'
\ }
\} |
Adds support for rspec `requests/` default directory naming in addition to `controllers/` and `intergration/`. Based on tpope/vim-rails#368 (comment)
Enables using `alternate` and `test` between Rails controller files and associated RSpec request specs. Based on tpope/vim-rails#368 (comment)
I have a controller that does not have controller unit tests but request integration tests.
When I am inside the controller I would like to be able to press
:A
to open the request test file. But instead it tries to open the controller unit test.The text was updated successfully, but these errors were encountered: