Skip to content

Commit c3fa5ba

Browse files
authored
Merge pull request #1055 from rubocop-hq/release-2.0
Release RuboCop RSpec v2.0
2 parents 137dc91 + 056ee5a commit c3fa5ba

File tree

182 files changed

+1300
-1077
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

182 files changed

+1300
-1077
lines changed

.rubocop.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require:
88
AllCops:
99
DisplayCopNames: true
1010
TargetRubyVersion: 2.4
11-
NewCops: enable
11+
NewCops: disable
1212
Exclude:
1313
- 'vendor/**/*'
1414
- 'spec/fixtures/**/*'

.rubocop_todo.yml

+4
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@
1010
# Configuration parameters: CountComments, CountAsOne.
1111
Metrics/ClassLength:
1212
Max: 106
13+
14+
RSpec/ExampleLength:
15+
Exclude:
16+
- spec/rubocop/cop/rspec/factory_bot/attribute_defined_statically_spec.rb

CHANGELOG.md

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
1-
# Change log
1+
# Changelog
22

33
## Master (Unreleased)
44

5+
## 2.0.0 (2020-11-06)
6+
7+
* Remove deprecated class `::RuboCop::Cop::RSpec::Cop`. ([@bquorning][])
8+
* Retire `RSpec/InvalidPredicateMatcher` cop. ([@pirj][])
9+
* Remove the code responsible for filtering files to inspect. ([@pirj][])
10+
* Make RSpec language elements configurable. ([@sl4vr][])
11+
* Remove `CustomIncludeMethods` `RSpec/EmptyExampleGroup` option in favour of the new RSpec DSL configuration. ([@pirj][])
12+
* Enabled pending cop (`RSpec/StubbedMock`). ([@pirj][])
13+
14+
## 2.0.0.pre (2020-10-22)
15+
16+
* Update RuboCop dependency to v1.0.0. ([@bquorning][])
17+
* Change namespace of several cops (`Capybara/*` -> `RSpec/Capybara/*`, `FactoryBot/*` -> `RSpec/FactoryBot/*`, `Rails/*` -> `RSpec/Rails/*`). ([@pirj][], [@bquorning][])
18+
519
## 1.44.1 (2020-10-20)
620

