Skip to content

Commit

Permalink
Merge pull request #1055 from rubocop-hq/release-2.0
Browse files Browse the repository at this point in the history
Release RuboCop RSpec v2.0
  • Loading branch information
bquorning committed Nov 6, 2020
2 parents 137dc91 + 056ee5a commit c3fa5ba
Show file tree
Hide file tree
Showing 182 changed files with 1,300 additions and 1,077 deletions.
2 changes: 1 addition & 1 deletion .rubocop.yml
Expand Up @@ -8,7 +8,7 @@ require:
AllCops:
DisplayCopNames: true
TargetRubyVersion: 2.4
NewCops: enable
NewCops: disable
Exclude:
- 'vendor/**/*'
- 'spec/fixtures/**/*'
Expand Down
4 changes: 4 additions & 0 deletions .rubocop_todo.yml
Expand Up @@ -10,3 +10,7 @@
# Configuration parameters: CountComments, CountAsOne.
Metrics/ClassLength:
Max: 106

RSpec/ExampleLength:
Exclude:
- spec/rubocop/cop/rspec/factory_bot/attribute_defined_statically_spec.rb
17 changes: 16 additions & 1 deletion CHANGELOG.md
@@ -1,7 +1,21 @@
# Change log
# Changelog

## Master (Unreleased)

## 2.0.0 (2020-11-06)

* Remove deprecated class `::RuboCop::Cop::RSpec::Cop`. ([@bquorning][])
* Retire `RSpec/InvalidPredicateMatcher` cop. ([@pirj][])
* Remove the code responsible for filtering files to inspect. ([@pirj][])
* Make RSpec language elements configurable. ([@sl4vr][])
* Remove `CustomIncludeMethods` `RSpec/EmptyExampleGroup` option in favour of the new RSpec DSL configuration. ([@pirj][])
* Enabled pending cop (`RSpec/StubbedMock`). ([@pirj][])

## 2.0.0.pre (2020-10-22)

* Update RuboCop dependency to v1.0.0. ([@bquorning][])
* Change namespace of several cops (`Capybara/*` -> `RSpec/Capybara/*`, `FactoryBot/*` -> `RSpec/FactoryBot/*`, `Rails/*` -> `RSpec/Rails/*`). ([@pirj][], [@bquorning][])

## 1.44.1 (2020-10-20)

