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 and CustomIncludeMethods with contexts #1050

Closed
incubus opened this issue Oct 21, 2020 · 4 comments
Closed

RSpec/EmptyExampleGroup and CustomIncludeMethods with contexts #1050

incubus opened this issue Oct 21, 2020 · 4 comments

Comments

@incubus
Copy link

incubus commented Oct 21, 2020

Hi!

RSpec/EmptyExampleGroup doesn't use CustomIncludeMethods with contexts. Here is an example with 1.44.1 version:

# frozen_string_literal: true

describe 'Object' do
  context 'with test' do
    example_request 'Remove' do
      expect(status).to eq 204
    end

    context 'with error' do
      example_request 'Update error' do
        expect(status).to eq 422
      end
    end
  end
end
RSpec/EmptyExampleGroup:
  CustomIncludeMethods:
    - example_request
spec/acceptance/test_spec.rb:9:5: C: RSpec/EmptyExampleGroup: Empty example group detected.
    context 'with error' do
    ^^^^^^^^^^^^^^^^^^^^

There is not problem with 1.43.2 version. Thanks!

@pirj
Copy link
Member

pirj commented Oct 21, 2020

Thanks for reporting!

CustomIncludeMethods were intended to facilitate the detection of aliases to it_behaves_like, not example group aliases.
It turns out it lacks support for such aliases being called with a block, like in your case.

There's a pull request fixing this #1015, but we decided not to merge it. Feel free to point your Gemfile to that fork/branch if you like as a short-term solution.

However, with #956 soon to be merged, we don't plan and wouldn't recommend to invest effort into fixing this.
Along with it, we plan to drop the CustomIncludeMethods config option altogether, see #1007.

If you don't have custom cops based on rubocop-rspec's code and would like this to be fixed ASAP along with 2.0 release, the best you can do is to check some recent pull request's edge-rubocop CI failure and send a pull request fixing at least some of them.

I'll keep this ticket open just in case.

@pirj
Copy link
Member

pirj commented Nov 6, 2020

#956 has been released in 2.0, so this should be fixed given that you configure your RSpec DSL aliases for RuboCop RSpec.

Please feel free to reopen if it won't affect how RSpec/EmptyExampleGroup behaves.

@pirj pirj closed this as completed Nov 6, 2020
@pirj
Copy link
Member

pirj commented Nov 6, 2020

Forgot to mention that CustomIncludeMethods have been removed in #1007

@pirj
Copy link
Member

pirj commented Nov 6, 2020

Also, this is a duplicate of #1006

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