Skip to content

Commit 38a9ed7

Browse files
committed
RSpec -> RSpecRails
1 parent 73411e4 commit 38a9ed7

38 files changed

+981
-3577
lines changed

.github/workflows/main.yml

+20-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,26 @@ jobs:
6969
- uses: actions/checkout@v4
7070
- name: Use latest RuboCop from `master`
7171
run: |
72-
echo "gem 'rubocop', github: 'rubocop/rubocop'" > Gemfile.local
72+
echo "gem 'rubocop', github: 'rubocop-hq/rubocop'" > Gemfile.local
73+
- uses: ruby/setup-ruby@v1
74+
with:
75+
ruby-version: "3.3"
76+
bundler-cache: true
77+
- run: NO_COVERAGE=true bundle exec rake ${{ matrix.task }}
78+
79+
edge-rubocop-rspec:
80+
runs-on: ubuntu-latest
81+
strategy:
82+
matrix:
83+
task:
84+
- internal_investigation
85+
- spec
86+
name: "Edge RuboCop RSpec: ${{ matrix.task }}"
87+
steps:
88+
- uses: actions/checkout@v4
89+
- name: Use latest RuboCop RSpec from `master`
90+
run: |
91+
echo "gem 'rubocop-rspec', github: 'rubocop/rubocop-rspec'" > Gemfile.local
7392
- uses: ruby/setup-ruby@v1
7493
with:
7594
ruby-version: "3.3"

.rubocop.yml

+3-11
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ Lint/RedundantCopDisableDirective:
4949

5050
Metrics/BlockLength:
5151
Exclude:
52-
- rubocop-rspec.gemspec
52+
- rubocop-rspec_rails.gemspec
5353
- Rakefile
5454
- '**/*.rake'
5555

5656
Naming/FileName:
5757
Exclude:
58-
- lib/rubocop-rspec.rb
58+
- lib/rubocop-rspec_rails.rb
5959

6060
Naming/InclusiveLanguage:
6161
Enabled: true
@@ -85,9 +85,6 @@ Naming/InclusiveLanguage:
8585
violation:
8686
Suggestions:
8787
- offense
88-
'register no offense':
89-
Suggestions:
90-
- registers no offense
9188

9289
RSpec:
9390
Language:
@@ -118,11 +115,6 @@ Style/FormatStringToken:
118115
Style/RequireOrder:
119116
Enabled: true
120117

121-
RSpec/SpecFilePathFormat:
122-
Enabled: true
123-
Exclude:
124-
- spec/rubocop/cop/rspec/mixin/**/*.rb
125-
126118
# Enable some of RuboCop's pending cops.
127119

128120
Layout/LineContinuationSpacing:
@@ -142,7 +134,7 @@ Style/RedundantStringEscape:
142134
Style/ReturnNilInPredicateMethodDefinition:
143135
Enabled: true
144136

145-
# Enable our own pending cops.
137+
# Enable pending rubocop-rspec cops.
146138

147139
RSpec/BeEmpty:
148140
Enabled: true

.simplecov

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
SimpleCov.start do
44
enable_coverage :branch
5-
minimum_coverage line: 99.60, branch: 94.77
5+
minimum_coverage line: 95.17, branch: 85.13
66
add_filter '/spec/'
77
add_filter '/vendor/bundle/'
88
end

CHANGELOG.md

+2-909
Large diffs are not rendered by default.

README.md

+18-26
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,79 @@
1-
# RuboCop RSpec
1+
# RuboCop RSpec Rails
22

