diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index daf8df1e8..63f10c4f6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -# This file was generated on 2022-01-26T13:58:53+00:00 from the rspec-dev repo. +# This file was generated on 2022-09-08T12:42:05+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. name: RSpec CI @@ -11,16 +11,18 @@ on: pull_request: branches: - '*' +permissions: + contents: read env: RSPEC_CI: true # This tells rspec-rails what branch to run in ci - RSPEC_VERSION: '= 3.11.0.pre' + RSPEC_VERSION: '~> 3.12.0' jobs: rubocop: name: Rubocop runs-on: 'ubuntu-20.04' steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: ruby/setup-ruby@v1 with: ruby-version: '3.0' @@ -72,7 +74,7 @@ jobs: continue-on-error: ${{ matrix.allow_failure || endsWith(matrix.ruby, 'head') }} env: ${{ matrix.env }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: ruby/setup-ruby@v1 with: bundler: ${{ matrix.bundler || '2.2.22' }} @@ -117,7 +119,7 @@ jobs: LEGACY_CI: true JRUBY_OPTS: ${{ matrix.container.jruby_opts || '--dev' }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - run: ${{ matrix.container.pre }} - run: script/legacy_setup.sh - run: bundle exec bin/rspec @@ -138,7 +140,7 @@ jobs: - 2.1.9 fail-fast: false steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: ruby/setup-ruby@v1 with: bundler: '2.2.22' diff --git a/.rubocop.yml b/.rubocop.yml index e6d4f3a13..a91a0fe3d 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,12 +1,18 @@ inherit_from: - .rubocop_rspec_base.yml + - .rubocop_todo.yml +# Over time we'd like to get this down, but this is what we're at now. Metrics/AbcSize: Max: 28 +# Over time we'd like to get this down, but this is what we're at now. Metrics/BlockLength: Max: 86 + Exclude: + - spec/**/* +# Over time we'd like to get this down, but this is what we're at now. Metrics/PerceivedComplexity: Max: 10 @@ -18,16 +24,10 @@ Style/EvalWithLocation: Exclude: # eval is only used here to check syntax - 'lib/rspec/support/ruby_features.rb' + - 'benchmarks/skip_frames_for_caller_filter.rb' + - 'spec/rspec/support/method_signature_verifier_spec.rb' Lint/AssignmentInCondition: Exclude: # The pattern makes sense here - 'lib/rspec/support/mutex.rb' - -# Over time we'd like to get this down, but this is what we're at now. -Metrics/AbcSize: - Max: 22 - -# Over time we'd like to get this down, but this is what we're at now. -Metrics/PerceivedComplexity: - Max: 9 diff --git a/.rubocop_rspec_base.yml b/.rubocop_rspec_base.yml index 13974fe8d..639f64c71 100644 --- a/.rubocop_rspec_base.yml +++ b/.rubocop_rspec_base.yml @@ -1,79 +1,76 @@ -# This file was generated on 2022-01-26T13:58:53+00:00 from the rspec-dev repo. +# This file was generated on 2022-09-08T12:42:05+01: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. -AccessModifierIndentation: +Layout/AccessModifierIndentation: Enabled: false # "Use alias_method instead of alias" # We're fine with `alias`. -Alias: +Style/Alias: Enabled: false -AlignParameters: - EnforcedStyle: with_first_parameter - # "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. -CaseEquality: +Style/CaseEquality: Enabled: false # Warns when the class is excessively long. -ClassLength: +Metrics/ClassLength: Max: 100 -CollectionMethods: +Style/CollectionMethods: PreferredMethods: reduce: 'inject' # Over time we'd like to get this down, but this is what we're at now. -CyclomaticComplexity: +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. -Documentation: +Style/Documentation: Enabled: false # We still support 1.8.7 which requires trailing dots -DotPosition: +Layout/DotPosition: EnforcedStyle: trailing -DoubleNegation: +Style/DoubleNegation: Enabled: false # each_with_object is unavailable on 1.8.7 so we have to disable this one. -EachWithObject: +Style/EachWithObject: Enabled: false -FormatString: +Style/FormatString: EnforcedStyle: percent # As long as we support ruby 1.8.7 we have to use hash rockets. -HashSyntax: +Style/HashSyntax: EnforcedStyle: hash_rockets # We can't use the new lambda syntax, since we still support 1.8.7. -Lambda: +Style/Lambda: Enabled: false # Over time we'd like to get this down, but this is what we're at now. -LineLength: +Layout/LineLength: Max: 100 # Over time we'd like to get this down, but this is what we're at now. -MethodLength: +Metrics/MethodLength: Max: 15 # Who cares what we call the argument for binary operator methods? -BinaryOperatorParameterName: +Naming/BinaryOperatorParameterName: Enabled: false -PercentLiteralDelimiters: +Style/PercentLiteralDelimiters: PreferredDelimiters: '%': () # double-quoted string '%i': '[]' # array of symbols @@ -87,41 +84,44 @@ PercentLiteralDelimiters: # We have too many special cases where we allow generator methods or prefer a # prefixed predicate due to it's improved readability. -PredicateName: +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/ -Proc: +Style/Proc: Enabled: false # Exceptions should be rescued with `Support::AllExceptionsExceptOnesWeMustNotRescue` -RescueException: +Lint/RescueException: Enabled: true # We haven't adopted the `fail` to signal exceptions vs `raise` for re-raises convention. -SignalException: +Style/SignalException: Enabled: false # We've tended to use no space, so it's less of a change to stick with that. -SpaceAroundEqualsInParameterDefault: +Layout/SpaceAroundEqualsInParameterDefault: EnforcedStyle: no_space # We don't care about single vs double qoutes. -StringLiterals: +Style/StringLiterals: Enabled: false # This rule favors constant names from the English standard library which we don't load. Style/SpecialGlobalVars: Enabled: false -Style/TrailingCommaInLiteral: +Style/TrailingCommaInArrayLiteral: + Enabled: false + +Style/TrailingCommaInHashLiteral: Enabled: false Style/TrailingCommaInArguments: Enabled: false -TrivialAccessors: +Style/TrivialAccessors: AllowDSLWriters: true AllowPredicates: true ExactNameMatch: true @@ -135,6 +135,15 @@ Layout/EmptyLineBetweenDefs: Layout/FirstParameterIndentation: Enabled: false +Layout/ParameterAlignment: + EnforcedStyle: with_first_parameter + +Layout/SpaceInsideBlockBraces: + Enabled: false + +Layout/SpaceInsideParens: + Enabled: false + Naming/ConstantName: Enabled: false @@ -162,7 +171,10 @@ Style/IfUnlessModifier: Style/IfUnlessModifierOfIfUnless: Enabled: false -Style/MethodMissing: +Lint/MissingSuper: + Enabled: false + +Style/MissingRespondToMissing: Enabled: false Style/MixinUsage: @@ -243,24 +255,19 @@ Style/StderrPuts: Style/TernaryParentheses: Enabled: false -# This could likely be enabled, but it had a false positive on rspec-mocks -# (suggested change was not behaviour preserving) so I don't trust it. -Performance/HashEachMethods: - Enabled: false - Naming/HeredocDelimiterNaming: Enabled: false -Layout/EmptyLineAfterMagicComment: +Layout/AssignmentIndentation: Enabled: false -Layout/IndentArray: +Layout/EmptyLineAfterMagicComment: Enabled: false -Layout/IndentAssignment: +Layout/FirstArrayElementIndentation: Enabled: false -Layout/IndentHeredoc: +Layout/HeredocIndentation: Enabled: false Layout/SpaceInsidePercentLiteralDelimiters: diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 000000000..108ab183a --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,424 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2022-01-09 17:43:27 UTC using RuboCop version 1.11.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. + +# Offense count: 1 +# Configuration parameters: Include. +# Include: **/*.gemspec +Gemspec/RequiredRubyVersion: + Exclude: + - 'rspec-support.gemspec' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: with_first_argument, with_fixed_indentation +Layout/ArgumentAlignment: + Exclude: + - 'spec/rspec/support_spec.rb' + +# Offense count: 17 +# Cop supports --auto-correct. +Layout/EmptyLineAfterGuardClause: + Exclude: + - 'benchmarks/caller_vs_caller_locations_vs_raise.rb' + - 'lib/rspec/support.rb' + - 'lib/rspec/support/differ.rb' + - 'lib/rspec/support/method_signature_verifier.rb' + - 'lib/rspec/support/mutex.rb' + - 'lib/rspec/support/recursive_const_methods.rb' + - 'lib/rspec/support/reentrant_mutex.rb' + - 'lib/rspec/support/source.rb' + - 'lib/rspec/support/source/location.rb' + - 'lib/rspec/support/source/token.rb' + - 'lib/rspec/support/spec/library_wide_checks.rb' + - 'lib/rspec/support/spec/stderr_splitter.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +Layout/EmptyLines: + Exclude: + - 'benchmarks/caller.rb' + - 'spec/rspec/support/differ_spec.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: AllowAliasSyntax, AllowedMethods. +# AllowedMethods: alias_method, public, protected, private +Layout/EmptyLinesAroundAttributeAccessor: + Exclude: + - 'spec/rspec/support/fuzzy_matcher_spec.rb' + - 'spec/rspec/support/method_signature_verifier_spec.rb' + +# Offense count: 8 +# Cop supports --auto-correct. +# 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: + - 'lib/rspec/support/source/token.rb' + - 'rspec-support.gemspec' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: normal, indented_internal_methods +Layout/IndentationConsistency: + Exclude: + - 'spec/rspec/support/differ_spec.rb' + +# Offense count: 6 +# Cop supports --auto-correct. +# Configuration parameters: Width, IgnoredPatterns. +Layout/IndentationWidth: + Exclude: + - 'lib/rspec/support/method_signature_verifier.rb' + - 'lib/rspec/support/ruby_features.rb' + +# Offense count: 50 +# Cop supports --auto-correct. +# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. +# URISchemes: http, https +Layout/LineLength: + Max: 156 + +# Offense count: 13 +# Cop supports --auto-correct. +Layout/SpaceAfterComma: + Exclude: + - 'rspec-support.gemspec' + - 'spec/rspec/support/differ_spec.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: space, no_space +Layout/SpaceAroundEqualsInParameterDefault: + Exclude: + - 'spec/rspec/support/encoded_string_spec.rb' + - 'spec/rspec/support/method_signature_verifier_spec.rb' + +# Offense count: 8 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets. +# SupportedStyles: space, no_space, compact +# SupportedStylesForEmptyBrackets: space, no_space +Layout/SpaceInsideArrayLiteralBrackets: + Exclude: + - 'spec/rspec/support/differ_spec.rb' + - 'spec/rspec/support/fuzzy_matcher_spec.rb' + +# Offense count: 20 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. +# SupportedStyles: space, no_space, compact +# SupportedStylesForEmptyBraces: space, no_space +Layout/SpaceInsideHashLiteralBraces: + Exclude: + - 'spec/rspec/support/differ_spec.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets. +# SupportedStyles: space, no_space +# SupportedStylesForEmptyBrackets: space, no_space +Layout/SpaceInsideReferenceBrackets: + Exclude: + - 'benchmarks/map_hash.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: final_newline, final_blank_line +Layout/TrailingEmptyLines: + Exclude: + - 'spec/rspec/support/fuzzy_matcher_spec.rb' + +# Offense count: 4 +Lint/AmbiguousBlockAssociation: + Exclude: + - 'spec/rspec/support/differ_spec.rb' + - 'spec/rspec/support/encoded_string_spec.rb' + - 'spec/rspec/support/ruby_features_spec.rb' + - 'spec/rspec/support_spec.rb' + +# Offense count: 2 +Lint/BinaryOperatorWithIdenticalOperands: + Exclude: + - 'spec/rspec/support/object_formatter_spec.rb' + - 'spec/rspec/support/source/token_spec.rb' + +# Offense count: 3 +# Configuration parameters: AllowedMethods. +# AllowedMethods: enums +Lint/ConstantDefinitionInBlock: + Exclude: + - 'spec/rspec/support/fuzzy_matcher_spec.rb' + - 'spec/rspec/support/recursive_const_methods_spec.rb' + - 'spec/rspec/support/spec/in_sub_process_spec.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: AllowedImplicitNamespaces. +# AllowedImplicitNamespaces: Gem +Lint/RaiseException: + Exclude: + - 'spec/rspec/support_spec.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Lint/RedundantCopDisableDirective: + Exclude: + - 'lib/rspec/support/spec/in_sub_process.rb' + +# Offense count: 1 +Lint/StructNewOverride: + Exclude: + - 'spec/rspec/support_spec.rb' + +# Offense count: 3 +# Configuration parameters: AllowComments. +Lint/SuppressedException: + Exclude: + - 'spec/rspec/support_spec.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: ContextCreatingMethods, MethodCreatingMethods. +Lint/UselessAccessModifier: + Exclude: + - 'lib/rspec/support/encoded_string.rb' + +# Offense count: 12 +# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods. +# IgnoredMethods: refine +Metrics/BlockLength: + Max: 834 + +# Offense count: 8 +# Configuration parameters: CountComments, CountAsOne. +Metrics/ModuleLength: + Max: 836 + +# Offense count: 1 +# Configuration parameters: IgnoredMethods. +Metrics/PerceivedComplexity: + Max: 10 + +# 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/caller_vs_caller_locations_vs_raise.rb' + - 'spec/rspec/support/method_signature_verifier_spec.rb' + +# Offense count: 5 +# Cop supports --auto-correct. +# Configuration parameters: PreferredName. +Naming/RescuedExceptionsVariableName: + Exclude: + - 'benchmarks/caller_vs_caller_locations_vs_raise.rb' + - 'lib/rspec/support.rb' + - 'lib/rspec/support/spec/in_sub_process.rb' + +# Offense count: 1 +Security/Eval: + Exclude: + - 'Gemfile' + +# Offense count: 7 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: percent_q, bare_percent +Style/BarePercentLiterals: + Exclude: + - 'spec/rspec/support/differ_spec.rb' + - 'spec/rspec/support/object_formatter_spec.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/CaseLikeIf: + Exclude: + - 'lib/rspec/support/directory_maker.rb' + +# Offense count: 7 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: nested, compact +Style/ClassAndModuleChildren: + Exclude: + - 'spec/rspec/support/comparable_version_spec.rb' + - 'spec/rspec/support/directory_maker_spec.rb' + - 'spec/rspec/support/encoded_string_spec.rb' + - 'spec/rspec/support/source/node_spec.rb' + - 'spec/rspec/support/source/token_spec.rb' + - 'spec/rspec/support/source_spec.rb' + - 'spec/rspec/support/with_keywords_when_needed_spec.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: IgnoredMethods. +# IgnoredMethods: ==, equal?, eql? +Style/ClassEqualityComparison: + Exclude: + - 'lib/rspec/support/comparable_version.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/ColonMethodCall: + Exclude: + - 'spec/rspec/support/differ_spec.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Style/EmptyLiteral: + Exclude: + - 'spec/rspec/support/method_signature_verifier_spec.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +Style/Encoding: + Exclude: + - 'rspec-support.gemspec' + - 'spec/rspec/support/differ_spec.rb' + - 'spec/rspec/support/encoded_string_spec.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +Style/ExpandPathArguments: + Exclude: + - 'Gemfile' + - 'benchmarks/caller.rb' + - 'rspec-support.gemspec' + - 'spec/rspec/support/caller_filter_spec.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: format, sprintf, percent +Style/FormatString: + Exclude: + - 'spec/rspec/support/encoded_string_spec.rb' + +# Offense count: 68 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: always, always_true, never +Style/FrozenStringLiteralComment: + Enabled: false + +# Offense count: 1 +# Cop supports --auto-correct. +Style/GlobalStdStream: + Exclude: + - 'spec/rspec/support/spec/stderr_splitter_spec.rb' + +# Offense count: 3 +# Configuration parameters: AllowedVariables. +Style/GlobalVars: + Exclude: + - 'spec/rspec/support/caller_filter_spec.rb' + - 'spec/rspec/support/spec/stderr_splitter_spec.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. +# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys +Style/HashSyntax: + Exclude: + - 'benchmarks/class_exec_vs_klass_exec.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Style/LineEndConcatenation: + Exclude: + - 'spec/rspec/support_spec.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: IgnoredMethods. +Style/MethodCallWithoutArgsParentheses: + Exclude: + - 'spec/rspec/support/method_signature_verifier_spec.rb' + +# Offense count: 8 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedOctalStyle. +# SupportedOctalStyles: zero_with_o, zero_only +Style/NumericLiteralPrefix: + Exclude: + - 'spec/rspec/support/differ_spec.rb' + - 'spec/rspec/support/object_formatter_spec.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: Strict. +Style/NumericLiterals: + MinDigits: 6 + +# Offense count: 1 +# Configuration parameters: AllowedMethods. +# AllowedMethods: respond_to_missing? +Style/OptionalBooleanParameter: + Exclude: + - 'lib/rspec/support/spec/in_sub_process.rb' + +# Offense count: 7 +# Cop supports --auto-correct. +# Configuration parameters: PreferredDelimiters. +Style/PercentLiteralDelimiters: + Exclude: + - 'spec/rspec/support/differ_spec.rb' + - 'spec/rspec/support/object_formatter_spec.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: lower_case_q, upper_case_q +Style/PercentQLiterals: + Exclude: + - 'spec/rspec/support/differ_spec.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Style/RedundantPercentQ: + Exclude: + - 'spec/rspec/support/differ_spec.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods. +# AllowedMethods: present?, blank?, presence, try, try! +Style/SafeNavigation: + Exclude: + - 'lib/rspec/support/mutex.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: AllowAsExpressionSeparator. +Style/Semicolon: + Exclude: + - 'spec/rspec/support/fuzzy_matcher_spec.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: AllowIfMethodIsEmpty. +Style/SingleLineMethods: + Exclude: + - 'spec/rspec/support/differ_spec.rb' + - 'spec/rspec/support/fuzzy_matcher_spec.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: WordRegex. +# SupportedStyles: percent, brackets +Style/WordArray: + EnforcedStyle: percent + MinSize: 3 diff --git a/Changelog.md b/Changelog.md index 12f14dcf3..e1f42050e 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,25 @@ +### Development +[Full Changelog](http://github.com/rspec/rspec-support/compare/v3.12.0...3-12-maintenance) + +### 3.12.0 / 2022-10-26 +[Full Changelog](http://github.com/rspec/rspec-support/compare/v3.11.1...v3.12.0) +Enhancements: + +* Add `RSpec::Support::RubyFeatures.distincts_kw_args_from_positional_hash?` + (Jean byroot Boussier, #535) + +### 3.11.1 / 2022-09-12 +[Full Changelog](http://github.com/rspec/rspec-support/compare/v3.11.0...v3.11.1) + +Bug Fixes: + +* Fix ripper detection on TruffleRuby. (Brandon Fish, #541) + +### 3.11.0 / 2022-02-09 +[Full Changelog](http://github.com/rspec/rspec-support/compare/v3.10.3...v3.11.0) + +No changes. Released to support other RSpec releases. + ### 3.10.3 / 2021-11-03 [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.10.2...v3.10.3) diff --git a/Gemfile b/Gemfile index b19de7d41..bdf4efb9b 100644 --- a/Gemfile +++ b/Gemfile @@ -50,6 +50,8 @@ end if RUBY_VERSION < '2.2.0' && !!(RbConfig::CONFIG['host_os'] =~ /cygwin|mswin|mingw|bccwin|wince|emx/) gem 'ffi', '< 1.10' +elsif RUBY_VERSION < '2.4.0' && !!(RbConfig::CONFIG['host_os'] =~ /cygwin|mswin|mingw|bccwin|wince|emx/) + gem 'ffi', '< 1.15' elsif RUBY_VERSION < '2.0' # ffi dropped Ruby 1.8 support in 1.9.19 and Ruby 1.9 support in 1.11.0 gem 'ffi', '< 1.9.19' @@ -61,7 +63,7 @@ end # No need to run rubocop on earlier versions if RUBY_VERSION >= '2.4' && RUBY_ENGINE == 'ruby' - gem "rubocop", "~> 0.52.1" + gem 'rubocop', "~> 1.0", "< 1.12" end eval File.read('Gemfile-custom') if File.exist?('Gemfile-custom') diff --git a/lib/rspec/support/caller_filter.rb b/lib/rspec/support/caller_filter.rb index cd59a30f8..fe210f74a 100644 --- a/lib/rspec/support/caller_filter.rb +++ b/lib/rspec/support/caller_filter.rb @@ -25,7 +25,7 @@ class CallerFilter # when `CallerFilter.first_non_rspec_line` is called from the top level of a required # file, but it depends on if rubygems is loaded or not. We don't want to have to deal # with this complexity in our `RSpec.deprecate` calls, so we ignore it here. - IGNORE_REGEX = Regexp.union(LIB_REGEX, "rubygems/core_ext/kernel_require.rb") + IGNORE_REGEX = Regexp.union(LIB_REGEX, "rubygems/core_ext/kernel_require.rb", "(other) # rubocop:disable Metrics/AbcSize + def <=>(other) other = self.class.new(other) unless other.is_a?(self.class) return 0 if string == other.string diff --git a/lib/rspec/support/differ.rb b/lib/rspec/support/differ.rb index b81184239..71a8694ce 100644 --- a/lib/rspec/support/differ.rb +++ b/lib/rspec/support/differ.rb @@ -6,7 +6,7 @@ module RSpec module Support - # rubocop:disable ClassLength + # rubocop:disable Metrics/ClassLength class Differ def diff(actual, expected) diff = "" @@ -24,7 +24,7 @@ def diff(actual, expected) diff.to_s end - # rubocop:disable MethodLength + # rubocop:disable Metrics/MethodLength def diff_as_string(actual, expected) encoding = EncodedString.pick_encoding(actual, expected) @@ -52,7 +52,7 @@ def diff_as_string(actual, expected) rescue Encoding::CompatibilityError handle_encoding_errors(actual, expected) end - # rubocop:enable MethodLength + # rubocop:enable Metrics/MethodLength def diff_as_object(actual, expected) actual_as_string = object_to_string(actual) @@ -210,6 +210,6 @@ def handle_encoding_errors(actual, expected) end end end - # rubocop:enable ClassLength + # rubocop:enable Metrics/ClassLength end end diff --git a/lib/rspec/support/encoded_string.rb b/lib/rspec/support/encoded_string.rb index 13c323503..80c69a881 100644 --- a/lib/rspec/support/encoded_string.rb +++ b/lib/rspec/support/encoded_string.rb @@ -60,7 +60,7 @@ def to_s # vs "\x80".encode('UTF-8','ASCII-8BIT', undef: :replace, replace: '') # # => '' # Encoding::CompatibilityError - # when Encoding.compatibile?(str1, str2) is nil + # when Encoding.compatible?(str1, str2) is nil # e.g. utf_16le_emoji_string.split("\n") # e.g. valid_unicode_string.encode(utf8_encoding) << ascii_string # Encoding::InvalidByteSequenceError: @@ -92,7 +92,7 @@ def matching_encoding(string) string = remove_invalid_bytes(string) string.encode(@encoding) rescue Encoding::UndefinedConversionError, Encoding::InvalidByteSequenceError - # Originally defined as a constant to avoid uneeded allocations, this hash must + # Originally defined as a constant to avoid unneeded allocations, this hash must # be defined inline (without {}) to avoid warnings on Ruby 2.7 # # In MRI 2.1 'invalid: :replace' changed to also replace an invalid byte sequence @@ -108,7 +108,7 @@ def matching_encoding(string) # string.encode(@encoding, :invalid => :replace, :undef => :replace, :replace => REPLACE) rescue Encoding::ConverterNotFoundError - # Originally defined as a constant to avoid uneeded allocations, this hash must + # Originally defined as a constant to avoid unneeded allocations, this hash must # be defined inline (without {}) to avoid warnings on Ruby 2.7 string.dup.force_encoding(@encoding).encode(:invalid => :replace, :replace => REPLACE) end diff --git a/lib/rspec/support/method_signature_verifier.rb b/lib/rspec/support/method_signature_verifier.rb index 16736224e..c4eb432ad 100644 --- a/lib/rspec/support/method_signature_verifier.rb +++ b/lib/rspec/support/method_signature_verifier.rb @@ -8,7 +8,7 @@ module Support # keyword args of a given method. # # @private - class MethodSignature # rubocop:disable ClassLength + class MethodSignature # rubocop:disable Metrics/ClassLength attr_reader :min_non_kw_args, :max_non_kw_args, :optional_kw_args, :required_kw_args def initialize(method) @@ -285,7 +285,7 @@ def initialize(signature, args=[]) @arbitrary_kw_args = @unlimited_args = false end - def with_expectation(expectation) # rubocop:disable MethodLength, Metrics/PerceivedComplexity + def with_expectation(expectation) # rubocop:disable Metrics/MethodLength return self unless MethodSignatureExpectation === expectation if expectation.empty? diff --git a/lib/rspec/support/mutex.rb b/lib/rspec/support/mutex.rb index 1bc3ccf69..778e9bb43 100644 --- a/lib/rspec/support/mutex.rb +++ b/lib/rspec/support/mutex.rb @@ -9,7 +9,7 @@ module Support # Some methods we don't need are deleted. Anything I don't # understand (there's quite a bit, actually) is left in. # - # Some formating changes are made to appease the robot overlord: + # Some formatting changes are made to appease the robot overlord: # https://travis-ci.org/rspec/rspec-core/jobs/54410874 # @private class Mutex diff --git a/lib/rspec/support/ruby_features.rb b/lib/rspec/support/ruby_features.rb index daba00ea5..d5d6aae53 100644 --- a/lib/rspec/support/ruby_features.rb +++ b/lib/rspec/support/ruby_features.rb @@ -116,6 +116,9 @@ def supports_taint? ripper_requirements.push(!Ruby.jruby_version.between?('9.0.0.0.rc1', '9.2.0.0')) end + # TruffleRuby disables ripper due to low performance + ripper_requirements.push(false) if Ruby.truffleruby? + if ripper_requirements.all? def ripper_supported? true @@ -126,6 +129,10 @@ def ripper_supported? end end + def distincts_kw_args_from_positional_hash? + RUBY_VERSION >= '3.0.0' + end + if Ruby.mri? def kw_args_supported? RUBY_VERSION >= '2.0.0' diff --git a/lib/rspec/support/spec/in_sub_process.rb b/lib/rspec/support/spec/in_sub_process.rb index 85196997c..2f5025ece 100644 --- a/lib/rspec/support/spec/in_sub_process.rb +++ b/lib/rspec/support/spec/in_sub_process.rb @@ -7,7 +7,7 @@ module InSubProcess # Useful as a way to isolate a global change to a subprocess. - def in_sub_process(prevent_warnings=true) # rubocop:disable MethodLength, Metrics/AbcSize + def in_sub_process(prevent_warnings=true) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize exception_reader, exception_writer = IO.pipe result_reader, result_writer = IO.pipe diff --git a/lib/rspec/support/spec/stderr_splitter.rb b/lib/rspec/support/spec/stderr_splitter.rb index 03b50e939..6da084cc9 100644 --- a/lib/rspec/support/spec/stderr_splitter.rb +++ b/lib/rspec/support/spec/stderr_splitter.rb @@ -39,7 +39,7 @@ def to_io def write(line) return if line =~ %r{^\S+/gems/\S+:\d+: warning:} # http://rubular.com/r/kqeUIZOfPG - # Ruby 2.7.0 warnings from keyword argments span multiple lines, extend check above + # Ruby 2.7.0 warnings from keyword arguments span multiple lines, extend check above # to look for the next line. return if @last_line =~ %r{^\S+/gems/\S+:\d+: warning:} && line =~ %r{warning: The called method .* is defined here} diff --git a/lib/rspec/support/version.rb b/lib/rspec/support/version.rb index 8cd1d0429..7421355e3 100644 --- a/lib/rspec/support/version.rb +++ b/lib/rspec/support/version.rb @@ -1,7 +1,7 @@ module RSpec module Support module Version - STRING = '3.11.0.pre' + STRING = '3.12.0' end end end diff --git a/lib/rspec/support/with_keywords_when_needed.rb b/lib/rspec/support/with_keywords_when_needed.rb index 56b67e70b..dc76b5ee0 100644 --- a/lib/rspec/support/with_keywords_when_needed.rb +++ b/lib/rspec/support/with_keywords_when_needed.rb @@ -9,7 +9,7 @@ module WithKeywordsWhenNeeded module_function if RSpec::Support::RubyFeatures.kw_args_supported? - # Remove this in RSpec 4 in favour of explictly passed in kwargs where + # Remove this in RSpec 4 in favour of explicitly passed in kwargs where # this is used. Works around a warning in Ruby 2.7 def class_exec(klass, *args, &block) diff --git a/maintenance-branch b/maintenance-branch index ba2906d06..90ed1bf04 100644 --- a/maintenance-branch +++ b/maintenance-branch @@ -1 +1 @@ -main +3-12-maintenance diff --git a/script/ci_functions.sh b/script/ci_functions.sh index add930da1..bc1852e90 100644 --- a/script/ci_functions.sh +++ b/script/ci_functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2022-01-26T13:58:53+00:00 from the rspec-dev repo. +# This file was generated on 2022-09-08T12:42:05+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. # Taken from: diff --git a/script/clone_all_rspec_repos b/script/clone_all_rspec_repos index e786c16de..d9924d852 100755 --- a/script/clone_all_rspec_repos +++ b/script/clone_all_rspec_repos @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2022-01-26T13:58:53+00:00 from the rspec-dev repo. +# This file was generated on 2022-09-08T12:42:05+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e @@ -12,7 +12,7 @@ if is_mri; then clone_repo "rspec-core" clone_repo "rspec-expectations" clone_repo "rspec-mocks" - clone_repo "rspec-rails" + clone_repo "rspec-rails" "6-0-maintenance" if rspec_support_compatible; then clone_repo "rspec-support" diff --git a/script/cucumber.sh b/script/cucumber.sh index 1710fe80e..bcc65ac53 100755 --- a/script/cucumber.sh +++ b/script/cucumber.sh @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2022-01-26T13:58:53+00:00 from the rspec-dev repo. +# This file was generated on 2022-09-08T12:42:05+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e diff --git a/script/functions.sh b/script/functions.sh index f15e4b20a..65ecc3e6a 100644 --- a/script/functions.sh +++ b/script/functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2022-01-26T13:58:53+00:00 from the rspec-dev repo. +# This file was generated on 2022-09-08T12:42:05+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" @@ -192,6 +192,9 @@ function run_all_spec_suites { fold "rspec-expectations specs" run_spec_suite_for "rspec-expectations" fold "rspec-mocks specs" run_spec_suite_for "rspec-mocks" if rspec_rails_compatible; then + if ! is_ruby_27_plus; then + export RAILS_VERSION='~> 6.1.0' + fi fold "rspec-rails specs" run_spec_suite_for "rspec-rails" fi diff --git a/script/legacy_setup.sh b/script/legacy_setup.sh index 0f4430afb..e209ccb08 100755 --- a/script/legacy_setup.sh +++ b/script/legacy_setup.sh @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2022-01-26T13:58:53+00:00 from the rspec-dev repo. +# This file was generated on 2022-09-08T12:42:05+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e diff --git a/script/predicate_functions.sh b/script/predicate_functions.sh index 18bf61989..3b43860e1 100644 --- a/script/predicate_functions.sh +++ b/script/predicate_functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2022-01-26T13:58:53+00:00 from the rspec-dev repo. +# This file was generated on 2022-09-08T12:42:05+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. function is_mri { @@ -95,6 +95,14 @@ function is_ruby_25_plus { fi } +function is_ruby_27_plus { + if ruby -e "exit(RUBY_VERSION.to_f >= 2.7)"; then + return 0 + else + return 1 + fi +} + function is_ruby_31_plus { if ruby -e "exit(RUBY_VERSION.to_f >= 3.1)"; then return 0 diff --git a/script/run_build b/script/run_build index 2fc337539..479329b45 100755 --- a/script/run_build +++ b/script/run_build @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2022-01-26T13:58:53+00:00 from the rspec-dev repo. +# This file was generated on 2022-09-08T12:42:05+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e diff --git a/script/run_rubocop b/script/run_rubocop index d8caff16f..07cff5294 100755 --- a/script/run_rubocop +++ b/script/run_rubocop @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2022-01-26T13:58:53+00:00 from the rspec-dev repo. +# This file was generated on 2022-09-08T12:42:05+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e diff --git a/script/update_rubygems_and_install_bundler b/script/update_rubygems_and_install_bundler index 42194ea15..a9919792a 100755 --- a/script/update_rubygems_and_install_bundler +++ b/script/update_rubygems_and_install_bundler @@ -1,11 +1,16 @@ #!/bin/bash -# This file was generated on 2022-01-26T13:58:53+00:00 from the rspec-dev repo. +# This file was generated on 2022-09-08T12:42:05+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e source script/functions.sh -if is_ruby_23_plus; then +if is_ruby_31_plus; then + echo "Installing rubygems 3.3.6 / bundler 2.3.6" + yes | gem update --system '3.3.6' + yes | gem install bundler -v '2.3.6' +elif is_ruby_23_plus; then + echo "Installing rubygems 3.2.22 / bundler 2.2.22" yes | gem update --system '3.2.22' yes | gem install bundler -v '2.2.22' else diff --git a/spec/rspec/support/caller_filter_spec.rb b/spec/rspec/support/caller_filter_spec.rb index 4c7004cb3..b47a107b2 100644 --- a/spec/rspec/support/caller_filter_spec.rb +++ b/spec/rspec/support/caller_filter_spec.rb @@ -54,7 +54,7 @@ def in_rspec_support_lib(name) it 'does not match rubygems lines from `require` statements' do with_isolated_stderr do - require 'rubygems' # ensure rubygems is laoded + require 'rubygems' # ensure rubygems is loaded end in_rspec_support_lib("test_dir") do |dir| diff --git a/spec/rspec/support/ruby_features_spec.rb b/spec/rspec/support/ruby_features_spec.rb index d9622a5fb..a45e8a075 100644 --- a/spec/rspec/support/ruby_features_spec.rb +++ b/spec/rspec/support/ruby_features_spec.rb @@ -21,12 +21,12 @@ module Support end describe ".windows_file_path?" do - it "returns true when the file alt seperator is a colon" do + it "returns true when the file alt separator is a colon" do stub_const("File::ALT_SEPARATOR", "\\") unless OS.windows? expect(OS).to be_windows_file_path end - it "returns false when file alt seperator is not present" do + it "returns false when file alt separator is not present" do stub_const("File::ALT_SEPARATOR", nil) if OS.windows? expect(OS).to_not be_windows_file_path end @@ -91,6 +91,10 @@ module Support RubyFeatures.required_kw_args_supported? end + specify "distincts_kw_args_from_positional_hash?" do + RubyFeatures.distincts_kw_args_from_positional_hash? + end + specify "#supports_rebinding_module_methods? exists" do RubyFeatures.supports_rebinding_module_methods? end diff --git a/spec/rspec/support/spec/stderr_splitter_spec.rb b/spec/rspec/support/spec/stderr_splitter_spec.rb index 0aa5d9a6e..7cb7f6d5f 100644 --- a/spec/rspec/support/spec/stderr_splitter_spec.rb +++ b/spec/rspec/support/spec/stderr_splitter_spec.rb @@ -86,7 +86,9 @@ splitter.verify_no_warnings! end - unless defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx' + unless RSpec::Support::Ruby.rbx? || RSpec::Support::Ruby.truffleruby? + # TruffleRuby doesn't support warnings for now + # https://github.com/oracle/truffleruby/issues/2595 it 'will fail an example which generates a warning' do true unless $undefined expect { splitter.verify_no_warnings! }.to raise_error(/Warnings were generated:/) diff --git a/spec/rspec/support_spec.rb b/spec/rspec/support_spec.rb index 477a63d52..2bb28351f 100644 --- a/spec/rspec/support_spec.rb +++ b/spec/rspec/support_spec.rb @@ -50,7 +50,7 @@ def method_missing(name, *args, &block) end it 'fails with `NameError` when an undefined method is fetched ' + - 'from an object that has overriden `method` to raise an Exception' do + 'from an object that has overridden `method` to raise an Exception' do object = double allow(object).to receive(:method).and_raise(Exception) expect { @@ -59,7 +59,7 @@ def method_missing(name, *args, &block) end it 'fails with `NameError` when a method is fetched from an object ' + - 'that has overriden `method` to not return a method' do + 'that has overridden `method` to not return a method' do object = proxy_class.new(double(:method => :baz)) expect { Support.method_handle_for(object, :=~) @@ -102,7 +102,7 @@ def method_missing(name, *args, &block) expect(Support.method_handle_for(object, :foo).call).to eq :bar end - it 'works when `method` has been overriden', :if => supports_rebinding_module_methods? do + it 'works when `method` has been overridden', :if => supports_rebinding_module_methods? do object = basic_class_with_method_override.new expect(Support.method_handle_for(object, :foo).call).to eq :bar end