* Relax `rubocop-ast` version constraint. ([@PhilCoggins][])
Expand Down Expand Up @@ -571,3 +585,4 @@ Compatibility release so users can upgrade RuboCop to 0.51.0. No new features.
[@koic]: https://github.com/koic
[@Rafix02]: https://github.com/Rafix02
[@PhilCoggins]: https://github.com/PhilCoggins
[@sl4vr]: https://github.com/sl4vr
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -23,6 +23,10 @@ or if you use bundler put this in your `Gemfile`
gem 'rubocop-rspec', require: false
```

### Upgrading to RuboCop RSpec v2.x

Read all the details in our [Upgrade to Version 2.x](https://docs.rubocop.org/rubocop-rspec/2.0/upgrade_to_version_2.html) document.

## Usage

You need to tell RuboCop to load the RSpec extension. There are three
Expand Down
140 changes: 114 additions & 26 deletions config/default.yml
@@ -1,14 +1,85 @@
---
AllCops:
RSpec:
Patterns:
- _spec.rb
- "(?:^|/)spec/"
RSpec/FactoryBot:
Patterns:
- spec/factories.rb
- spec/factories/**/*.rb
- features/support/factories/**/*.rb
RSpec:
Include:
- "**/*_spec.rb"
- "**/spec/**/*"
Language:
ExampleGroups:
Regular:
- describe
- context
- feature
- example_group
Skipped:
- xdescribe
- xcontext
- xfeature
Focused:
- fdescribe
- fcontext
- ffeature
Examples:
Regular:
- it
- specify
- example
- scenario
- its
Focused:
- fit
- fspecify
- fexample
- fscenario
- focus
Skipped:
- xit
- xspecify
- xexample
- xscenario
- skip
Pending:
- pending
Expectations:
- expect
- is_expected
- expect_any_instance_of
Helpers:
- let
- let!
Hooks:
- prepend_before
- before
- append_before
- around
- prepend_after
- after
- append_after
HookScopes:
- each
- example
- context
- all
- suite
Includes:
Examples:
- it_behaves_like
- it_should_behave_like
- include_examples
Context:
- include_context
Runners:
- to
- to_not
- not_to
SharedGroups:
Examples:
- shared_examples
- shared_examples_for
Context:
- shared_context
Subjects:
- subject
- subject!

RSpec/AlignLeftLetBrace:
Description: Checks that left braces for adjacent single line lets are aligned.
Expand Down Expand Up @@ -136,8 +207,8 @@ RSpec/Dialect:
RSpec/EmptyExampleGroup:
Description: Checks if an example group does not include any tests.
Enabled: true
CustomIncludeMethods: []
VersionAdded: '1.7'
VersionChanged: '2.0'
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/EmptyExampleGroup

RSpec/EmptyHook:
Expand Down Expand Up @@ -241,6 +312,9 @@ RSpec/ExpectOutput:
RSpec/FilePath:
Description: Checks that spec file paths are consistent and well-formed.
Enabled: true
Include:
- "**/*_spec*rb*"
- "**/spec/**/*"
CustomTransform:
RuboCop: rubocop
RSpec: rspec
Expand Down Expand Up @@ -315,12 +389,6 @@ RSpec/InstanceVariable:
VersionChanged: '1.7'
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/InstanceVariable

RSpec/InvalidPredicateMatcher:
Description: Checks invalid usage for predicate matcher.
Enabled: true
VersionAdded: '1.16'
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/InvalidPredicateMatcher

RSpec/ItBehavesLike:
Description: Checks that only one `it_behaves_like` style is used.
Enabled: true
Expand Down Expand Up @@ -561,7 +629,7 @@ RSpec/SingleArgumentMessageChain:

RSpec/StubbedMock:
Description: Checks that message expectations do not have a configured response.
Enabled: pending
Enabled: true
VersionAdded: '1.44'
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/StubbedMock

Expand Down Expand Up @@ -620,54 +688,74 @@ RSpec/Yield:
VersionAdded: '1.32'
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Yield

Capybara/CurrentPathExpectation:
RSpec/Capybara/CurrentPathExpectation:
Description: Checks that no expectations are set on Capybara's `current_path`.
Enabled: true
VersionAdded: '1.18'
VersionChanged: '2.0'
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Capybara/CurrentPathExpectation

Capybara/FeatureMethods:
RSpec/Capybara/FeatureMethods:
Description: Checks for consistent method usage in feature specs.
Enabled: true
EnabledMethods: []
VersionAdded: '1.17'
VersionChanged: '1.25'
VersionChanged: '2.0'
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Capybara/FeatureMethods

Capybara/VisibilityMatcher:
RSpec/Capybara/VisibilityMatcher:
Description: Checks for boolean visibility in capybara finders.
Enabled: true
VersionAdded: '1.39'
VersionChanged: '2.0'
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Capybara/VisibilityMatcher

FactoryBot/AttributeDefinedStatically:
RSpec/FactoryBot/AttributeDefinedStatically:
Description: Always declare attribute values as blocks.
Enabled: true
Include:
- spec/factories.rb
- spec/factories/**/*.rb
- features/support/factories/**/*.rb
VersionAdded: '1.28'
VersionChanged: '2.0'
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/FactoryBot/AttributeDefinedStatically

FactoryBot/CreateList:
RSpec/FactoryBot/CreateList:
Description: Checks for create_list usage.
Enabled: true
Include:
- "**/*_spec.rb"
- "**/spec/**/*"
- spec/factories.rb
- spec/factories/**/*.rb
- features/support/factories/**/*.rb
EnforcedStyle: create_list
SupportedStyles:
- create_list
- n_times
VersionAdded: '1.25'
VersionChanged: '2.0'
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/FactoryBot/CreateList

FactoryBot/FactoryClassName:
RSpec/FactoryBot/FactoryClassName:
Description: Use string value when setting the class attribute explicitly.
Enabled: true
Include:
- spec/factories.rb
- spec/factories/**/*.rb
- features/support/factories/**/*.rb
VersionAdded: '1.37'
VersionChanged: '2.0'
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/FactoryBot/FactoryClassName

Rails/HttpStatus:
RSpec/Rails/HttpStatus:
Description: Enforces use of symbolic or numeric value to describe HTTP status.
Enabled: true
EnforcedStyle: symbolic
SupportedStyles:
- numeric
- symbolic
VersionAdded: '1.23'
VersionChanged: '2.0'
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Rails/HttpStatus
2 changes: 1 addition & 1 deletion docs/antora.yml
@@ -1,5 +1,5 @@
name: rubocop-rspec
title: RuboCop RSpec
version: master
version: '2.0'
nav:
- modules/ROOT/nav.adoc
1 change: 1 addition & 0 deletions docs/modules/ROOT/nav.adoc
Expand Up @@ -2,6 +2,7 @@
* xref:installation.adoc[Installation]
* xref:usage.adoc[Usage]
* xref:cops.adoc[Cops]
* xref:upgrade_to_version_2.adoc[Upgrade to 2.x]
* Cops Documentation
** xref:cops_capybara.adoc[Capybara]
** xref:cops_factorybot.adoc[FactoryBot]
Expand Down
29 changes: 14 additions & 15 deletions docs/modules/ROOT/pages/cops.adoc
@@ -1,17 +1,5 @@
// START_COP_LIST

=== Department xref:cops_capybara.adoc[Capybara]

* xref:cops_capybara.adoc#capybaracurrentpathexpectation[Capybara/CurrentPathExpectation]
* xref:cops_capybara.adoc#capybarafeaturemethods[Capybara/FeatureMethods]
* xref:cops_capybara.adoc#capybaravisibilitymatcher[Capybara/VisibilityMatcher]

=== Department xref:cops_factorybot.adoc[FactoryBot]

* xref:cops_factorybot.adoc#factorybotattributedefinedstatically[FactoryBot/AttributeDefinedStatically]
* xref:cops_factorybot.adoc#factorybotcreatelist[FactoryBot/CreateList]
* xref:cops_factorybot.adoc#factorybotfactoryclassname[FactoryBot/FactoryClassName]

=== Department xref:cops_rspec.adoc[RSpec]

* xref:cops_rspec.adoc#rspecalignleftletbrace[RSpec/AlignLeftLetBrace]
Expand Down Expand Up @@ -52,7 +40,6 @@
* xref:cops_rspec.adoc#rspecimplicitsubject[RSpec/ImplicitSubject]
* xref:cops_rspec.adoc#rspecinstancespy[RSpec/InstanceSpy]
* xref:cops_rspec.adoc#rspecinstancevariable[RSpec/InstanceVariable]
* xref:cops_rspec.adoc#rspecinvalidpredicatematcher[RSpec/InvalidPredicateMatcher]
* xref:cops_rspec.adoc#rspecitbehaveslike[RSpec/ItBehavesLike]
* xref:cops_rspec.adoc#rspeciteratedexpectation[RSpec/IteratedExpectation]
* xref:cops_rspec.adoc#rspecleadingsubject[RSpec/LeadingSubject]
Expand Down Expand Up @@ -95,8 +82,20 @@
* xref:cops_rspec.adoc#rspecvoidexpect[RSpec/VoidExpect]
* xref:cops_rspec.adoc#rspecyield[RSpec/Yield]

=== Department xref:cops_rails.adoc[Rails]
=== Department xref:cops_rspec/capybara.adoc[RSpec/Capybara]

* xref:cops_rspec/capybara.adoc#rspeccapybara/currentpathexpectation[RSpec/Capybara/CurrentPathExpectation]
* xref:cops_rspec/capybara.adoc#rspeccapybara/featuremethods[RSpec/Capybara/FeatureMethods]
* xref:cops_rspec/capybara.adoc#rspeccapybara/visibilitymatcher[RSpec/Capybara/VisibilityMatcher]

=== Department xref:cops_rspec/factorybot.adoc[RSpec/FactoryBot]

* xref:cops_rspec/factorybot.adoc#rspecfactorybot/attributedefinedstatically[RSpec/FactoryBot/AttributeDefinedStatically]
* xref:cops_rspec/factorybot.adoc#rspecfactorybot/createlist[RSpec/FactoryBot/CreateList]
* xref:cops_rspec/factorybot.adoc#rspecfactorybot/factoryclassname[RSpec/FactoryBot/FactoryClassName]

=== Department xref:cops_rspec/rails.adoc[RSpec/Rails]

* xref:cops_rails.adoc#railshttpstatus[Rails/HttpStatus]
* xref:cops_rspec/rails.adoc#rspecrails/httpstatus[RSpec/Rails/HttpStatus]

// END_COP_LIST

0 comments on commit c3fa5ba

Please sign in to comment.