From 6279549cdb7b17e7555dc275f8c044b5baec0b0b Mon Sep 17 00:00:00 2001 From: qwyng Date: Thu, 29 Sep 2022 23:32:09 +0900 Subject: [PATCH] add support for rubocop-rspec syntax extensions --- README.md | 10 ++++++++++ config/rubocop-rspec.yml | 5 +++++ 2 files changed, 15 insertions(+) create mode 100644 config/rubocop-rspec.yml diff --git a/README.md b/README.md index 5cee228..4ce649e 100644 --- a/README.md +++ b/README.md @@ -802,6 +802,16 @@ An alternative approach to Pundit policy specs is scoping them to a user context Pundit does not provide a DSL for testing scopes. Just test it like a regular Ruby class! +### Linting with RuboCop RSpec + +When you lint your RSpec spec files with `rubocop-rspec`, it will fail to properly detect RSpec constructs that Pundit defines, `permissions`. +Make sure to use `rubocop-rspec` 2.0 or newer and add the following to your `.rubocop.yml`: + +```yaml +inherit_gem: + pundit: config/rubocop-rspec.yml +``` + # External Resources - [RailsApps Example Application: Pundit and Devise](https://github.com/RailsApps/rails-devise-pundit) diff --git a/config/rubocop-rspec.yml b/config/rubocop-rspec.yml new file mode 100644 index 0000000..6f4c7e1 --- /dev/null +++ b/config/rubocop-rspec.yml @@ -0,0 +1,5 @@ +RSpec: + Language: + ExampleGroups: + Regular: + - permissions