33
[![Join the chat at https://gitter.im/rubocop-rspec/Lobby](https://badges.gitter.im/rubocop-rspec/Lobby.svg)](https://gitter.im/rubocop-rspec/Lobby)
4-
[![Gem Version](https://badge.fury.io/rb/rubocop-rspec.svg)](https://rubygems.org/gems/rubocop-rspec)
5-
![CI](https://github.com/rubocop/rubocop-rspec/workflows/CI/badge.svg)
4+
[![Gem Version](https://badge.fury.io/rb/rubocop-rspec_rails.svg)](https://rubygems.org/gems/rubocop-rspec_rails)
5+
![CI](https://github.com/rubocop/rubocop-rspec_rails/workflows/CI/badge.svg)
66

7-
[RSpec](https://rspec.info/)-specific analysis for your projects, as an extension to
7+
[RSpec Rails](https://rspec.info/)-specific analysis for your projects, as an extension to
88
[RuboCop](https://github.com/rubocop/rubocop).
99

1010
## Installation
1111

12-
Just install the `rubocop-rspec` gem
12+
Just install the `rubocop-rspec_rails` gem
1313

1414
```bash
15-
gem install rubocop-rspec
15+
gem install rubocop-rspec_rails
1616
```
1717

1818
or if you use bundler put this in your `Gemfile`
1919

2020
```ruby
21-
gem 'rubocop-rspec', require: false
21+
gem 'rubocop-rspec_rails', require: false
2222
```
2323

24-
### Upgrading to RuboCop RSpec v2.x
25-
26-
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.
27-
2824
## Usage
2925

30-
You need to tell RuboCop to load the RSpec extension. There are three
26+
You need to tell RuboCop to load the RSpec Rails extension. There are three
3127
ways to do this:
3228

3329
### RuboCop configuration file
3430

3531
Put this into your `.rubocop.yml`.
3632

3733
```yaml
38-
require: rubocop-rspec
34+
require: rubocop-rspec_rails
3935
```
4036
4137
Alternatively, use the following array notation when specifying multiple extensions.
4238
4339
```yaml
4440
require:
45-
- rubocop-other-extension
4641
- rubocop-rspec
42+
- rubocop-rspec_rails
4743
```
4844
49-
Now you can run `rubocop` and it will automatically load the RuboCop RSpec
45+
Now you can run `rubocop` and it will automatically load the RuboCop RSpec Rails
5046
cops together with the standard cops.
5147

5248
### Command line
5349

5450
```bash
55-
rubocop --require rubocop-rspec
51+
rubocop --require rubocop-rspec_rails
5652
```
5753

5854
### Rake task
5955

6056
```ruby
6157
RuboCop::RakeTask.new do |task|
62-
task.requires << 'rubocop-rspec'
58+
task.requires << 'rubocop-rspec_rails'
6359
end
6460
```
6561

66-
### Code Climate
67-
68-
rubocop-rspec is available on Code Climate as part of the rubocop engine. [Learn More](https://marketing.codeclimate.com/changelog/55a433bbe30ba00852000fac/).
69-
7062
## Documentation
7163

72-
You can read more about RuboCop RSpec in its [official manual](https://docs.rubocop.org/rubocop-rspec).
64+
You can read more about RuboCop RSpec Rails in its [official manual](https://docs.rubocop.org/rubocop-rspec_rails).
7365

7466
## The Cops
7567

7668
All cops are located under
77-
[`lib/rubocop/cop/rspec`](lib/rubocop/cop/rspec), and contain
69+
[`lib/rubocop/cop/rspec_rails`](lib/rubocop/cop/rspec_rails), and contain
7870
examples/documentation.
7971

80-
In your `.rubocop.yml`, you may treat the RSpec cops just like any other
72+
In your `.rubocop.yml`, you may treat the RSpec Rails cops just like any other
8173
cop. For example:
8274

8375
```yaml
84-
RSpec/FilePath:
76+
RSpecRails/AvoidSetupHook:
8577
Exclude:
8678
- spec/my_poorly_named_spec_file.rb
8779
```
@@ -92,5 +84,5 @@ Checkout the [contribution guidelines](.github/CONTRIBUTING.md).
9284

9385
## License
9486

95-
`rubocop-rspec` is MIT licensed. [See the accompanying file](MIT-LICENSE.md) for
87+
`rubocop-rspec_rails` is MIT licensed. [See the accompanying file](MIT-LICENSE.md) for
9688
the full text.

Rakefile

+15-16
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,18 @@ desc 'Build config/default.yml'
2929
task :build_config do
3030
require 'yard'
3131

32-
require 'rubocop-rspec'
33-
require 'rubocop/rspec/config_formatter'
34-
require 'rubocop/rspec/description_extractor'
35-
36-
glob = File.join('lib', 'rubocop', 'cop', 'rspec',
37-
'{,capybara,factory_bot,rails}', '*.rb')
38-
# Due to YARD's sensitivity to file require order (as of 0.9.25),
39-
# we have to prepend the list with our base cop, RuboCop::Cop::RSpec::Base.
40-
# Otherwise, cop's parent class for cops loaded before our base cop class
41-
# are detected as RuboCop::Cop::Base, and that complicates the detection
42-
# of their relation with RuboCop RSpec.
43-
rspec_cop_path = File.join('lib', 'rubocop', 'cop', 'rspec', 'base.rb')
32+
require 'rubocop-rspec_rails'
33+
require 'rubocop/rspec_rails/config_formatter'
34+
require 'rubocop/rspec_rails/description_extractor'
35+
36+
glob = File.join('lib', 'rubocop', 'cop', 'rspec_rails', '*.rb')
4437
YARD::Tags::Library.define_tag('Cop Safety Information', :safety)
45-
YARD.parse(Dir[glob].prepend(rspec_cop_path), [])
38+
YARD.parse(Dir[glob], [])
4639

4740
descriptions =
48-
RuboCop::RSpec::DescriptionExtractor.new(YARD::Registry.all(:class)).to_h
41+
RuboCop::RSpecRails::DescriptionExtractor.new(
42+
YARD::Registry.all(:class)
43+
).to_h
4944
current_config = if Psych::VERSION >= '4.0.0' # RUBY_VERSION >= '3.1.0'
5045
YAML.unsafe_load_file('config/default.yml')
5146
else
@@ -54,7 +49,9 @@ task :build_config do
5449

5550
File.write(
5651
'config/default.yml',
57-
RuboCop::RSpec::ConfigFormatter.new(current_config, descriptions).dump
52+
RuboCop::RSpecRails::ConfigFormatter.new(
53+
current_config, descriptions
54+
).dump
5855
)
5956
end
6057

@@ -100,7 +97,9 @@ task :new_cop, [:cop] do |_task, args|
10097
generator = RuboCop::Cop::Generator.new(cop_name)
10198
generator.write_source
10299
generator.write_spec
103-
generator.inject_require(root_file_path: 'lib/rubocop/cop/rspec_cops.rb')
100+
generator.inject_require(
101+
root_file_path: 'lib/rubocop/cop/rspec_rails_cops.rb'
102+
)
104103
generator.inject_config
105104

106105
puts generator.todo

0 commit comments

Comments
 (0)