diff --git a/config/default.yml b/config/default.yml index a8c35fb..1a362fe 100644 --- a/config/default.yml +++ b/config/default.yml @@ -7,13 +7,13 @@ RSpecRails: - "**/spec/**/*" RSpecRails/AvoidSetupHook: - Description: Checks that tests use RSpec `before` hook over Rails `setup` method. + Description: Prefer RSpec `before` hook over Rails `setup` method. Enabled: pending VersionAdded: '2.4' Reference: https://www.rubydoc.info/gems/rubocop-rspec_rails/RuboCop/Cop/RSpecRails/AvoidSetupHook RSpecRails/HaveHttpStatus: - Description: Checks that tests use `have_http_status` instead of equality matchers. + Description: Prefer `have_http_status` over equality matchers. Enabled: pending ResponseMethods: - response @@ -24,7 +24,7 @@ RSpecRails/HaveHttpStatus: Reference: https://www.rubydoc.info/gems/rubocop-rspec_rails/RuboCop/Cop/RSpecRails/HaveHttpStatus RSpecRails/HttpStatus: - Description: Enforces use of symbolic or numeric value to describe HTTP status. + Description: Enforce use of symbolic or numeric value to describe HTTP status. Enabled: true EnforcedStyle: symbolic SupportedStyles: @@ -36,13 +36,13 @@ RSpecRails/HttpStatus: Reference: https://www.rubydoc.info/gems/rubocop-rspec_rails/RuboCop/Cop/RSpecRails/HttpStatus RSpecRails/HttpStatusNameConsistency: - Description: Enforces consistency by using the current HTTP status names. + Description: Enforce consistency by using the current HTTP status names. Enabled: pending VersionAdded: '2.32' Reference: https://www.rubydoc.info/gems/rubocop-rspec_rails/RuboCop/Cop/RSpecRails/HttpStatusNameConsistency RSpecRails/InferredSpecType: - Description: Identifies redundant spec type. + Description: Identify redundant spec type. Enabled: pending Safe: false VersionAdded: '2.14' @@ -65,13 +65,13 @@ RSpecRails/InferredSpecType: views: view RSpecRails/MinitestAssertions: - Description: Check if using Minitest-like matchers. + Description: Prefer RSpec/Rails-style matchers over Minitest-like matchers. Enabled: pending VersionAdded: '2.17' Reference: https://www.rubydoc.info/gems/rubocop-rspec_rails/RuboCop/Cop/RSpecRails/MinitestAssertions RSpecRails/NegationBeValid: - Description: Enforces use of `be_invalid` or `not_to` for negated be_valid. + Description: Enforce use of `be_invalid` or `not_to` for negated be_valid. AutoCorrect: contextual Safe: false EnforcedStyle: not_to diff --git a/docs/modules/ROOT/pages/cops_rspecrails.adoc b/docs/modules/ROOT/pages/cops_rspecrails.adoc index 6595465..1ae6dc7 100644 --- a/docs/modules/ROOT/pages/cops_rspecrails.adoc +++ b/docs/modules/ROOT/pages/cops_rspecrails.adoc @@ -19,7 +19,7 @@ | - |=== -Checks that tests use RSpec `before` hook over Rails `setup` method. +Prefer RSpec `before` hook over Rails `setup` method. [#examples-rspecrailsavoidsetuphook] === Examples @@ -55,13 +55,13 @@ end | 2.27 |=== -Checks that tests use `have_http_status` instead of equality matchers. +Prefer `have_http_status` over equality matchers. [#examples-rspecrailshavehttpstatus] === Examples -[#responsemethods_-__response__-_last_response__-_default_-rspecrailshavehttpstatus] -==== ResponseMethods: ['response', 'last_response'] (default) +[#_responsemethods_-__response__-_last_response___-_default_-rspecrailshavehttpstatus] +==== `ResponseMethods: ['response', 'last_response']` (default) [source,ruby] ---- @@ -74,8 +74,8 @@ expect(response).to have_http_status(200) expect(last_response).to have_http_status(200) ---- -[#responsemethods_-__foo_response__-rspecrailshavehttpstatus] -==== ResponseMethods: ['foo_response'] +[#_responsemethods_-__foo_response___-rspecrailshavehttpstatus] +==== `ResponseMethods: ['foo_response']` [source,ruby] ---- @@ -119,7 +119,7 @@ expect(last_response).to have_http_status(200) | 2.20 |=== -Enforces use of symbolic or numeric value to describe HTTP status. +Enforce use of symbolic or numeric value to describe HTTP status. This cop inspects only `have_http_status` calls. So, this cop does not check if a method starting with `be_*` is used @@ -224,7 +224,7 @@ it { is_expected.to have_http_status :ok } | - |=== -Enforces consistency by using the current HTTP status names. +Enforce consistency by using the current HTTP status names. [#examples-rspecrailshttpstatusnameconsistency] === Examples @@ -256,7 +256,7 @@ it { is_expected.to have_http_status :unprocessable_content } | - |=== -Identifies redundant spec type. +Identify redundant spec type. After setting up rspec-rails, you will have enabled `config.infer_spec_type_from_file_location!` by default in @@ -290,16 +290,11 @@ RSpec.describe User, type: :common do end ---- -[#_inferences_-configuration-rspecrailsinferredspectype] -==== `Inferences` configuration +[#_inferences_-_services_-service__-rspecrailsinferredspectype] +==== `Inferences: {services: service}` [source,ruby] ---- -# .rubocop.yml -# RSpecRails/InferredSpecType: -# Inferences: -# services: service - # bad # spec/services/user_spec.rb RSpec.describe User, type: :service do @@ -345,10 +340,10 @@ end | - |=== -Check if using Minitest-like matchers. +Prefer RSpec/Rails-style matchers over Minitest-like matchers. -Check the use of minitest-like matchers -starting with `assert_` or `refute_`. +Detect the use of Minitest-like matchers +(those starting with `assert_` or `refute_`). [#examples-rspecrailsminitestassertions] === Examples @@ -396,7 +391,7 @@ expect(response).to have_http_status(:ok) | 2.29 |=== -Enforces use of `be_invalid` or `not_to` for negated be_valid. +Enforce use of `be_invalid` or `not_to` for negated be_valid. [#safety-rspecrailsnegationbevalid] === Safety @@ -407,8 +402,8 @@ the test target is an instance of `ActiveModel::Validations``. [#examples-rspecrailsnegationbevalid] === Examples -[#enforcedstyle_-not_to-_default_-rspecrailsnegationbevalid] -==== EnforcedStyle: not_to (default) +[#_enforcedstyle_-not_to_-_default_-rspecrailsnegationbevalid] +==== `EnforcedStyle: not_to` (default) [source,ruby] ---- @@ -422,8 +417,8 @@ expect(foo).not_to be_valid expect(foo).to be_invalid.and be_odd ---- -[#enforcedstyle_-be_invalid-rspecrailsnegationbevalid] -==== EnforcedStyle: be_invalid +[#_enforcedstyle_-be_invalid_-rspecrailsnegationbevalid] +==== `EnforcedStyle: be_invalid` [source,ruby] ---- diff --git a/lib/rubocop/cop/rspec_rails/avoid_setup_hook.rb b/lib/rubocop/cop/rspec_rails/avoid_setup_hook.rb index fdb446d..4435b4f 100644 --- a/lib/rubocop/cop/rspec_rails/avoid_setup_hook.rb +++ b/lib/rubocop/cop/rspec_rails/avoid_setup_hook.rb @@ -3,7 +3,7 @@ module RuboCop module Cop module RSpecRails - # Checks that tests use RSpec `before` hook over Rails `setup` method. + # Prefer RSpec `before` hook over Rails `setup` method. # # @example # # bad diff --git a/lib/rubocop/cop/rspec_rails/have_http_status.rb b/lib/rubocop/cop/rspec_rails/have_http_status.rb index 71bd168..4d0ee6a 100644 --- a/lib/rubocop/cop/rspec_rails/have_http_status.rb +++ b/lib/rubocop/cop/rspec_rails/have_http_status.rb @@ -3,9 +3,9 @@ module RuboCop module Cop module RSpecRails - # Checks that tests use `have_http_status` instead of equality matchers. + # Prefer `have_http_status` over equality matchers. # - # @example ResponseMethods: ['response', 'last_response'] (default) + # @example `ResponseMethods: ['response', 'last_response']` (default) # # bad # expect(response.status).to be(200) # expect(last_response.code).to eq("200") @@ -14,7 +14,7 @@ module RSpecRails # expect(response).to have_http_status(200) # expect(last_response).to have_http_status(200) # - # @example ResponseMethods: ['foo_response'] + # @example `ResponseMethods: ['foo_response']` # # bad # expect(foo_response.status).to be(200) # diff --git a/lib/rubocop/cop/rspec_rails/http_status.rb b/lib/rubocop/cop/rspec_rails/http_status.rb index 148f7be..9dca08d 100644 --- a/lib/rubocop/cop/rspec_rails/http_status.rb +++ b/lib/rubocop/cop/rspec_rails/http_status.rb @@ -9,7 +9,7 @@ module RuboCop module Cop module RSpecRails - # Enforces use of symbolic or numeric value to describe HTTP status. + # Enforce use of symbolic or numeric value to describe HTTP status. # # This cop inspects only `have_http_status` calls. # So, this cop does not check if a method starting with `be_*` is used diff --git a/lib/rubocop/cop/rspec_rails/http_status_name_consistency.rb b/lib/rubocop/cop/rspec_rails/http_status_name_consistency.rb index b5cad2e..10a6248 100644 --- a/lib/rubocop/cop/rspec_rails/http_status_name_consistency.rb +++ b/lib/rubocop/cop/rspec_rails/http_status_name_consistency.rb @@ -3,7 +3,7 @@ module RuboCop module Cop module RSpecRails - # Enforces consistency by using the current HTTP status names. + # Enforce consistency by using the current HTTP status names. # # @example # diff --git a/lib/rubocop/cop/rspec_rails/inferred_spec_type.rb b/lib/rubocop/cop/rspec_rails/inferred_spec_type.rb index d21f9e1..e4e531e 100644 --- a/lib/rubocop/cop/rspec_rails/inferred_spec_type.rb +++ b/lib/rubocop/cop/rspec_rails/inferred_spec_type.rb @@ -3,7 +3,7 @@ module RuboCop module Cop module RSpecRails - # Identifies redundant spec type. + # Identify redundant spec type. # # After setting up rspec-rails, you will have enabled # `config.infer_spec_type_from_file_location!` by default in @@ -30,12 +30,7 @@ module RSpecRails # RSpec.describe User, type: :common do # end # - # @example `Inferences` configuration - # # .rubocop.yml - # # RSpecRails/InferredSpecType: - # # Inferences: - # # services: service - # + # @example `Inferences: {services: service}` # # bad # # spec/services/user_spec.rb # RSpec.describe User, type: :service do diff --git a/lib/rubocop/cop/rspec_rails/minitest_assertions.rb b/lib/rubocop/cop/rspec_rails/minitest_assertions.rb index 88975dd..cb08d2f 100644 --- a/lib/rubocop/cop/rspec_rails/minitest_assertions.rb +++ b/lib/rubocop/cop/rspec_rails/minitest_assertions.rb @@ -3,10 +3,10 @@ module RuboCop module Cop module RSpecRails - # Check if using Minitest-like matchers. + # Prefer RSpec/Rails-style matchers over Minitest-like matchers. # - # Check the use of minitest-like matchers - # starting with `assert_` or `refute_`. + # Detect the use of Minitest-like matchers + # (those starting with `assert_` or `refute_`). # # @example # # bad diff --git a/lib/rubocop/cop/rspec_rails/negation_be_valid.rb b/lib/rubocop/cop/rspec_rails/negation_be_valid.rb index c57b228..5ee911c 100644 --- a/lib/rubocop/cop/rspec_rails/negation_be_valid.rb +++ b/lib/rubocop/cop/rspec_rails/negation_be_valid.rb @@ -3,13 +3,13 @@ module RuboCop module Cop module RSpecRails - # Enforces use of `be_invalid` or `not_to` for negated be_valid. + # Enforce use of `be_invalid` or `not_to` for negated be_valid. # # @safety # This cop is unsafe because it cannot guarantee that # the test target is an instance of `ActiveModel::Validations``. # - # @example EnforcedStyle: not_to (default) + # @example `EnforcedStyle: not_to` (default) # # bad # expect(foo).to be_invalid # @@ -19,7 +19,7 @@ module RSpecRails # # good (with method chain) # expect(foo).to be_invalid.and be_odd # - # @example EnforcedStyle: be_invalid + # @example `EnforcedStyle: be_invalid` # # bad # expect(foo).not_to be_valid #