721
* Relax `rubocop-ast` version constraint. ([@PhilCoggins][])
@@ -571,3 +585,4 @@ Compatibility release so users can upgrade RuboCop to 0.51.0. No new features.
571585
[@koic]: https://github.com/koic
572586
[@Rafix02]: https://github.com/Rafix02
573587
[@PhilCoggins]: https://github.com/PhilCoggins
588+
[@sl4vr]: https://github.com/sl4vr

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ or if you use bundler put this in your `Gemfile`
2323
gem 'rubocop-rspec', require: false
2424
```
2525

26+
### Upgrading to RuboCop RSpec v2.x
27+
28+
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.
29+
2630
## Usage
2731

2832
You need to tell RuboCop to load the RSpec extension. There are three

config/default.yml

+114-26
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,85 @@
11
---
2-
AllCops:
3-
RSpec:
4-
Patterns:
5-
- _spec.rb
6-
- "(?:^|/)spec/"
7-
RSpec/FactoryBot:
8-
Patterns:
9-
- spec/factories.rb
10-
- spec/factories/**/*.rb
11-
- features/support/factories/**/*.rb
2+
RSpec:
3+
Include:
4+
- "**/*_spec.rb"
5+
- "**/spec/**/*"
6+
Language:
7+
ExampleGroups:
8+
Regular:
9+
- describe
10+
- context
11+
- feature
12+
- example_group
13+
Skipped:
14+
- xdescribe
15+
- xcontext
16+
- xfeature
17+
Focused:
18+
- fdescribe
19+
- fcontext
20+
- ffeature
21+
Examples:
22+
Regular:
23+
- it
24+
- specify
25+
- example
26+
- scenario
27+
- its
28+
Focused:
29+
- fit
30+
- fspecify
31+
- fexample
32+
- fscenario
33+
- focus
34+
Skipped:
35+
- xit
36+
- xspecify
37+
- xexample
38+
- xscenario
39+
- skip
40+
Pending:
41+
- pending
42+
Expectations:
43+
- expect
44+
- is_expected
45+
- expect_any_instance_of
46+
Helpers:
47+
- let
48+
- let!
49+
Hooks:
50+
- prepend_before
51+
- before
52+
- append_before
53+
- around
54+
- prepend_after
55+
- after
56+
- append_after
57+
HookScopes:
58+
- each
59+
- example
60+
- context
61+
- all
62+
- suite
63+
Includes:
64+
Examples:
65+
- it_behaves_like
66+
- it_should_behave_like
67+
- include_examples
68+
Context:
69+
- include_context
70+
Runners:
71+
- to
72+
- to_not
73+
- not_to
74+
SharedGroups:
75+
Examples:
76+
- shared_examples
77+
- shared_examples_for
78+
Context:
79+
- shared_context
80+
Subjects:
81+
- subject
82+
- subject!
1283

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

143214
RSpec/EmptyHook:
@@ -241,6 +312,9 @@ RSpec/ExpectOutput:
241312
RSpec/FilePath:
242313
Description: Checks that spec file paths are consistent and well-formed.
243314
Enabled: true
315+
Include:
316+
- "**/*_spec*rb*"
317+
- "**/spec/**/*"
244318
CustomTransform:
245319
RuboCop: rubocop
246320
RSpec: rspec
@@ -315,12 +389,6 @@ RSpec/InstanceVariable:
315389
VersionChanged: '1.7'
316390
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/InstanceVariable
317391

318-
RSpec/InvalidPredicateMatcher:
319-
Description: Checks invalid usage for predicate matcher.
320-
Enabled: true
321-
VersionAdded: '1.16'
322-
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/InvalidPredicateMatcher
323-
324392
RSpec/ItBehavesLike:
325393
Description: Checks that only one `it_behaves_like` style is used.
326394
Enabled: true
@@ -561,7 +629,7 @@ RSpec/SingleArgumentMessageChain:
561629

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

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

623-
Capybara/CurrentPathExpectation:
691+
RSpec/Capybara/CurrentPathExpectation:
624692
Description: Checks that no expectations are set on Capybara's `current_path`.
625693
Enabled: true
626694
VersionAdded: '1.18'
695+
VersionChanged: '2.0'
627696
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Capybara/CurrentPathExpectation
628697

629-
Capybara/FeatureMethods:
698+
RSpec/Capybara/FeatureMethods:
630699
Description: Checks for consistent method usage in feature specs.
631700
Enabled: true
632701
EnabledMethods: []
633702
VersionAdded: '1.17'
634-
VersionChanged: '1.25'
703+
VersionChanged: '2.0'
635704
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Capybara/FeatureMethods
636705

637-
Capybara/VisibilityMatcher:
706+
RSpec/Capybara/VisibilityMatcher:
638707
Description: Checks for boolean visibility in capybara finders.
639708
Enabled: true
640709
VersionAdded: '1.39'
710+
VersionChanged: '2.0'
641711
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Capybara/VisibilityMatcher
642712

643-
FactoryBot/AttributeDefinedStatically:
713+
RSpec/FactoryBot/AttributeDefinedStatically:
644714
Description: Always declare attribute values as blocks.
645715
Enabled: true
716+
Include:
717+
- spec/factories.rb
718+
- spec/factories/**/*.rb
719+
- features/support/factories/**/*.rb
646720
VersionAdded: '1.28'
721+
VersionChanged: '2.0'
647722
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/FactoryBot/AttributeDefinedStatically
648723

649-
FactoryBot/CreateList:
724+
RSpec/FactoryBot/CreateList:
650725
Description: Checks for create_list usage.
651726
Enabled: true
727+
Include:
728+
- "**/*_spec.rb"
729+
- "**/spec/**/*"
730+
- spec/factories.rb
731+
- spec/factories/**/*.rb
732+
- features/support/factories/**/*.rb
652733
EnforcedStyle: create_list
653734
SupportedStyles:
654735
- create_list
655736
- n_times
656737
VersionAdded: '1.25'
738+
VersionChanged: '2.0'
657739
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/FactoryBot/CreateList
658740

659-
FactoryBot/FactoryClassName:
741+
RSpec/FactoryBot/FactoryClassName:
660742
Description: Use string value when setting the class attribute explicitly.
661743
Enabled: true
744+
Include:
745+
- spec/factories.rb
746+
- spec/factories/**/*.rb
747+
- features/support/factories/**/*.rb
662748
VersionAdded: '1.37'
749+
VersionChanged: '2.0'
663750
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/FactoryBot/FactoryClassName
664751

665-
Rails/HttpStatus:
752+
RSpec/Rails/HttpStatus:
666753
Description: Enforces use of symbolic or numeric value to describe HTTP status.
667754
Enabled: true
668755
EnforcedStyle: symbolic
669756
SupportedStyles:
670757
- numeric
671758
- symbolic
672759
VersionAdded: '1.23'
760+
VersionChanged: '2.0'
673761
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Rails/HttpStatus

docs/antora.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: rubocop-rspec
22
title: RuboCop RSpec
3-
version: master
3+
version: '2.0'
44
nav:
55
- modules/ROOT/nav.adoc

docs/modules/ROOT/nav.adoc

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* xref:installation.adoc[Installation]
33
* xref:usage.adoc[Usage]
44
* xref:cops.adoc[Cops]
5+
* xref:upgrade_to_version_2.adoc[Upgrade to 2.x]
56
* Cops Documentation
67
** xref:cops_capybara.adoc[Capybara]
78
** xref:cops_factorybot.adoc[FactoryBot]

docs/modules/ROOT/pages/cops.adoc

+14-15
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
11
// START_COP_LIST
22

3-
=== Department xref:cops_capybara.adoc[Capybara]
4-
5-
* xref:cops_capybara.adoc#capybaracurrentpathexpectation[Capybara/CurrentPathExpectation]
6-
* xref:cops_capybara.adoc#capybarafeaturemethods[Capybara/FeatureMethods]
7-
* xref:cops_capybara.adoc#capybaravisibilitymatcher[Capybara/VisibilityMatcher]
8-
9-
=== Department xref:cops_factorybot.adoc[FactoryBot]
10-
11-
* xref:cops_factorybot.adoc#factorybotattributedefinedstatically[FactoryBot/AttributeDefinedStatically]
12-
* xref:cops_factorybot.adoc#factorybotcreatelist[FactoryBot/CreateList]
13-
* xref:cops_factorybot.adoc#factorybotfactoryclassname[FactoryBot/FactoryClassName]
14-
153
=== Department xref:cops_rspec.adoc[RSpec]
164

175
* xref:cops_rspec.adoc#rspecalignleftletbrace[RSpec/AlignLeftLetBrace]
@@ -52,7 +40,6 @@
5240
* xref:cops_rspec.adoc#rspecimplicitsubject[RSpec/ImplicitSubject]
5341
* xref:cops_rspec.adoc#rspecinstancespy[RSpec/InstanceSpy]
5442
* xref:cops_rspec.adoc#rspecinstancevariable[RSpec/InstanceVariable]
55-
* xref:cops_rspec.adoc#rspecinvalidpredicatematcher[RSpec/InvalidPredicateMatcher]
5643
* xref:cops_rspec.adoc#rspecitbehaveslike[RSpec/ItBehavesLike]
5744
* xref:cops_rspec.adoc#rspeciteratedexpectation[RSpec/IteratedExpectation]
5845
* xref:cops_rspec.adoc#rspecleadingsubject[RSpec/LeadingSubject]
@@ -95,8 +82,20 @@
9582
* xref:cops_rspec.adoc#rspecvoidexpect[RSpec/VoidExpect]
9683
* xref:cops_rspec.adoc#rspecyield[RSpec/Yield]
9784

98-
=== Department xref:cops_rails.adoc[Rails]
85+
=== Department xref:cops_rspec/capybara.adoc[RSpec/Capybara]
86+
87+
* xref:cops_rspec/capybara.adoc#rspeccapybara/currentpathexpectation[RSpec/Capybara/CurrentPathExpectation]
88+
* xref:cops_rspec/capybara.adoc#rspeccapybara/featuremethods[RSpec/Capybara/FeatureMethods]
89+
* xref:cops_rspec/capybara.adoc#rspeccapybara/visibilitymatcher[RSpec/Capybara/VisibilityMatcher]
90+
91+
=== Department xref:cops_rspec/factorybot.adoc[RSpec/FactoryBot]
92+
93+
* xref:cops_rspec/factorybot.adoc#rspecfactorybot/attributedefinedstatically[RSpec/FactoryBot/AttributeDefinedStatically]
94+
* xref:cops_rspec/factorybot.adoc#rspecfactorybot/createlist[RSpec/FactoryBot/CreateList]
95+
* xref:cops_rspec/factorybot.adoc#rspecfactorybot/factoryclassname[RSpec/FactoryBot/FactoryClassName]
96+
97+
=== Department xref:cops_rspec/rails.adoc[RSpec/Rails]
9998

100-
* xref:cops_rails.adoc#railshttpstatus[Rails/HttpStatus]
99+
* xref:cops_rspec/rails.adoc#rspecrails/httpstatus[RSpec/Rails/HttpStatus]
101100

102101
// END_COP_LIST

0 commit comments

Comments
 (0)