Skip to content

Commit 0b2c7aa

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 Sibling pull requests: - palkan/action_policy#138
1 parent 8116530 commit 0b2c7aa

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

CHANGELOG.md

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

33
## master (unrealeased)
44

5+
- Add support for RSpec aliases detection when linting specs using `let_it_be`/`before_all` with `rubocop-rspec` 2.0 ([@pirj][])
6+
57
## 0.12.2 (2020-09-03)
68

79
- Execute Minitest `before_all` in the context of the current test object. ([@palkan][])

config/rubocop-rspec.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
RSpec:
2+
Language:
3+
Helpers:
4+
- let_it_be
5+
Hooks:
6+
- before_all

docs/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,16 @@ Supported Ruby versions:
8888

8989
Supported RSpec version (for RSpec features only): >= 3.5.0 (for older RSpec version use TestProf < 0.8.0).
9090

91+
### Linting with RuboCop RSpec
92+
93+
When you lint your RSpec spec files with `rubocop-rspec`, it will fail to properly detect RSpec constructs that TestProf defines, `let_it_be` and `before_all`.
94+
Make sure to use `rubocop-rspec` 2.0 or newer and add the following to your `.rubocop.yml`:
95+
96+
```yaml
97+
inherit_gem:
98+
test-prof: config/rubocop-rspec.yml
99+
```
100+
91101
## Profilers
92102
93103
- [RubyProf Integration](./profilers/ruby_prof.md)

test-prof.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
2626
"source_code_uri" => "http://github.com/test-prof/test-prof"
2727
}
2828

29-
spec.files = Dir.glob("lib/**/*") + Dir.glob("config/**/*") + Dir.glob("assets/**/*") + %w[README.md LICENSE.txt CHANGELOG.md]
29+
spec.files = Dir.glob("lib/**/*") + Dir.glob("config/**/*") + Dir.glob("assets/**/*") + %w[README.md LICENSE.txt CHANGELOG.md] + %w[config/rubocop-rspec.yml]
3030

3131
spec.require_paths = ["lib"]
3232

0 commit comments

Comments
 (0)