Skip to content

Commit

Permalink
Add RuboCop RSpec support
Browse files Browse the repository at this point in the history
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
  • Loading branch information
pirj authored and palkan committed Nov 18, 2020
1 parent 8116530 commit 8d6b0c7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,8 @@

## master (unrealeased)

- Add support for RSpec aliases detection when linting specs using `let_it_be`/`before_all` with `rubocop-rspec` 2.0 ([@pirj][])

## 0.12.2 (2020-09-03)

- Execute Minitest `before_all` in the context of the current test object. ([@palkan][])
Expand Down
6 changes: 6 additions & 0 deletions config/rubocop-rspec.yml
@@ -0,0 +1,6 @@
RSpec:
Language:
Helpers:
- let_it_be
Hooks:
- before_all
10 changes: 10 additions & 0 deletions docs/README.md
Expand Up @@ -88,6 +88,16 @@ Supported Ruby versions:

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

### Linting with RuboCop RSpec

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`.
Make sure to use `rubocop-rspec` 2.0 or newer and add the following to your `.rubocop.yml`:

```yaml
inherit_gem:
test-prof: config/rubocop-rspec.yml
```

## Profilers

- [RubyProf Integration](./profilers/ruby_prof.md)
Expand Down

0 comments on commit 8d6b0c7

Please sign in to comment.