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

Add support for rubocop-rspec syntax extensions #745

Merged
merged 1 commit into from Oct 19, 2022

Conversation

QWYNG
Copy link
Contributor

@QWYNG QWYNG commented Sep 29, 2022

Hi, Thank you for Great Gem.

fix #691

Example

Gemfile

# frozen_string_literal: true

source 'https://rubygems.org'

gem 'pundit', path: '../pundit'
gem 'rubocop'
gem 'rubocop-rspec'

.rubocop.yml

AllCops:
  NewCops: enable

require:
  - rubocop-rspec

inherit_gem:
  pundit: config/rubocop-rspec.yml

spec/policies/some_policy_spec.rb

# frozen_string_literal: true

RSpec.describe SomePolicy do
  permissions :update?, :edit? do
    'wowwow'
  end
end

Before

bundle exec rubocop
Inspecting 2 files
.C

Offenses:

spec/policies/some_policy_spec.rb:3:1: C: [Correctable] RSpec/EmptyExampleGroup: Empty example group detected.
RSpec.describe SomePolicy do
^^^^^^^^^^^^^^^^^^^^^^^^^

2 files inspected, 1 offense detected, 1 offense autocorrectable

After

bundle exec rubocop
Inspecting 2 files
.C

Offenses:

spec/policies/some_policy_spec.rb:4:3: C: [Correctable] RSpec/EmptyExampleGroup: Empty example group detected.
  permissions :update?, :edit? do
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

2 files inspected, 1 offense detected, 1 offense autocorrectable

See also:
palkan/action_policy#138
test-prof/test-prof#199

@Burgestrand
Copy link
Member

Thank you!

I had issues seeing the change at first since both before and after triggered warnings, but I see it now :D

# frozen_string_literal: true

RSpec.describe SomePolicy do
  permissions :update?, :edit? do
    # empty example group here!
  end

  it 'does something'
end

@Burgestrand Burgestrand merged commit a5d756a into varvet:main Oct 19, 2022
@madhums
Copy link

madhums commented Dec 12, 2022

@Burgestrand could you please make a release with this change?

@Burgestrand
Copy link
Member

@Burgestrand could you please make a release with this change?

Thank you for the reminder! I'll dedicate some time to it monday next week.

@Burgestrand Burgestrand mentioned this pull request Dec 19, 2022
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

Successfully merging this pull request may close these issues.

Add support for Rubocop syntax extensions
3 participants