Skip to content

Commit

Permalink
Allow deeper group nesting in RSpec
Browse files Browse the repository at this point in the history
The reason for restricting nesting is presumably to flag complex test setups
that indicate a smell in the tested code. [Three levels are
allowed](rubocop/rubocop-rspec#207 (comment))
to accomodate this common style:

```ruby
describe MyClass do
  describe '#a_method' do
    context 'some application state' do
      # examples
    end

    context 'other application state' do
      # examples
    end
  end
end
```

My experience has been that a slightly more complex setup in a Rails
application (particularly for model and controller specs) is more a fact of life
than a code smell. Four levels accommodates code like:

```ruby
describe MyController, type: :controller do
  context 'when logged in as admin' do
    include_context 'as admin' do

    ...
  end

  context 'when logged is as other_role' do
    include_context 'as other_role' do
    ...
  end
end
```

Using my current application as a gague, my sense is that the additional level
of nesting addresses the common cases.
  • Loading branch information
Tom Johnson committed Oct 2, 2017
1 parent f14b123 commit 9859dd0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion bixby_rspec_enabled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ RSpec/NamedSubject:

RSpec/NestedGroups:
Enabled: true
Max: 3
Max: 5

RSpec/NotToNot:
EnforcedStyle: not_to
Expand Down

0 comments on commit 9859dd0

Please sign in to comment.