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

RSpec/EmptyExampleGroup warning when using rswag's run_test! #1177

Closed
Krupskis opened this issue Aug 9, 2021 · 6 comments
Closed

RSpec/EmptyExampleGroup warning when using rswag's run_test! #1177

Krupskis opened this issue Aug 9, 2021 · 6 comments

Comments

@Krupskis
Copy link

Krupskis commented Aug 9, 2021

rubocop does not recognize rswag's run_test! as a test block and results in an unexpected behavior. If this really is a bug, I would love to explore it and try to fix it.


Expected behavior

I expect this to give no offenses

Actual behavior

spec/integration/menu_spec.rb:3:1: C: RSpec/EmptyExampleGroup: Empty example group detected.
RSpec.describe MenusController do
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Steps to reproduce the problem

A simple spec like this should suffice.

require 'swagger_helper'

RSpec.describe MenusController do
  path '/menus' do
    get 'menus' do
      tags 'Menus'
      produces 'application/json'
      response '200', 'success' do
        run_test! do
        end
      end
    end
  end
end

RuboCop version

$ bundle exec rubocop -V
0.93.1 (using Parser 3.0.2.0, rubocop-ast 1.7.0, running on ruby 2.6.3 x86_64-darwin20)
@koic koic transferred this issue from rubocop/rubocop Aug 9, 2021
@pirj
Copy link
Member

pirj commented Aug 9, 2021

We've discussed pretty extensively how it would be possible to smoothen the rough edges between Rswag and rubocop-rspec in #1165. To make use of the described technique, you'll need to use RuboCop version that includes this fix. And it's not yet included in the latest 1.18.4.

Thanks for reporting. Please don't hesitate to ask further questions. This area is interesting and important to make rubocop-rspec compatible with many tools that add custom RSpec DSL.

If you want to kick-off rswag-rubocop-rspec to include the default configuration, that would be great, too.

@pirj pirj closed this as completed Aug 9, 2021
@Krupskis
Copy link
Author

Hey @pirj, thanks for the reply. Could you expand a bit more about this?

If you want to kick-off rswag-rubocop-rspec to include the default configuration, that would be great, too.

@pirj
Copy link
Member

pirj commented Aug 10, 2021

@pirj
Copy link
Member

pirj commented Aug 12, 2021

https://github.com/rubocop/rubocop/releases/tag/v1.19.0 released with the fix to DSL configuration loading.

@Krupskis
Copy link
Author

Krupskis commented Aug 15, 2021

https://github.com/rubocop/rubocop/releases/tag/v1.19.0 released with the fix to DSL configuration loading.

@pirj Thanks for the news! does that fix the RSpec/EmptyExampleGroup when only response and run_test! are present?

@pirj
Copy link
Member

pirj commented Aug 15, 2021

does that fix the RSpec/EmptyExampleGroup when only response and run_test! are present?

Provided you configure its DSL properly #1165, supposedly yes.
I encourage you to test it out.

yksflip added a commit to yksflip/foodsoft that referenced this issue Jan 2, 2023
this is fixed in newer rubocop-rspec versions.
see: rubocop/rubocop-rspec#1177
yksflip added a commit to yksflip/foodsoft that referenced this issue Jan 2, 2023
this is fixed in newer rubocop-rspec versions.
see: rubocop/rubocop-rspec#1177
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants