Skip to content

Commit 4e57433

Browse files
committed
Add RuboCop RSpec support
Previously, RuboCop RSpec failed to detect RSpec aliases. A number of cops were failing false offences, and some cops were unable to lint, as they were skipping locally defined RSpec aliases taking them for arbitrary blocks and method calls. See: - rubocop/rubocop-rspec#1077 - rubocop/rubocop-rspec#956 - palkan#103
1 parent 3927a67 commit 4e57433

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

.rubocop-rspec-aliases.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
RSpec:
2+
Language:
3+
ExampleGroups:
4+
Regular:
5+
- describe_rule
6+
Focused:
7+
- fdescribe_rule
8+
Skipped:
9+
- xdescribe_rule
10+
Includes:
11+
Examples:
12+
- succeed
13+
- failed
14+
- fsucceed
15+
- ffailed
16+
- xsucceed
17+
- xfailed

action_policy.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
1313
spec.homepage = "https://github.com/palkan/action_policy"
1414
spec.license = "MIT"
1515

16-
spec.files = Dir.glob("lib/**/*") + Dir.glob("lib/.rbnext/**/*") + %w[README.md LICENSE.txt CHANGELOG.md]
16+
spec.files = Dir.glob("lib/**/*") + Dir.glob("lib/.rbnext/**/*") + %w[README.md LICENSE.txt CHANGELOG.md] + %w[rubocop-rspec-aliases.yml]
1717

1818
spec.metadata = {
1919
"bug_tracker_uri" => "http://github.com/palkan/action_policy/issues",

docs/testing.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,3 +388,13 @@ describe "users/index.html.slim" do
388388
end
389389
end
390390
```
391+
392+
## Linting with RuboCop RSpec
393+
394+
When you lint your RSpec spec files with `rubocop-rspec`, it will fail to detect RSpec aliases that Action Policy defines.
395+
Make sure to use `rubocop-rspec` 2.0 or newer and add the following to your `.rubocop.yml`:
396+
397+
```yaml
398+
inherit_gem:
399+
action_policy: .rubocop-rspec-aliases.yml
400+
```

0 commit comments

Comments
 (0)