Skip to content

Commit 931dd74

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 931dd74

File tree

4 files changed

+31
-1
lines changed

4 files changed

+31
-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

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## master
44

5+
- Add support for RSpec aliases detection when linting policy specs with `rubocop-rspec` 2.0 ([@pirj][])
6+
57
## 0.5.0 (2020-09-29)
68

79
- Move `deny!` / `allow!` to core. ([@palkan][])
@@ -429,3 +431,4 @@ This value is now stored in a cache (if any) instead of just the call result (`t
429431
[@nicolas-brousse]: https://github.com/nicolas-brousse
430432
[@somenugget]: https://github.com/somenugget
431433
[@Be-ngt-oH]: https://github.com/Be-ngt-oH
434+
[@pirj]: https://github.com/pirj

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)