Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

RSpec/EmptyExampleGroup raises when using only shared examples in a context #884

Closed
jsugarman opened this issue Mar 18, 2020 · 3 comments
Closed

Comments

@jsugarman
Copy link

using rubocop-rspec (1.38.1)
this cop raises a violation for a block in which there are only shared_example calls

Example using cancancan ability_spec

RSpec.configure do |config|
  config.alias_it_behaves_like_to :is_able_to, 'is able to'
end

RSpec.shared_examples 'perform search' do
  it { is_expected.to be_able_to(%i[new create], SearchFilter) }
  it { is_expected.to be_able_to(%i[new create], Search) }
end


RSpec.describe Ability, type: :model do
  subject(:ability) { described_class.new(user) }

  # cop violated on this block
  # rubocop:disable RSpec/EmptyExampleGroup
  context 'when a manager' do
    let(:user) { create(:user, roles: ['manager']) }
    is_able_to 'perform search'
  end
  # rubocop:enable RSpec/EmptyExampleGroup
end
@pirj
Copy link
Member

pirj commented Mar 18, 2020

I suspect this is not because there are shared examples only, but because of an alias that rubocop-rspec is unaware of.
Related: #333

@pirj
Copy link
Member

pirj commented Nov 6, 2020

Handled in #1077

Appreciate if you could tackle a pull request to CanCanCan, @jsugarman

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

pirj commented Nov 9, 2020

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants