Skip to content

Commit

Permalink
Rename Rails department to RSpecRails
Browse files Browse the repository at this point in the history
Resolves: rubocop#611
  • Loading branch information
ixti committed Oct 27, 2019
1 parent 6049c9a commit fb1252e
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 16 deletions.
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,7 @@ RSpec/ExampleLength:
RSpec/DescribeClass:
Exclude:
- spec/project/**/*.rb

RSpec/FilePath:
Exclude:
- spec/rubocop/cop/rspec/rspec_rails/**/*.rb
2 changes: 1 addition & 1 deletion bin/build_config
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require 'rubocop/rspec/description_extractor'
require 'rubocop/rspec/config_formatter'

glob = File.join(__dir__, '..', 'lib', 'rubocop', 'cop', 'rspec',
'{,capybara,factory_bot,rails}', '*.rb')
'{,capybara,factory_bot,rspec_rails}', '*.rb')
YARD.parse(Dir[glob], [])

descriptions = RuboCop::RSpec::DescriptionExtractor.new(YARD::Registry.all).to_h
Expand Down
4 changes: 2 additions & 2 deletions config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -474,11 +474,11 @@ FactoryBot/CreateList:
- n_times
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/FactoryBot/CreateList

Rails/HttpStatus:
RSpecRails/HttpStatus:
Description: Enforces use of symbolic or numeric value to describe HTTP status.
Enabled: true
EnforcedStyle: symbolic
SupportedStyles:
- numeric
- symbolic
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Rails/HttpStatus
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/RSpecRails/HttpStatus
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
module RuboCop
module Cop
module RSpec
module Rails
module RSpecRails
# Enforces use of symbolic or numeric value to describe HTTP status.
#
# @example `EnforcedStyle: symbolic` (default)
Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop/cop/rspec_cops.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
require_relative 'rspec/factory_bot/create_list'

begin
require_relative 'rspec/rails/http_status'
require_relative 'rspec/rspec_rails/http_status'
rescue LoadError # rubocop:disable Lint/HandleExceptions
# Rails/HttpStatus cannot be loaded if rack/utils is unavailable.
# RSpecRails/HttpStatus cannot be loaded if rack/utils is unavailable.
end

require_relative 'rspec/align_left_let_brace'
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/rspec/config_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module RuboCop
module RSpec
# Builds a YAML config file from two config hashes
class ConfigFormatter
NAMESPACES = /^(RSpec|Capybara|FactoryBot|Rails)/.freeze
NAMESPACES = /^(RSpec|Capybara|FactoryBot|RSpecRails)/.freeze
STYLE_GUIDE_BASE_URL = 'https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/'

def initialize(config, descriptions)
Expand Down
4 changes: 2 additions & 2 deletions manual/cops.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@
* [RSpec/VoidExpect](cops_rspec.md#rspecvoidexpect)
* [RSpec/Yield](cops_rspec.md#rspecyield)

#### Department [Rails](cops_rails.md)
#### Department [RSpecRails](cops_rspecrails.md)

* [Rails/HttpStatus](cops_rails.md#railshttpstatus)
* [RSpecRails/HttpStatus](cops_rspecrails.md#rspecrailshttpstatus)

<!-- END_COP_LIST -->
6 changes: 3 additions & 3 deletions manual/cops_rails.md → manual/cops_rspecrails.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Rails
# RSpecRails

## Rails/HttpStatus
## RSpecRails/HttpStatus

Enabled by default | Supports autocorrection
--- | ---
Expand Down Expand Up @@ -45,4 +45,4 @@ EnforcedStyle | `symbolic` | `numeric`, `symbolic`

### References

* [https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Rails/HttpStatus](https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Rails/HttpStatus)
* [https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/RSpecRails/HttpStatus](https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/RSpecRails/HttpStatus)
6 changes: 3 additions & 3 deletions spec/project/default_config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
'rspec' => 'RSpec',
'capybara' => 'Capybara',
'factory_bot' => 'FactoryBot',
'rails' => 'Rails'
'rspec_rails' => 'RSpecRails'
}
end

let(:cop_names) do
glob = SpecHelper::ROOT.join('lib', 'rubocop', 'cop', 'rspec',
'{,capybara,factory_bot,rails}', '*.rb')
'{,capybara,factory_bot,rspec_rails}', '*.rb')
cop_names =
Pathname.glob(glob).map do |file|
file_name = file.basename('.rb').to_s
Expand Down Expand Up @@ -47,7 +47,7 @@ def cop_configuration(config_key)
end

it 'sorts configuration keys alphabetically' do
namespaces.each do |_path, prefix|
namespaces.each_value do |prefix|
expected = config_keys.select { |key| key.start_with?(prefix) }.sort
actual = default_config.keys.select { |key| key.start_with?(prefix) }
actual.each_with_index do |key, idx|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

RSpec.describe RuboCop::Cop::RSpec::Rails::HttpStatus, :config do
RSpec.describe RuboCop::Cop::RSpec::RSpecRails::HttpStatus, :config do
subject(:cop) { described_class.new(config) }

context 'when EnforcedStyle is `symbolic`' do
Expand Down

0 comments on commit fb1252e

Please sign in to comment.