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
RSpec/ScatteredSetup: false positive #1165
Comments
Your example only has a single I could suggest configuring example groups to include rubocop-rspec/config/default.yml Line 9 in e33f838
Be extra careful with that, though, as the default settings might be overridden due to a bug. |
The whole structure is more like: describe 'Cluster' do
path '/clusters/{id}/start' do
post 'Start cluster' do
tags 'Cluster'
operationId 'startCluster'
produces 'application/json'
parameter name: :id, in: :path, type: :integer
response '200', 'success' do
before do
cleanup_operations(existing_cluster)
end
schema '$ref' => '#/components/schemas/OperationResult'
run_test!
end
response '409', 'conflict' do
schema '$ref' => '#/components/schemas/OperationResult'
run_test!
end
end
path '/clusters/{id}/delete' do
post 'Delete cluster' do
tags 'Cluster'
operationId 'deleteCluster'
produces 'application/json'
parameter name: :id, in: :path, type: :integer
response '200', 'success' do
before do
cleanup_operations(existing_cluster)
end
schema '$ref' => '#/components/schemas/OperationResult'
run_test!
end
response '409', 'conflict' do
schema '$ref' => '#/components/schemas/OperationResult'
run_test!
end
end
end but with several more endpoints. |
Can you please try configuring the DSL? |
In general, we could suggest |
Thanks for the response.
If I put spec/requests/api_controller/clusters_spec.rb:607:7: C: RSpec/EmptyExampleGroup: Empty example group detected.
response '200', 'success' do
^^^^^^^^^^^^^^^^^^^^^^^^^
spec/requests/api_controller/clusters_spec.rb:638:7: C: RSpec/EmptyExampleGroup: Empty example group detected.
response '200', 'success' do |
Gotcha, RSpec:
Language:
ExampleGroups:
Regular:
- path
- post
- put
- get
- delete
Examples:
Regular:
- response Thanks for pointing me in that direction. I got a bunch of other offences, probably since Rubocop/RSpec started properly analyzing my rspec file, but the initial problem is gone. |
@pirj, so if I am right, what I can do to prevent someone else from hitting the same issue in the future? Create issue / PR in the https://github.com/rswag/rswag asking to add RSpec:
Language:
ExampleGroups:
Regular:
- path
- post
- put
- get
- delete
Examples:
Regular:
- response and follow https://docs.rubocop.org/rubocop-rspec/third_party_rspec_syntax_extensions.html#packaging-configuration-for-rubocop-rspec + https://github.com/palkan/action_policy/pull/138/files ? |
palkan/action_policy#138 is more representative, where Same here,
Right. |
@ololobus Any update? |
Thanks for your previous comment, now I use: RSpec:
Language:
ExampleGroups:
Regular:
- path
- post
- put
- get
- delete
- response
Examples:
Regular:
- run_test! so far so good. I only receive reasonable warnings. I have not prepared a PR yet, but I found a closed issue rswag/rswag#138. And it seems that they are not really willing to accept something like that. Although I want to try anyway |
I went ahead and going to fix the bug I've mentioned earlier in rubocop/rubocop#9952 If Do you think there's anything actionable left, or we can close this ticket, @ololobus ? |
@pirj, yeah, I think so. Thanks for responses, that helped me a lot. I'm closing this one |
@Krupskis, not yet |
@ololobus Do you plan to do so? I would like to contribute |
Yeah, I'm going to do it, but if you are willing to do it right now, then go ahead, sure 👍 |
@ololobus I would like to do it together, as I am a beginner, especially at gems, so having some guidance would be pretty cool. |
I am using rails 6 + rspec + rswag and have a following repeating pattern in my request specs:
The idea is that model does not allow concurrent operations, so if there are running ones it will return
409
code. But I also want to test200
response, so I use a cleanup helper, which forcedly marks all operations as finished. This would be fine, but I have several similar endpoints to test, e.g.start
,stop
, etc. And for some responses I need before callback and for some of them I do not, thus I cannot declarebefore
on thedescribe
level.However,
RSpec/ScatteredSetup
says:and so on.
And I cannot obey, because it will ruin my test logic. Am I missing something?
The text was updated successfully, but these errors were encountered: