diff --git a/.rubocop.yml b/.rubocop.yml index 95832a486..bffff3303 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,7 +1,10 @@ inherit_from: + - .rubocop_rspec_base.yml - .rubocop_todo.yml AllCops: + TargetRubyVersion: 2.5 + NewCops: disable Exclude: # Templates are really ERB which Rubocop does not parse - bin/**/* @@ -9,6 +12,18 @@ AllCops: - lib/generators/rspec/*/templates/**/* - tmp/**/* +# Over time we'd like to get this down, but this is what we're at now. +Metrics/CyclomaticComplexity: + Max: 10 # default: 6 + +# Over time we'd like to get this down, but this is what we're at now. +Layout/LineLength: + Max: 186 # default: 80 + +# Over time we'd like to get this down, but this is what we're at now. +Metrics/MethodLength: + Max: 43 # default: 10 + Bundler/DuplicatedGem: Enabled: false @@ -17,403 +32,31 @@ Gemspec/RequiredRubyVersion: # but doesnt have a 2.2 option Enabled: false -Layout/AccessModifierIndentation: - Enabled: false - -Layout/AssignmentIndentation: - Enabled: false - -Layout/BlockAlignment: - EnforcedStyleAlignWith: start_of_block - -Layout/ClosingParenthesisIndentation: - Enabled: false - -Layout/EmptyLineAfterMagicComment: - Enabled: false - -Layout/EmptyLineBetweenDefs: - Enabled: false - -Layout/EmptyLinesAroundAccessModifier: - Enabled: false - -Layout/EmptyLinesAroundBlockBody: - Enabled: false - -Layout/ExtraSpacing: - Enabled: false - -Layout/FirstArgumentIndentation: - Enabled: false - -Layout/FirstArrayElementIndentation: - Enabled: false - -Layout/HashAlignment: - Enabled: false - -Layout/HeredocIndentation: - Enabled: false - -Layout/MultilineMethodCallBraceLayout: - Enabled: false - -Layout/MultilineMethodCallIndentation: - Enabled: false - -Layout/MultilineOperationIndentation: - Enabled: false - -Layout/ParameterAlignment: - EnforcedStyle: with_first_parameter - -Layout/SpaceInsideHashLiteralBraces: - EnforcedStyle: no_space - EnforcedStyleForEmptyBraces: no_space - -Layout/SpaceInsidePercentLiteralDelimiters: - Enabled: false - -# We use spaces, so it's less of a change to stick with that. -Layout/SpaceAroundEqualsInParameterDefault: - EnforcedStyle: space - -Layout/SpaceInsideBlockBraces: - EnforcedStyleForEmptyBraces: space - -Layout/SpaceAroundBlockParameters: - Enabled: false - -Layout/SpaceAroundOperators: - Enabled: false - -Layout/SpaceBeforeComma: - Enabled: false - -Layout/SpaceInsideStringInterpolation: - Enabled: false - -Lint/AmbiguousBlockAssociation: - Exclude: - - spec/**/* - -Lint/AmbiguousOperator: +Metrics/BlockLength: Exclude: - Rakefile + - example_app_generator/generate_app.rb + - example_app_generator/spec/**/* + - lib/rspec/rails/configuration.rb + - lib/rspec/rails/example/system_example_group.rb + - lib/rspec/rails/tasks/rspec.rake + - rspec-rails.gemspec + - spec/**/* -Lint/AmbiguousRegexpLiteral: - Exclude: - - features/step_definitions/additional_cli_steps.rb - -Lint/AssignmentInCondition: - Enabled: false - -Lint/DuplicateMethods: - Exclude: - - example_app_generator/no_active_record/app/models/in_memory/model.rb - -Lint/NonDeterministicRequireOrder: - Exclude: - - spec/spec_helper.rb - -Lint/EmptyExpression: - Enabled: false - -Lint/ImplicitStringConcatenation: - Enabled: false - -Lint/NestedMethodDefinition: - Enabled: false - -# Exceptions should be rescued with `Support::AllExceptionsExceptOnesWeMustNotRescue` -Lint/RescueException: - Enabled: true - -Lint/SuppressedException: - Exclude: - # RSpec is tightly coupled to capybara right now, this should be - # re-evaluted in the future. For now we allow the empty rescue - - lib/rspec/rails/vendor/capybara.rb - - example_app_generator/generate_stuff.rb - - example_app_generator/spec/support/default_preview_path - -Metrics/AbcSize: - Enabled: false - -Metrics/BlockLength: - Enabled: false - -# Warns when the class is excessively long. -Metrics/ClassLength: - Max: 100 - -Metrics/PerceivedComplexity: - Enabled: false - +# Offense count: 3 +# Configuration parameters: CountComments, CountAsOne. Metrics/ModuleLength: Exclude: - spec/**/* -Metrics/ParameterLists: - Exclude: - - example_app_generator/spec/verify_custom_renderers_spec.rb - -# Who cares what we call the argument for binary operator methods? -Naming/BinaryOperatorParameterName: - Enabled: false - -Naming/ConstantName: - Enabled: false - -Naming/FileName: - Exclude: - # We break convention here so that when bundler requires the gem, which - # uses the gem name, things work without user configuration. - - lib/rspec-rails.rb - -Naming/HeredocDelimiterNaming: - Enabled: false - -Naming/MemoizedInstanceVariableName: - Enabled: false - -Naming/MethodParameterName: - Enabled: false - -# We have too many special cases where we allow generator methods or prefer a -# prefixed predicate due to it's improved readability. -Naming/PredicateName: - Enabled: false - -Naming/RescuedExceptionsVariableName: - Enabled: false - -Naming/VariableNumber: - Enabled: false - -Style/CollectionMethods: - PreferredMethods: - reduce: 'inject' - -Style/AccessModifierDeclarations: - Enabled: false - -# "Use alias_method instead of alias" -# We're fine with `alias`. -Style/Alias: - Enabled: false - -Style/BlockDelimiters: - Enabled: false - -# "Avoid the use of the case equality operator ===" -# We prefer using `Class#===` over `Object#is_a?` because `Class#===` -# is less likely to be monkey patched than `is_a?` on a user object. -Style/CaseEquality: - Enabled: false - -Style/ClassAndModuleChildren: - Enabled: false - -Style/ClassCheck: - Enabled: false - -Style/CommentedKeyword: - Exclude: - - spec/rspec/rails/example/view_example_group_spec.rb - -Style/ConditionalAssignment: - Enabled: false - -Style/DateTime: - Enabled: false - -# We use YARD to enforce documentation. It works better than rubocop's -# enforcement...rubocop complains about the places we re-open -# `RSpec::Expectations` and `RSpec::Matchers` w/o having doc commments. -Style/Documentation: - Enabled: false - -Style/DoubleNegation: - Enabled: false - -Style/EmptyMethod: - Enabled: false - -Style/EmptyCaseCondition: - Enabled: false - -Style/EmptyElse: - Enabled: false - -Style/FormatString: - EnforcedStyle: percent - -Style/FormatStringToken: - Enabled: false - -Style/FrozenStringLiteralComment: - Enabled: false - -Style/GlobalVars: - Exclude: - - spec/support/shared_examples.rb - -Style/GuardClause: - Enabled: false +# Override the shared base defaults that are in place for 1.8.7 support -Style/HashEachMethods: - Enabled: true +Layout/DotPosition: + EnforcedStyle: leading -Style/HashTransformKeys: - Enabled: true +Style/HashSyntax: + EnforcedStyle: ruby19 -Style/HashTransformValues: +Style/Lambda: Enabled: true -Style/IdenticalConditionalBranches: - Enabled: false - -Style/IfUnlessModifierOfIfUnless: - Enabled: false - -Style/IfInsideElse: - Enabled: false - -Style/IfUnlessModifier: - Enabled: false - -Style/MethodMissingSuper: - Enabled: false - -Style/MissingRespondToMissing: - Enabled: false - -Style/MixinUsage: - Enabled: false - -Style/MultilineIfModifier: - Enabled: false - -Style/MultipleComparison: - Enabled: false - -Style/MutableConstant: - Enabled: false - -Style/NestedModifier: - Enabled: false - -Style/NestedParenthesizedCalls: - Enabled: false - -Style/NumericLiterals: - Exclude: - - spec/rspec/rails/matchers/action_cable/have_stream_spec.rb - -Style/NumericLiteralPrefix: - EnforcedOctalStyle: zero_only - -Style/NumericPredicate: - Enabled: false - -Style/ParallelAssignment: - Enabled: false - -Style/ParenthesesAroundCondition: - Enabled: false - -Style/PercentLiteralDelimiters: - PreferredDelimiters: - '%': () # double-quoted string - '%i': '[]' # array of symbols - '%q': () # single-quoted string - '%Q': () # double-quoted string - '%r': '{}' # regular expression pattern - '%s': () # a symbol - '%w': '[]' # array of single-quoted strings - '%W': '[]' # array of double-quoted strings - '%x': () # a shell command as a string - -Style/RaiseArgs: - Exclude: - - spec/rspec/rails/matchers/be_routable_spec.rb - - spec/rspec/rails/matchers/have_rendered_spec.rb - - spec/rspec/rails/matchers/redirect_to_spec.rb - - spec/rspec/rails/matchers/route_to_spec.rb - -Style/RegexpLiteral: - Enabled: false - -Style/RedundantReturn: - Enabled: false - -Style/RedundantParentheses: - Enabled: false - -Style/RescueStandardError: - Enabled: false - -# We haven't adopted the `fail` to signal exceptions vs `raise` for re-raises convention. -Style/SignalException: - Enabled: false - -Style/SingleLineMethods: - Exclude: - - spec/rspec/rails/example/controller_example_group_spec.rb - - spec/rspec/rails/matchers/active_job_spec.rb - - spec/rspec/rails/matchers/be_a_new_spec.rb - - spec/rspec/rails/matchers/has_spec.rb - - spec/rspec/rails/matchers/have_enqueued_mail_spec.rb - - spec/rspec/rails/matchers/have_rendered_spec.rb - - spec/rspec/rails/setup_and_teardown_adapter_spec.rb - -# This rule favors constant names from the English standard library which we don't load. -Style/SpecialGlobalVars: - Enabled: false - -Style/StderrPuts: - Enabled: false - -Style/StringLiteralsInInterpolation: - Enabled: false - -Style/StructInheritance: - Enabled: false - -# We don't care about single vs double qoutes. -Style/StringLiterals: - Enabled: false - -Style/SymbolArray: - Enabled: false - -Style/SymbolProc: - Enabled: false - -Style/TernaryParentheses: - Enabled: false - -Style/TrailingCommaInArrayLiteral: - Enabled: false - -Style/TrailingCommaInHashLiteral: - Enabled: false - -Style/TrailingCommaInArguments: - Enabled: false - -Style/TrivialAccessors: - AllowDSLWriters: true - AllowPredicates: true - ExactNameMatch: true - -Style/TrailingUnderscoreVariable: - Enabled: false - -Style/YodaCondition: - Enabled: false - -Style/ZeroLengthPredicate: - Enabled: false diff --git a/.rubocop_rspec_base.yml b/.rubocop_rspec_base.yml new file mode 100644 index 000000000..b00eb6cea --- /dev/null +++ b/.rubocop_rspec_base.yml @@ -0,0 +1,316 @@ +# This file was generated on 2022-01-10T22:24:10+00:00 from the rspec-dev repo. +# DO NOT modify it by hand as your changes will get lost the next time it is generated. + +# This file contains defaults for RSpec projects. Individual projects +# can customize by inheriting this file and overriding particular settings. + +Layout/AccessModifierIndentation: + Enabled: false + +# "Use alias_method instead of alias" +# We're fine with `alias`. +Style/Alias: + Enabled: false + +# "Avoid the use of the case equality operator ===" +# We prefer using `Class#===` over `Object#is_a?` because `Class#===` +# is less likely to be monkey patched than `is_a?` on a user object. +Style/CaseEquality: + Enabled: false + +# Warns when the class is excessively long. +Metrics/ClassLength: + Max: 100 + +Style/CollectionMethods: + PreferredMethods: + reduce: 'inject' + +# Over time we'd like to get this down, but this is what we're at now. +Metrics/CyclomaticComplexity: + Max: 10 + +# We use YARD to enforce documentation. It works better than rubocop's +# enforcement...rubocop complains about the places we re-open +# `RSpec::Expectations` and `RSpec::Matchers` w/o having doc commments. +Style/Documentation: + Enabled: false + +# We still support 1.8.7 which requires trailing dots +Layout/DotPosition: + EnforcedStyle: trailing + +Style/DoubleNegation: + Enabled: false + +# each_with_object is unavailable on 1.8.7 so we have to disable this one. +Style/EachWithObject: + Enabled: false + +Style/FormatString: + EnforcedStyle: percent + +# As long as we support ruby 1.8.7 we have to use hash rockets. +Style/HashSyntax: + EnforcedStyle: hash_rockets + +# We can't use the new lambda syntax, since we still support 1.8.7. +Style/Lambda: + Enabled: false + +# Over time we'd like to get this down, but this is what we're at now. +Layout/LineLength: + Max: 100 + +# Over time we'd like to get this down, but this is what we're at now. +Metrics/MethodLength: + Max: 15 + +# Who cares what we call the argument for binary operator methods? +Naming/BinaryOperatorParameterName: + Enabled: false + +Style/PercentLiteralDelimiters: + PreferredDelimiters: + '%': () # double-quoted string + '%i': '[]' # array of symbols + '%q': () # single-quoted string + '%Q': () # double-quoted string + '%r': '{}' # regular expression pattern + '%s': () # a symbol + '%w': '[]' # array of single-quoted strings + '%W': '[]' # array of double-quoted strings + '%x': () # a shell command as a string + +# We have too many special cases where we allow generator methods or prefer a +# prefixed predicate due to it's improved readability. +Naming/PredicateName: + Enabled: false + +# On 1.8 `proc` is `lambda`, so we use `Proc.new` to ensure we get real procs on all supported versions. +# http://batsov.com/articles/2014/02/04/the-elements-of-style-in-ruby-number-12-proc-vs-proc-dot-new/ +Style/Proc: + Enabled: false + +# Exceptions should be rescued with `Support::AllExceptionsExceptOnesWeMustNotRescue` +Lint/RescueException: + Enabled: true + +# We haven't adopted the `fail` to signal exceptions vs `raise` for re-raises convention. +Style/SignalException: + Enabled: false + +# We've tended to use no space, so it's less of a change to stick with that. +Layout/SpaceAroundEqualsInParameterDefault: + EnforcedStyle: no_space + +# We don't care about single vs double qoutes. +Style/StringLiterals: + Enabled: false + +# This rule favors constant names from the English standard library which we don't load. +Style/SpecialGlobalVars: + Enabled: false + +Style/TrailingCommaInArrayLiteral: + Enabled: false + +Style/TrailingCommaInHashLiteral: + Enabled: false + +Style/TrailingCommaInArguments: + Enabled: false + +Style/TrivialAccessors: + AllowDSLWriters: true + AllowPredicates: true + ExactNameMatch: true + +Style/ParallelAssignment: + Enabled: false + +Layout/EmptyLineBetweenDefs: + Enabled: false + +Layout/FirstParameterIndentation: + Enabled: false + +Layout/ParameterAlignment: + EnforcedStyle: with_first_parameter + +Layout/SpaceInsideBlockBraces: + Enabled: false + +Layout/SpaceInsideParens: + Enabled: false + +Naming/ConstantName: + Enabled: false + +Style/ClassCheck: + Enabled: false + +Style/ConditionalAssignment: + Enabled: false + +Style/EmptyMethod: + Enabled: false + +Style/FormatStringToken: + Enabled: false + +Style/GuardClause: + Enabled: false + +Style/IdenticalConditionalBranches: + Enabled: false + +Style/IfUnlessModifier: + Enabled: false + +Style/IfUnlessModifierOfIfUnless: + Enabled: false + +Lint/MissingSuper: + Enabled: false + +Style/MissingRespondToMissing: + Enabled: false + +Style/MixinUsage: + Enabled: false + +Style/MultipleComparison: + Enabled: false + +Style/MutableConstant: + Enabled: false + +Style/NestedModifier: + Enabled: false + +Style/NestedParenthesizedCalls: + Enabled: false + +Style/NumericPredicate: + Enabled: false + +Style/RedundantParentheses: + Enabled: false + +Style/StringLiteralsInInterpolation: + Enabled: false + +Style/SymbolArray: + Enabled: false + +Style/SymbolProc: + Enabled: false + +Style/YodaCondition: + Enabled: false + +Style/ZeroLengthPredicate: + Enabled: false + +Layout/ClosingParenthesisIndentation: + Enabled: false + +Layout/ExtraSpacing: + Enabled: false + +Layout/MultilineMethodCallBraceLayout: + Enabled: false + +Layout/MultilineMethodCallIndentation: + Enabled: false + +Layout/MultilineOperationIndentation: + Enabled: false + +Layout/SpaceAroundBlockParameters: + Enabled: false + +Layout/SpaceAroundOperators: + Enabled: false + +Layout/SpaceBeforeComma: + Enabled: false + +Style/BlockDelimiters: + Enabled: false + +Style/EmptyCaseCondition: + Enabled: false + +Style/MultilineIfModifier: + Enabled: false + +Style/RescueStandardError: + Enabled: false + +Style/StderrPuts: + Enabled: false + +Style/TernaryParentheses: + Enabled: false + +Naming/HeredocDelimiterNaming: + Enabled: false + +Layout/AssignmentIndentation: + Enabled: false + +Layout/EmptyLineAfterMagicComment: + Enabled: false + +Layout/FirstArrayElementIndentation: + Enabled: false + +Layout/HeredocIndentation: + Enabled: false + +Layout/SpaceInsidePercentLiteralDelimiters: + Enabled: false + +Style/EmptyElse: + Enabled: false + +Style/IfInsideElse: + Enabled: false + +Style/RedundantReturn: + Enabled: false + +Style/StructInheritance: + Enabled: false + +Naming/VariableNumber: + Enabled: false + +Layout/SpaceInsideStringInterpolation: + Enabled: false + +Style/DateTime: + Enabled: false + +Style/ParenthesesAroundCondition: + Enabled: false + +Layout/EmptyLinesAroundBlockBody: + Enabled: false + +Lint/ImplicitStringConcatenation: + Enabled: false + +Lint/NestedMethodDefinition: + Enabled: false + +Style/RegexpLiteral: + Enabled: false + +Style/TrailingUnderscoreVariable: + Enabled: false + +Layout/EmptyLinesAroundAccessModifier: + Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 8221da291..676799af6 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,11 +1,307 @@ -# Over time we'd like to get this down, but this is what we're at now. -Metrics/CyclomaticComplexity: - Max: 9 # default: 6 +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2022-07-26 21:27:23 UTC using RuboCop version 1.32.0. +# The point is for the user to remove these configuration records +# one by one as the offenses are removed from the code base. +# Note that changes in the inspected code, or installation of new +# versions of RuboCop, may require this file to be generated again. -# Over time we'd like to get this down, but this is what we're at now. -Layout/LineLength: - Max: 186 # default: 80 +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyleAlignWith, Severity. +# SupportedStylesAlignWith: start_of_line, begin +Layout/BeginEndAlignment: + Exclude: + - 'lib/generators/rspec/scaffold/scaffold_generator.rb' + - 'lib/rspec/rails/tasks/rspec.rake' -# Over time we'd like to get this down, but this is what we're at now. -Metrics/MethodLength: - Max: 43 # default: 10 +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowAliasSyntax, AllowedMethods. +# AllowedMethods: alias_method, public, protected, private +Layout/EmptyLinesAroundAttributeAccessor: + Exclude: + - 'lib/rspec/rails/adapters.rb' + - 'spec/rspec/rails/matchers/be_valid_spec.rb' + +# Offense count: 4 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. +# SupportedHashRocketStyles: key, separator, table +# SupportedColonStyles: key, separator, table +# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit +Layout/HashAlignment: + Exclude: + - 'rspec-rails.gemspec' + +# Offense count: 34 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: . +# SupportedStyles: space, no_space +Layout/SpaceAroundEqualsInParameterDefault: + EnforcedStyle: space + +# Offense count: 27 +# Configuration parameters: IgnoredMethods. +Lint/AmbiguousBlockAssociation: + Exclude: + - 'spec/rspec/rails/matchers/action_cable/have_broadcasted_to_spec.rb' + - 'spec/rspec/rails/matchers/active_job_spec.rb' + - 'spec/rspec/rails/matchers/be_a_new_spec.rb' + - 'spec/rspec/rails/matchers/have_enqueued_mail_spec.rb' + - 'spec/rspec/rails/setup_and_teardown_adapter_spec.rb' + - 'spec/rspec/rails/view_rendering_spec.rb' + - 'spec/rspec/rails/view_spec_methods_spec.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Lint/AmbiguousOperator: + Exclude: + - 'Rakefile' + +# Offense count: 5 +# This cop supports safe autocorrection (--autocorrect). +Lint/AmbiguousRegexpLiteral: + Exclude: + - 'features/step_definitions/additional_cli_steps.rb' + +# Offense count: 3 +# Configuration parameters: AllowSafeAssignment. +Lint/AssignmentInCondition: + Exclude: + - 'lib/rspec/rails/adapters.rb' + - 'lib/rspec/rails/tasks/rspec.rake' + +# Offense count: 15 +# Configuration parameters: AllowedMethods. +# AllowedMethods: enums +Lint/ConstantDefinitionInBlock: + Exclude: + - 'example_app_generator/spec/support/default_preview_path' + - 'example_app_generator/spec/verify_custom_renderers_spec.rb' + - 'example_app_generator/spec/verify_mailer_preview_path_spec.rb' + - 'spec/rspec/rails/example/helper_example_group_spec.rb' + - 'spec/rspec/rails/example/mailer_example_group_spec.rb' + - 'spec/rspec/rails/example/view_example_group_spec.rb' + - 'spec/rspec/rails/matchers/be_valid_spec.rb' + - 'spec/rspec/rails/view_rendering_spec.rb' + - 'spec/rspec/rails/view_spec_methods_spec.rb' + +# Offense count: 1 +Lint/DuplicateMethods: + Exclude: + - 'example_app_generator/no_active_record/app/models/in_memory/model.rb' + +# Offense count: 2 +Lint/EmptyExpression: + Exclude: + - 'lib/rspec/rails/adapters.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +Lint/NonDeterministicRequireOrder: + Exclude: + - 'spec/spec_helper.rb' + +# Offense count: 6 +# Configuration parameters: AllowComments, AllowNil. +Lint/SuppressedException: + Exclude: + - 'example_app_generator/generate_stuff.rb' + - 'example_app_generator/spec/support/default_preview_path' + - 'lib/rspec/rails/vendor/capybara.rb' + +# Offense count: 2 +# Configuration parameters: AllowedPatterns, IgnoredPatterns. +# AllowedPatterns: (?-mix:(exactly|at_least|at_most)\(\d+\)\.times) +Lint/UnreachableLoop: + Exclude: + - 'spec/rspec/rails/fixture_file_upload_support_spec.rb' + - 'spec/rspec/rails/fixture_support_spec.rb' + +# Offense count: 12 +# Configuration parameters: IgnoredMethods, CountRepeatedAttributes. +Metrics/AbcSize: + Max: 71 + +# Offense count: 2 +# Configuration parameters: CountKeywordArgs. +Metrics/ParameterLists: + MaxOptionalParameters: 5 + Max: 6 + +# Offense count: 3 +# Configuration parameters: IgnoredMethods. +Metrics/PerceivedComplexity: + Max: 15 + +# Offense count: 1 +# Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, CheckDefinitionPathHierarchyRoots, Regex, IgnoreExecutableScripts, AllowedAcronyms. +# CheckDefinitionPathHierarchyRoots: lib, spec, test, src +# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS +Naming/FileName: + Exclude: + - 'lib/rspec-rails.rb' + +# Offense count: 7 +# Configuration parameters: EnforcedStyleForLeadingUnderscores. +# SupportedStylesForLeadingUnderscores: disallowed, required, optional +Naming/MemoizedInstanceVariableName: + Exclude: + - 'example_app_generator/generate_stuff.rb' + - 'example_app_generator/no_active_record/app/models/in_memory/model.rb' + - 'lib/generators/rspec.rb' + - 'lib/rspec/rails/matchers/have_http_status.rb' + - 'spec/rspec/rails/matchers/action_cable/have_broadcasted_to_spec.rb' + - 'spec/rspec/rails/matchers/active_job_spec.rb' + +# Offense count: 6 +# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames. +# AllowedNames: at, by, db, id, in, io, ip, of, on, os, pp, to +Naming/MethodParameterName: + Exclude: + - 'benchmarks/before_block_capture_block_vs_yield.rb' + - 'lib/rspec/rails/example/routing_example_group.rb' + - 'spec/rspec/rails/example/controller_example_group_spec.rb' + +# Offense count: 4 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: PreferredName. +Naming/RescuedExceptionsVariableName: + Exclude: + - 'lib/rspec/rails/matchers/base_matcher.rb' + - 'lib/rspec/rails/matchers/have_http_status.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +Style/BisectedAttrAccessor: + Exclude: + - 'lib/rspec/rails/view_rendering.rb' + +# Offense count: 17 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: nested, compact +Style/ClassAndModuleChildren: + Enabled: false + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: Keywords, RequireColon. +# Keywords: TODO, FIXME, OPTIMIZE, HACK, REVIEW, NOTE +Style/CommentAnnotation: + Exclude: + - 'spec/rspec/rails/matchers/active_job_spec.rb' + +# Offense count: 5 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/CommentedKeyword: + Exclude: + - 'spec/rspec/rails/example/view_example_group_spec.rb' + +# Offense count: 6 +# This cop supports safe autocorrection (--autocorrect). +Style/ExplicitBlockArgument: + Exclude: + - 'benchmarks/before_block_capture_block_vs_yield.rb' + - 'features/support/env.rb' + - 'spec/sanity_check_spec.rb' + +# Offense count: 152 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: always, always_true, never +Style/FrozenStringLiteralComment: + Enabled: false + +# Offense count: 3 +# Configuration parameters: AllowedVariables. +Style/GlobalVars: + Exclude: + - 'spec/support/shared_examples.rb' + +# Offense count: 2 +# Configuration parameters: MinBranchesCount. +Style/HashLikeCase: + Exclude: + - 'lib/rspec/rails/matchers/action_cable/have_broadcasted_to.rb' + - 'lib/rspec/rails/matchers/active_job.rb' + +# Offense count: 4 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedOctalStyle. +# SupportedOctalStyles: zero_with_o, zero_only +Style/NumericLiteralPrefix: + Exclude: + - 'example_app_generator/generate_action_mailer_specs.rb' + - 'example_app_generator/generate_app.rb' + - 'spec/sanity_check_spec.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: Strict, AllowedNumbers. +Style/NumericLiterals: + MinDigits: 6 + +# Offense count: 2 +# Configuration parameters: AllowedMethods. +# AllowedMethods: respond_to_missing? +Style/OptionalBooleanParameter: + Exclude: + - 'example_app_generator/spec/verify_custom_renderers_spec.rb' + - 'lib/rspec/rails/view_rendering.rb' + +# Offense count: 12 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, AllowedCompactTypes. +# SupportedStyles: compact, exploded +Style/RaiseArgs: + Exclude: + - 'spec/rspec/rails/matchers/be_routable_spec.rb' + - 'spec/rspec/rails/matchers/have_rendered_spec.rb' + - 'spec/rspec/rails/matchers/redirect_to_spec.rb' + - 'spec/rspec/rails/matchers/route_to_spec.rb' + +# Offense count: 36 +# This cop supports safe autocorrection (--autocorrect). +Style/RedundantRegexpEscape: + Exclude: + - 'example_app_generator/generate_app.rb' + - 'spec/generators/rspec/feature/feature_generator_spec.rb' + - 'spec/generators/rspec/generator/generator_generator_spec.rb' + - 'spec/generators/rspec/system/system_generator_spec.rb' + - 'spec/generators/rspec/view/view_generator_spec.rb' + - 'spec/rspec/rails/matchers/action_cable/have_stream_spec.rb' + - 'spec/rspec/rails/matchers/have_rendered_spec.rb' + - 'spec/rspec/rails/matchers/redirect_to_spec.rb' + - 'spec/support/generators.rb' + +# Offense count: 23 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowIfMethodIsEmpty. +Style/SingleLineMethods: + Exclude: + - 'spec/rspec/rails/example/controller_example_group_spec.rb' + - 'spec/rspec/rails/matchers/active_job_spec.rb' + - 'spec/rspec/rails/matchers/be_a_new_spec.rb' + - 'spec/rspec/rails/matchers/has_spec.rb' + - 'spec/rspec/rails/matchers/have_enqueued_mail_spec.rb' + - 'spec/rspec/rails/matchers/have_rendered_spec.rb' + - 'spec/rspec/rails/setup_and_teardown_adapter_spec.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowModifier. +Style/SoleNestedConditional: + Exclude: + - 'lib/rspec/rails/tasks/rspec.rake' + +# Offense count: 4 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: Mode. +Style/StringConcatenation: + Exclude: + - 'lib/rspec/rails/configuration.rb' + - 'lib/rspec/rails/example/controller_example_group.rb' + - 'lib/rspec/rails/example/view_example_group.rb' + - 'spec/support/shared_examples.rb' diff --git a/Gemfile b/Gemfile index afec6680d..cd84a10b9 100644 --- a/Gemfile +++ b/Gemfile @@ -15,7 +15,7 @@ end gem 'capybara' gem 'ffi', '~> 1.15.5' gem 'rake', '> 12' -gem 'rubocop', '~> 0.80.1' +gem 'rubocop', '~> 1.28.2' custom_gemfile = File.expand_path('Gemfile-custom', __dir__) eval_gemfile custom_gemfile if File.exist?(custom_gemfile) diff --git a/example_app_generator/spec/verify_mailer_preview_path_spec.rb b/example_app_generator/spec/verify_mailer_preview_path_spec.rb index 96bfaee78..d6d2efaa1 100644 --- a/example_app_generator/spec/verify_mailer_preview_path_spec.rb +++ b/example_app_generator/spec/verify_mailer_preview_path_spec.rb @@ -16,7 +16,7 @@ def as_commandline(ops) end def capture_exec(*ops) - ops << {err: [:child, :out]} + ops << { err: [:child, :out] } io = IO.popen(ops) # Necessary to ignore warnings from Rails code base out = io.readlines @@ -40,7 +40,7 @@ def have_no_preview if RSpec::Rails::FeatureCheck.has_action_mailer_preview? context 'in the development environment' do - let(:custom_env) { {'RAILS_ENV' => rails_env} } + let(:custom_env) { { 'RAILS_ENV' => rails_env } } let(:rails_env) { 'development' } it 'sets the preview path to the default rspec path' do @@ -88,7 +88,7 @@ def have_no_preview end context 'in a non-development environment' do - let(:custom_env) { {'RAILS_ENV' => rails_env} } + let(:custom_env) { { 'RAILS_ENV' => rails_env } } let(:rails_env) { 'test' } it 'does not set the preview path by default' do @@ -123,7 +123,7 @@ def have_no_preview end else context 'in the development environment' do - let(:custom_env) { {'RAILS_ENV' => rails_env} } + let(:custom_env) { { 'RAILS_ENV' => rails_env } } let(:rails_env) { 'development' } it 'handles no action mailer preview' do @@ -150,7 +150,7 @@ def have_no_preview end context 'in a non-development environment' do - let(:custom_env) { {'RAILS_ENV' => rails_env} } + let(:custom_env) { { 'RAILS_ENV' => rails_env } } let(:rails_env) { 'test' } it 'handles no action mailer preview' do diff --git a/lib/generators/rspec.rb b/lib/generators/rspec.rb index 34bdc8ce3..e1ff5429a 100644 --- a/lib/generators/rspec.rb +++ b/lib/generators/rspec.rb @@ -23,12 +23,13 @@ def self.source_root(path = nil) # @private # Load configuration from RSpec to ensure `--default-path` is set def self.configuration - @configuration ||= begin - configuration = RSpec.configuration - options = RSpec::Core::ConfigurationOptions.new({}) - options.configure(configuration) - configuration - end + @configuration ||= + begin + configuration = RSpec.configuration + options = RSpec::Core::ConfigurationOptions.new({}) + options.configure(configuration) + configuration + end end def target_path(*paths) diff --git a/lib/rspec/rails/configuration.rb b/lib/rspec/rails/configuration.rb index 243e9c071..20d4cf3a4 100644 --- a/lib/rspec/rails/configuration.rb +++ b/lib/rspec/rails/configuration.rb @@ -26,19 +26,19 @@ class Configuration # # @api private DIRECTORY_MAPPINGS = { - channel: %w[spec channels], + channel: %w[spec channels], controller: %w[spec controllers], - generator: %w[spec generator], - helper: %w[spec helpers], - job: %w[spec jobs], - mailer: %w[spec mailers], - model: %w[spec models], - request: %w[spec (requests|integration|api)], - routing: %w[spec routing], - view: %w[spec views], - feature: %w[spec features], - system: %w[spec system], - mailbox: %w[spec mailboxes] + generator: %w[spec generator], + helper: %w[spec helpers], + job: %w[spec jobs], + mailer: %w[spec mailers], + model: %w[spec models], + request: %w[spec (requests|integration|api)], + routing: %w[spec routing], + view: %w[spec views], + feature: %w[spec features], + system: %w[spec system], + mailbox: %w[spec mailboxes] } # Sets up the different example group modules for the different spec types diff --git a/lib/rspec/rails/example/view_example_group.rb b/lib/rspec/rails/example/view_example_group.rb index 76783582d..cfb2d2cc4 100644 --- a/lib/rspec/rails/example/view_example_group.rb +++ b/lib/rspec/rails/example/view_example_group.rb @@ -149,7 +149,7 @@ def _default_render_options # the original string. match = path_regex.match(_default_file_to_render) - render_options = {template: match[:template]} + render_options = { template: match[:template] } render_options[:handlers] = [match[:handler].to_sym] if match[:handler] render_options[:formats] = [match[:format].to_sym] if match[:format] render_options[:locales] = [match[:locale].to_sym] if match[:locale] diff --git a/lib/rspec/rails/matchers/routing_matchers.rb b/lib/rspec/rails/matchers/routing_matchers.rb index e2b209add..621b06b00 100644 --- a/lib/rspec/rails/matchers/routing_matchers.rb +++ b/lib/rspec/rails/matchers/routing_matchers.rb @@ -26,7 +26,7 @@ def matches?(verb_to_path_map) path, query = *verb_to_path_map.values.first.split('?') @scope.assert_recognizes( @expected, - {method: verb_to_path_map.keys.first, path: path}, + { method: verb_to_path_map.keys.first, path: path }, Rack::Utils.parse_nested_query(query) ) end @@ -115,7 +115,7 @@ module RouteHelpers # Shorthand method for matching this type of route. %w[get post put patch delete options head].each do |method| define_method method do |path| - {method.to_sym => path} + { method.to_sym => path } end end end diff --git a/spec/rspec/rails/example/view_example_group_spec.rb b/spec/rspec/rails/example/view_example_group_spec.rb index 5f8ede30c..f4ca8ea94 100644 --- a/spec/rspec/rails/example/view_example_group_spec.rb +++ b/spec/rspec/rails/example/view_example_group_spec.rb @@ -145,25 +145,25 @@ def _default_file_to_render; end # Stub method it "sends render(:template => (described file)) to the view" do allow(view_spec).to receive(:_default_file_to_render) { "widgets/new" } view_spec.render - expect(view_spec.received.first).to eq([{template: "widgets/new"}, {}, nil]) + expect(view_spec.received.first).to eq([{ template: "widgets/new" }, {}, nil]) end it "converts the filename components into render options" do allow(view_spec).to receive(:_default_file_to_render) { "widgets/new.en.html.erb" } view_spec.render - expect(view_spec.received.first).to eq([{template: "widgets/new", locales: [:en], formats: [:html], handlers: [:erb]}, {}, nil]) + expect(view_spec.received.first).to eq([{ template: "widgets/new", locales: [:en], formats: [:html], handlers: [:erb] }, {}, nil]) end it "converts the filename with variant into render options" do allow(view_spec).to receive(:_default_file_to_render) { "widgets/new.en.html+fancy.erb" } view_spec.render - expect(view_spec.received.first).to eq([{template: "widgets/new", locales: [:en], formats: [:html], handlers: [:erb], variants: [:fancy]}, {}, nil]) + expect(view_spec.received.first).to eq([{ template: "widgets/new", locales: [:en], formats: [:html], handlers: [:erb], variants: [:fancy] }, {}, nil]) end it "converts the filename without format into render options" do allow(view_spec).to receive(:_default_file_to_render) { "widgets/new.en.erb" } view_spec.render - expect(view_spec.received.first).to eq([{template: "widgets/new", locales: [:en], handlers: [:erb]}, {}, nil]) + expect(view_spec.received.first).to eq([{ template: "widgets/new", locales: [:en], handlers: [:erb] }, {}, nil]) end end @@ -177,7 +177,7 @@ def _default_file_to_render; end # Stub method context "given a hash" do it "sends the hash as the first arg to render" do view_spec.render(foo: 'bar') - expect(view_spec.received.first).to eq([{foo: "bar"}, {}, nil]) + expect(view_spec.received.first).to eq([{ foo: "bar" }, {}, nil]) end end end diff --git a/spec/rspec/rails/matchers/active_job_spec.rb b/spec/rspec/rails/matchers/active_job_spec.rb index 70635ec38..db1abda6c 100644 --- a/spec/rspec/rails/matchers/active_job_spec.rb +++ b/spec/rspec/rails/matchers/active_job_spec.rb @@ -354,7 +354,7 @@ def self.name; "LoggingJob"; end hello_job.perform_later(global_id_object, symbolized_key: "asdf") }.to have_enqueued_job(hello_job).with { |first_arg, second_arg| expect(first_arg).to eq(global_id_object) - expect(second_arg).to eq({symbolized_key: "asdf"}) + expect(second_arg).to eq({ symbolized_key: "asdf" }) } end @@ -655,7 +655,7 @@ def self.name; "LoggingJob"; end hello_job.perform_later(global_id_object, symbolized_key: "asdf") }.to have_performed_job(hello_job).with { |first_arg, second_arg| expect(first_arg).to eq(global_id_object) - expect(second_arg).to eq({symbolized_key: "asdf"}) + expect(second_arg).to eq({ symbolized_key: "asdf" }) } end diff --git a/spec/rspec/rails/matchers/be_a_new_spec.rb b/spec/rspec/rails/matchers/be_a_new_spec.rb index b4e929ea8..76906a56f 100644 --- a/spec/rspec/rails/matchers/be_a_new_spec.rb +++ b/spec/rspec/rails/matchers/be_a_new_spec.rb @@ -81,7 +81,7 @@ def new_record?; true; end it "fails" do expect { expect(record).to be_a_new(record.class).with( - foo: a_hash_including({no_foo: "foo"})) + foo: a_hash_including({ no_foo: "foo" })) }.to raise_error { |e| expect(e.message).to eq("no implicit conversion of Hash into String").or eq("can't convert Hash into String") } diff --git a/spec/rspec/rails/matchers/be_routable_spec.rb b/spec/rspec/rails/matchers/be_routable_spec.rb index 81f27d37c..5306f8f3b 100644 --- a/spec/rspec/rails/matchers/be_routable_spec.rb +++ b/spec/rspec/rails/matchers/be_routable_spec.rb @@ -12,14 +12,14 @@ it "passes if routes recognize the path" do allow(routes).to receive(:recognize_path) { {} } expect do - expect({get: "/a/path"}).to be_routable + expect({ get: "/a/path" }).to be_routable end.to_not raise_error end it "fails if routes do not recognize the path" do allow(routes).to receive(:recognize_path) { raise ActionController::RoutingError.new('ignore') } expect do - expect({get: "/a/path"}).to be_routable + expect({ get: "/a/path" }).to be_routable end.to raise_error(/expected \{:get=>"\/a\/path"\} to be routable/) end end @@ -29,14 +29,14 @@ it "passes if routes do not recognize the path" do allow(routes).to receive(:recognize_path) { raise ActionController::RoutingError.new('ignore') } expect do - expect({get: "/a/path"}).not_to be_routable + expect({ get: "/a/path" }).not_to be_routable end.to_not raise_error end it "fails if routes recognize the path" do - allow(routes).to receive(:recognize_path) { {controller: "foo"} } + allow(routes).to receive(:recognize_path) { { controller: "foo" } } expect do - expect({get: "/a/path"}).not_to be_routable + expect({ get: "/a/path" }).not_to be_routable end.to raise_error(/expected \{:get=>"\/a\/path"\} not to be routable, but it routes to \{:controller=>"foo"\}/) end end diff --git a/spec/rspec/rails/matchers/have_enqueued_mail_spec.rb b/spec/rspec/rails/matchers/have_enqueued_mail_spec.rb index 258bf2889..bded88edc 100644 --- a/spec/rspec/rails/matchers/have_enqueued_mail_spec.rb +++ b/spec/rspec/rails/matchers/have_enqueued_mail_spec.rb @@ -386,7 +386,7 @@ def self.name; "NonMailerJob"; end expect { TestMailer.with('foo' => 'bar').email_with_args(1, 2).deliver_later - }.to have_enqueued_mail(TestMailer, :email_with_args).with({'foo' => 'bar'}, 1, 2) + }.to have_enqueued_mail(TestMailer, :email_with_args).with({ 'foo' => 'bar' }, 1, 2) end end @@ -414,13 +414,13 @@ def self.name; "NonMailerJob"; end expect { UnifiedMailer.with('foo' => 'bar').test_email.deliver_later }.to have_enqueued_mail(UnifiedMailer, :test_email).with( - a_hash_including(params: {'foo' => 'bar'}) + a_hash_including(params: { 'foo' => 'bar' }) ) expect { UnifiedMailer.with('foo' => 'bar').email_with_args(1, 2).deliver_later }.to have_enqueued_mail(UnifiedMailer, :email_with_args).with( - a_hash_including(params: {'foo' => 'bar'}, args: [1, 2]) + a_hash_including(params: { 'foo' => 'bar' }, args: [1, 2]) ) end diff --git a/spec/rspec/rails/matchers/have_rendered_spec.rb b/spec/rspec/rails/matchers/have_rendered_spec.rb index c665cc3f4..75f847d3e 100644 --- a/spec/rspec/rails/matchers/have_rendered_spec.rb +++ b/spec/rspec/rails/matchers/have_rendered_spec.rb @@ -6,8 +6,8 @@ context "given a hash" do def assert_template(*); end it "delegates to assert_template" do - expect(self).to receive(:assert_template).with({this: "hash"}, "this message") - expect("response").to send(template_expectation, {this: "hash"}, "this message") + expect(self).to receive(:assert_template).with({ this: "hash" }, "this message") + expect("response").to send(template_expectation, { this: "hash" }, "this message") end end diff --git a/spec/rspec/rails/matchers/route_to_spec.rb b/spec/rspec/rails/matchers/route_to_spec.rb index 5c32918e5..0b58a7c4a 100644 --- a/spec/rspec/rails/matchers/route_to_spec.rb +++ b/spec/rspec/rails/matchers/route_to_spec.rb @@ -13,20 +13,20 @@ def assert_recognizes(*) end it "delegates to assert_recognizes" do - expect(self).to receive(:assert_recognizes).with({"these" => "options"}, {method: :get, path: "path"}, {}) - expect({get: "path"}).to route_to("these" => "options") + expect(self).to receive(:assert_recognizes).with({ "these" => "options" }, { method: :get, path: "path" }, {}) + expect({ get: "path" }).to route_to("these" => "options") end context "with shortcut syntax" do it "routes with extra options" do - expect(self).to receive(:assert_recognizes).with({controller: "controller", action: "action", extra: "options"}, {method: :get, path: "path"}, {}) + expect(self).to receive(:assert_recognizes).with({ controller: "controller", action: "action", extra: "options" }, { method: :get, path: "path" }, {}) expect(get("path")).to route_to("controller#action", extra: "options") end it "routes without extra options" do expect(self).to receive(:assert_recognizes).with( - {controller: "controller", action: "action"}, - {method: :get, path: "path"}, + { controller: "controller", action: "action" }, + { method: :get, path: "path" }, {} ) expect(get("path")).to route_to("controller#action") @@ -34,29 +34,29 @@ def assert_recognizes(*) it "routes with one query parameter" do expect(self).to receive(:assert_recognizes).with( - {controller: "controller", action: "action", queryitem: "queryvalue"}, - {method: :get, path: "path"}, - {'queryitem' => 'queryvalue'} + { controller: "controller", action: "action", queryitem: "queryvalue" }, + { method: :get, path: "path" }, + { 'queryitem' => 'queryvalue' } ) expect(get("path?queryitem=queryvalue")).to route_to("controller#action", queryitem: 'queryvalue') end it "routes with multiple query parameters" do expect(self).to receive(:assert_recognizes).with( - {controller: "controller", action: "action", queryitem: "queryvalue", qi2: 'qv2'}, - {method: :get, path: "path"}, - {'queryitem' => 'queryvalue', 'qi2' => 'qv2'} + { controller: "controller", action: "action", queryitem: "queryvalue", qi2: 'qv2' }, + { method: :get, path: "path" }, + { 'queryitem' => 'queryvalue', 'qi2' => 'qv2' } ) expect(get("path?queryitem=queryvalue&qi2=qv2")).to route_to("controller#action", queryitem: 'queryvalue', qi2: 'qv2') end it "routes with nested query parameters" do expect(self).to receive(:assert_recognizes).with( - {:controller => "controller", :action => "action", 'queryitem' => {'qi2' => 'qv2'}}, - {method: :get, path: "path"}, - {'queryitem' => {'qi2' => 'qv2'}} + { :controller => "controller", :action => "action", 'queryitem' => { 'qi2' => 'qv2' } }, + { method: :get, path: "path" }, + { 'queryitem' => { 'qi2' => 'qv2' } } ) - expect(get("path?queryitem[qi2]=qv2")).to route_to("controller#action", 'queryitem' => {'qi2' => 'qv2'}) + expect(get("path?queryitem[qi2]=qv2")).to route_to("controller#action", 'queryitem' => { 'qi2' => 'qv2' }) end end @@ -65,7 +65,7 @@ def assert_recognizes(*) context "when assert_recognizes passes" do it "passes" do expect do - expect({get: "path"}).to route_to("these" => "options") + expect({ get: "path" }).to route_to("these" => "options") end.to_not raise_exception end end @@ -76,7 +76,7 @@ def assert_recognizes(*) raise ActiveSupport::TestCase::Assertion.new("this message") end expect do - expect({get: "path"}).to route_to("these" => "options") + expect({ get: "path" }).to route_to("these" => "options") end.to raise_error(RSpec::Expectations::ExpectationNotMetError, "this message") end end @@ -87,7 +87,7 @@ def assert_recognizes(*) raise ActionController::RoutingError.new("this message") end expect do - expect({get: "path"}).to route_to("these" => "options") + expect({ get: "path" }).to route_to("these" => "options") end.to raise_error(RSpec::Expectations::ExpectationNotMetError, "this message") end end @@ -98,7 +98,7 @@ def assert_recognizes(*) raise "oops" end expect do - expect({get: "path"}).to route_to("these" => "options") + expect({ get: "path" }).to route_to("these" => "options") end.to raise_exception("oops") end end @@ -108,7 +108,7 @@ def assert_recognizes(*) context "when assert_recognizes passes" do it "fails with custom message" do expect { - expect({get: "path"}).not_to route_to("these" => "options") + expect({ get: "path" }).not_to route_to("these" => "options") }.to raise_error(/expected \{:get=>"path"\} not to route to \{"these"=>"options"\}/) end end @@ -119,7 +119,7 @@ def assert_recognizes(*) raise ActiveSupport::TestCase::Assertion.new("this message") end expect do - expect({get: "path"}).not_to route_to("these" => "options") + expect({ get: "path" }).not_to route_to("these" => "options") end.to_not raise_error end end @@ -130,7 +130,7 @@ def assert_recognizes(*) raise ActionController::RoutingError.new("this message") end expect do - expect({get: "path"}).not_to route_to("these" => "options") + expect({ get: "path" }).not_to route_to("these" => "options") end.to_not raise_error end end @@ -141,7 +141,7 @@ def assert_recognizes(*) raise "oops" end expect do - expect({get: "path"}).not_to route_to("these" => "options") + expect({ get: "path" }).not_to route_to("these" => "options") end.to raise_exception("oops") end end @@ -152,7 +152,7 @@ def assert_recognizes(*) raise ActiveSupport::TestCase::Assertion, "this message" end expect do - expect({"this" => "path"}).to route_to("these" => "options") + expect({ "this" => "path" }).to route_to("these" => "options") end.to raise_error("this message") end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 6d3c5a3f6..0f020214b 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -5,7 +5,7 @@ class Application < ::Rails::Application config.secret_key_base = 'ASecretString' if defined?(ActionCable) - ActionCable.server.config.cable = {"adapter" => "test"} + ActionCable.server.config.cable = { "adapter" => "test" } ActionCable.server.config.logger = ActiveSupport::TaggedLogging.new ActiveSupport::Logger.new(StringIO.new) end