diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index a9f5e1a2b..90f7be8d0 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -19,7 +19,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] - ruby: ["2.7", "3.0", "3.1", "3.2"] + ruby: ['3.0', '3.1', '3.2', '3.3'] include: - os: ubuntu-latest ruby: jruby-9.4 diff --git a/.github/workflows/rubocop.yaml b/.github/workflows/rubocop.yaml index de7545865..389a1ebb7 100644 --- a/.github/workflows/rubocop.yaml +++ b/.github/workflows/rubocop.yaml @@ -15,6 +15,6 @@ jobs: - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: - ruby-version: 2.7 + ruby-version: '3.0' bundler-cache: true - run: bundle exec rubocop diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 513f24864..84fb8b029 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -17,7 +17,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, macos-latest, windows-latest] - ruby: ["2.7", "3.0", "3.1", "3.2"] + ruby: ['3.0', '3.1', '3.2', '3.3'] include: - os: ubuntu-latest ruby: jruby-9.4 diff --git a/.rubocop.yml b/.rubocop.yml index 68770cc7d..59524f3a3 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -13,7 +13,7 @@ require: AllCops: NewCops: disable # Keep this inline with the lowest ruby version in the gemspec - TargetRubyVersion: 2.7 + TargetRubyVersion: 3.0 # Display cop name / style guide references DisplayCopNames: true DisplayStyleGuide: true @@ -34,13 +34,6 @@ Layout/TrailingWhitespace: - spec/cucumber/formatter/pretty_spec.rb - spec/cucumber/formatter/progress_spec.rb -# TODO: [LH] - This needs a re-review. I think we can pretty much delete / phase this out with incremental updates -# We exclude proto_world for documentation (rdoc) purpose -Lint/UselessMethodDefinition: - Enabled: true - Exclude: - - lib/cucumber/glue/proto_world.rb - # Rubocop doesn't like method names in other languages but as Cucumber supports multiple languages, this cop needs to be disabled Naming/AsciiIdentifiers: Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 8d2129d91..e0d2e80c1 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2024-02-01 10:58:34 UTC using RuboCop version 1.56.4. +# on 2024-07-09 14:33:36 UTC using RuboCop version 1.61.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 @@ -8,32 +8,8 @@ # TODO - [LH] -> Oct '23 - 355 files inspected, 642 offenses detected, 205 offenses autocorrectable # TODO - [LH] -> Dec '23 - 350 files inspected, 595 offenses detected, 171 offenses autocorrectable -# TODO - [LH] -> Feb '23 - 370 files inspected, 635 offenses detected, 166 offenses autocorrectable - -# Offense count: 10 -# 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: - - 'lib/cucumber/cli/options.rb' - -# Offense count: 19 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowInHeredoc. -Layout/TrailingWhitespace: - Exclude: - - 'lib/cucumber/multiline_argument/data_table.rb' - -# Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). -Lint/AmbiguousOperator: - Exclude: - - 'lib/cucumber/multiline_argument/data_table.rb' - - 'lib/cucumber/running_test_case.rb' - - 'spec/cucumber/formatter/spec_helper.rb' +# TODO - [LH] -> Feb '24 - 370 files inspected, 635 offenses detected, 166 offenses autocorrectable +# TODO - [LH] -> Jul '24 - 370 files inspected, 637 offenses detected, 97 offenses autocorrectable # Offense count: 4 Lint/RescueException: @@ -43,6 +19,13 @@ Lint/RescueException: - 'lib/cucumber/glue/invoke_in_world.rb' - 'lib/cucumber/glue/proto_world.rb' +# Offense count: 2 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AutoCorrect. +Lint/UselessMethodDefinition: + Exclude: + - 'lib/cucumber/glue/proto_world.rb' + # Offense count: 60 # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes. Metrics/AbcSize: @@ -57,7 +40,7 @@ Metrics/BlockLength: # Offense count: 13 # Configuration parameters: CountComments, CountAsOne. Metrics/ClassLength: - Max: 523 + Max: 515 # Offense count: 8 # Configuration parameters: AllowedMethods, AllowedPatterns. @@ -67,9 +50,9 @@ Metrics/CyclomaticComplexity: # Offense count: 74 # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. Metrics/MethodLength: - Max: 72 + Max: 64 -# Offense count: 17 +# Offense count: 16 # Configuration parameters: CountComments, CountAsOne. Metrics/ModuleLength: Max: 804 @@ -87,37 +70,14 @@ Naming/FileName: Exclude: - 'features/lib/step_definitions/iso-8859-1_steps.rb' -# Offense count: 2 +# Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyleForLeadingUnderscores. # SupportedStylesForLeadingUnderscores: disallowed, required, optional Naming/MemoizedInstanceVariableName: Exclude: - - 'lib/cucumber/formatter/json.rb' - 'lib/cucumber/multiline_argument/data_table.rb' -## Offense count: 14 -## Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames. -## AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to -#Naming/MethodParameterName: -# Exclude: -# - 'lib/cucumber/cli/options.rb' -# - 'lib/cucumber/formatter/ansicolor.rb' -# - 'lib/cucumber/formatter/console.rb' -# - 'lib/cucumber/gherkin/formatter/ansi_escapes.rb' -# - 'lib/cucumber/multiline_argument/data_table.rb' - -# Offense count: 8 -# Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns. -# SupportedStyles: snake_case, normalcase, non_integer -# AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339, x86_64 -Naming/VariableNumber: - Exclude: - - 'examples/i18n/bg/lib/calculator.rb' - - 'examples/i18n/ru/lib/calculator.rb' - - 'examples/i18n/uk/lib/calculator.rb' - - 'examples/i18n/uz/lib/calculator.rb' - # Offense count: 2 RSpec/AnyInstance: Exclude: @@ -130,31 +90,17 @@ RSpec/Capybara/FeatureMethods: Exclude: - 'spec/cucumber/filters/activate_steps_spec.rb' -# Offense count: 15 +# Offense count: 5 # Configuration parameters: Prefixes, AllowedPatterns. # Prefixes: when, with, without RSpec/ContextWording: Exclude: - - 'spec/cucumber/cli/options_spec.rb' - - 'spec/cucumber/cli/rerun_spec.rb' - - 'spec/cucumber/configuration_spec.rb' - 'spec/cucumber/filters/tag_limits_spec.rb' - 'spec/cucumber/formatter/http_io_spec.rb' - 'spec/cucumber/formatter/junit_spec.rb' - 'spec/cucumber/formatter/publish_banner_printer_spec.rb' - - 'spec/cucumber/glue/step_definition_spec.rb' - 'spec/support/shared_context/http_server.rb' -# Offense count: 8 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: SkipBlocks, EnforcedStyle. -# SupportedStyles: described_class, explicit -RSpec/DescribedClass: - Exclude: - - 'spec/cucumber/cli/profile_loader_spec.rb' - - 'spec/cucumber/formatter/json_spec.rb' - - 'spec/cucumber/multiline_argument/data_table_spec.rb' - # Offense count: 2 # This cop supports unsafe autocorrection (--autocorrect-all). RSpec/EmptyExampleGroup: @@ -162,14 +108,6 @@ RSpec/EmptyExampleGroup: - 'spec/cucumber/filters/activate_steps_spec.rb' - 'spec/cucumber/running_test_case_spec.rb' -# Offense count: 4 -# This cop supports safe autocorrection (--autocorrect). -RSpec/EmptyLineAfterFinalLet: - Exclude: - - 'spec/cucumber/cli/main_spec.rb' - - 'spec/cucumber/configuration_spec.rb' - - 'spec/cucumber/hooks_spec.rb' - # Offense count: 82 # Configuration parameters: CountAsOne. RSpec/ExampleLength: @@ -201,7 +139,7 @@ RSpec/ExpectOutput: Exclude: - 'spec/cucumber/formatter/interceptor_spec.rb' -# Offense count: 62 +# Offense count: 61 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: implicit, each, example @@ -276,23 +214,6 @@ RSpec/RepeatedExampleGroupDescription: Exclude: - 'spec/cucumber/glue/proto_world_spec.rb' -# Offense count: 31 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: and_return, block -RSpec/ReturnFromStub: - Exclude: - - 'spec/cucumber/cli/configuration_spec.rb' - - 'spec/cucumber/cli/main_spec.rb' - - 'spec/cucumber/cli/options_spec.rb' - - 'spec/cucumber/cli/profile_loader_spec.rb' - - 'spec/cucumber/cli/rerun_spec.rb' - - 'spec/cucumber/configuration_spec.rb' - - 'spec/cucumber/filters/tag_limits/verifier_spec.rb' - - 'spec/cucumber/formatter/interceptor_spec.rb' - - 'spec/cucumber/formatter/junit_spec.rb' - - 'spec/cucumber/glue/registry_and_more_spec.rb' - # Offense count: 3 # This cop supports safe autocorrection (--autocorrect). RSpec/ScatteredLet: @@ -352,6 +273,23 @@ Style/GlobalVars: - 'features/lib/support/env.rb' - 'spec/cucumber/cli/options_spec.rb' +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: literals, strict +Style/MutableConstant: + Exclude: + - 'lib/cucumber/formatter/unicode.rb' + +# Offense count: 5 +# This cop supports safe autocorrection (--autocorrect). +Style/RedundantFreeze: + Exclude: + - 'lib/cucumber/cli/options.rb' + - 'lib/cucumber/file_specs.rb' + - 'lib/cucumber/runtime.rb' + - 'lib/cucumber/term/ansicolor.rb' + # Offense count: 6 # This cop supports safe autocorrection (--autocorrect). Style/StderrPuts: diff --git a/CHANGELOG.md b/CHANGELOG.md index aaf4bd422..bf6ca8a2f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,15 @@ This document is formatted according to the principles of [Keep A CHANGELOG](htt Please visit [cucumber/CONTRIBUTING.md](https://github.com/cucumber/cucumber/blob/master/CONTRIBUTING.md) for more info on how to contribute to Cucumber. ## [Unreleased] +### Changed +- Updated `cucumber-compatibility-kit` to v16 ([luke-hill](https://github.com/luke-hill)) +- Changed compatibility testing to fully lean on external assets instead of duplicating them ([luke-hill](https://github.com/luke-hill)) + +### Fixed +- Fixed an issue where a change to one example in compatibility testing wasn't fully adhered to ([luke-hill](https://github.com/luke-hill)) + +### Removed +- Removed support for Ruby 2.7 ([luke-hill](https://github.com/luke-hill)) ## [9.2.0] - 2024-03-19 ### Changed diff --git a/compatibility/cck_spec.rb b/compatibility/cck_spec.rb index 37a3aec17..0aa162cd6 100644 --- a/compatibility/cck_spec.rb +++ b/compatibility/cck_spec.rb @@ -3,7 +3,7 @@ require_relative 'support/shared_examples' require_relative 'support/cck/examples' -require 'cucumber-compatibility-kit' +require 'cck/examples' describe 'Cucumber Compatibility Kit', type: :feature, cck: true do let(:cucumber_command) { 'bundle exec cucumber --publish-quiet --profile none --format message' } diff --git a/compatibility/features/attachments/attachments.feature.rb b/compatibility/features/attachments/attachments_steps.rb similarity index 70% rename from compatibility/features/attachments/attachments.feature.rb rename to compatibility/features/attachments/attachments_steps.rb index 21de6c26a..d639fbdd3 100644 --- a/compatibility/features/attachments/attachments.feature.rb +++ b/compatibility/features/attachments/attachments_steps.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true -# This blank hook has been re-added in. See https://github.com/cucumber/compatibility-kit/issues/83 for more details -Before { nil } +def cck_asset_path + "#{Gem.loaded_specs['cucumber-compatibility-kit'].full_gem_path}/features/attachments" +end When('the string {string} is attached as {string}') do |text, media_type| attach(text, media_type) @@ -25,13 +26,13 @@ end When('a JPEG image is attached') do - attach(File.open("#{__dir__}/cucumber.jpeg"), 'image/jpeg') + attach(File.open("#{cck_asset_path}/cucumber.jpeg"), 'image/jpeg') end When('a PNG image is attached') do - attach(File.open("#{__dir__}/cucumber.png"), 'image/png') + attach(File.open("#{cck_asset_path}/cucumber.png"), 'image/png') end When('a PDF document is attached and renamed') do - attach(File.open("#{__dir__}/document.pdf"), 'document/pdf', 'renamed.pdf') + attach(File.open("#{cck_asset_path}/document.pdf"), 'document/pdf', 'renamed.pdf') end diff --git a/compatibility/features/attachments/cucumber.jpeg b/compatibility/features/attachments/cucumber.jpeg deleted file mode 100644 index e833d6c77..000000000 Binary files a/compatibility/features/attachments/cucumber.jpeg and /dev/null differ diff --git a/compatibility/features/attachments/cucumber.png b/compatibility/features/attachments/cucumber.png deleted file mode 100644 index 2760899aa..000000000 Binary files a/compatibility/features/attachments/cucumber.png and /dev/null differ diff --git a/compatibility/features/attachments/document.pdf b/compatibility/features/attachments/document.pdf deleted file mode 100644 index fc73b32aa..000000000 Binary files a/compatibility/features/attachments/document.pdf and /dev/null differ diff --git a/compatibility/features/cdata/cdata.feature.rb b/compatibility/features/cdata/cdata_steps.rb similarity index 100% rename from compatibility/features/cdata/cdata.feature.rb rename to compatibility/features/cdata/cdata_steps.rb diff --git a/compatibility/features/data-tables/data-tables.feature.rb b/compatibility/features/data-tables/data-tables_steps.rb similarity index 100% rename from compatibility/features/data-tables/data-tables.feature.rb rename to compatibility/features/data-tables/data-tables_steps.rb diff --git a/compatibility/features/examples-tables/examples-tables.feature.rb b/compatibility/features/examples-tables/examples-tables_steps.rb similarity index 54% rename from compatibility/features/examples-tables/examples-tables.feature.rb rename to compatibility/features/examples-tables/examples-tables_steps.rb index 9b0bcd5a6..f346c974e 100644 --- a/compatibility/features/examples-tables/examples-tables.feature.rb +++ b/compatibility/features/examples-tables/examples-tables_steps.rb @@ -4,6 +4,10 @@ @count = initial_count end +Given('there are {int} friends') do |initial_friends| + @friends = initial_friends +end + When('I eat {int} cucumbers') do |eat_count| @count -= eat_count end @@ -11,3 +15,9 @@ Then('I should have {int} cucumbers') do |expected_count| expect(@count).to eq(expected_count) end + +Then('each person can eat {int} cucumbers') do |expected_share| + share = (@count / (1 + @friends)).floor + + expect(share).to eq(expected_share) +end diff --git a/compatibility/features/hooks/cucumber.svg b/compatibility/features/hooks/cucumber.svg deleted file mode 100644 index e76ff7faf..000000000 --- a/compatibility/features/hooks/cucumber.svg +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/compatibility/features/hooks/hooks.feature.rb b/compatibility/features/hooks/hooks_steps.rb similarity index 65% rename from compatibility/features/hooks/hooks.feature.rb rename to compatibility/features/hooks/hooks_steps.rb index caa444c07..2eb59a0ea 100644 --- a/compatibility/features/hooks/hooks.feature.rb +++ b/compatibility/features/hooks/hooks_steps.rb @@ -8,6 +8,10 @@ # no-op end +def cck_asset_path + "#{Gem.loaded_specs['cucumber-compatibility-kit'].full_gem_path}/features/hooks" +end + When('a step passes') do # no-op end @@ -25,5 +29,5 @@ end After('@with-attachment') do - attach(File.open("#{__dir__}/cucumber.svg"), 'image/svg+xml') + attach(File.open("#{cck_asset_path}/cucumber.svg"), 'image/svg+xml') end diff --git a/compatibility/features/minimal/minimal.feature.rb b/compatibility/features/minimal/minimal_steps.rb similarity index 100% rename from compatibility/features/minimal/minimal.feature.rb rename to compatibility/features/minimal/minimal_steps.rb diff --git a/compatibility/features/parameter-types/parameter-types.feature.rb b/compatibility/features/parameter-types/parameter-types_steps.rb similarity index 100% rename from compatibility/features/parameter-types/parameter-types.feature.rb rename to compatibility/features/parameter-types/parameter-types_steps.rb diff --git a/compatibility/features/pending/pending.feature.rb b/compatibility/features/pending/pending_steps.rb similarity index 100% rename from compatibility/features/pending/pending.feature.rb rename to compatibility/features/pending/pending_steps.rb diff --git a/compatibility/features/retry/retry.arguments.txt b/compatibility/features/retry/retry.arguments.txt deleted file mode 100644 index cf83a5556..000000000 --- a/compatibility/features/retry/retry.arguments.txt +++ /dev/null @@ -1 +0,0 @@ ---retry 2 diff --git a/compatibility/features/retry/retry.feature.rb b/compatibility/features/retry/retry_steps.rb similarity index 100% rename from compatibility/features/retry/retry.feature.rb rename to compatibility/features/retry/retry_steps.rb diff --git a/compatibility/features/rules/rules.feature.rb b/compatibility/features/rules/rules_steps.rb similarity index 100% rename from compatibility/features/rules/rules.feature.rb rename to compatibility/features/rules/rules_steps.rb diff --git a/compatibility/features/skipped/skipped.feature.rb b/compatibility/features/skipped/skipped_steps.rb similarity index 100% rename from compatibility/features/skipped/skipped.feature.rb rename to compatibility/features/skipped/skipped_steps.rb diff --git a/compatibility/features/stack-traces/stack-traces.feature.rb b/compatibility/features/stack-traces/stack-traces_steps.rb similarity index 100% rename from compatibility/features/stack-traces/stack-traces.feature.rb rename to compatibility/features/stack-traces/stack-traces_steps.rb diff --git a/compatibility/features/undefined/undefined.feature.rb b/compatibility/features/undefined/undefined_steps.rb similarity index 100% rename from compatibility/features/undefined/undefined.feature.rb rename to compatibility/features/undefined/undefined_steps.rb diff --git a/compatibility/features/unknown-parameter-type/unknown-parameter-type.feature.rb b/compatibility/features/unknown-parameter-type/unknown-parameter-type_steps.rb similarity index 100% rename from compatibility/features/unknown-parameter-type/unknown-parameter-type.feature.rb rename to compatibility/features/unknown-parameter-type/unknown-parameter-type_steps.rb diff --git a/compatibility/support/cck/messages_comparator.rb b/compatibility/support/cck/messages_comparator.rb index e0f49c4d1..31dbeb473 100644 --- a/compatibility/support/cck/messages_comparator.rb +++ b/compatibility/support/cck/messages_comparator.rb @@ -51,6 +51,7 @@ def compare_message(detected, expected) return if ignorable?(detected) return if incomparable?(detected) + # TODO: This needs refactoring as it's becoming rather large and bloated all_errors << CCK::KeysChecker.compare(detected, expected) compare_sub_messages(detected, expected) end diff --git a/compatibility/support/shared_examples.rb b/compatibility/support/shared_examples.rb index 72dbd3efc..7fb6f31b9 100644 --- a/compatibility/support/shared_examples.rb +++ b/compatibility/support/shared_examples.rb @@ -7,8 +7,6 @@ require_relative 'cck/helpers' require_relative 'cck/messages_comparator' -require 'cucumber-compatibility-kit' - RSpec.shared_examples 'cucumber compatibility kit' do include CCK::Helpers diff --git a/cucumber.gemspec b/cucumber.gemspec index cd97804cd..2aec488b8 100644 --- a/cucumber.gemspec +++ b/cucumber.gemspec @@ -19,8 +19,8 @@ Gem::Specification.new do |s| 'source_code_uri' => 'https://github.com/cucumber/cucumber-ruby' } - s.required_ruby_version = '>= 2.7' - s.required_rubygems_version = '>= 3.0.1' + s.required_ruby_version = '>= 3.0' + s.required_rubygems_version = '>= 3.2.8' s.add_dependency 'builder', '~> 3.2' s.add_dependency 'cucumber-ci-environment', '> 9', '< 11' @@ -34,12 +34,12 @@ Gem::Specification.new do |s| s.add_dependency 'multi_test', '~> 1.1' s.add_dependency 'sys-uname', '~> 1.2' - s.add_development_dependency 'cucumber-compatibility-kit', '~> 15.0' + s.add_development_dependency 'cucumber-compatibility-kit', '~> 16.0' # Only needed whilst we are testing the formatters. Can be removed once we remove tests for those s.add_development_dependency 'nokogiri', '~> 1.14' s.add_development_dependency 'rake', '~> 13.1' s.add_development_dependency 'rspec', '~> 3.12' - s.add_development_dependency 'rubocop', '~> 1.56.4' + s.add_development_dependency 'rubocop', '~> 1.61.0' s.add_development_dependency 'rubocop-capybara', '~> 2.19.0' s.add_development_dependency 'rubocop-packaging', '~> 0.5.2' s.add_development_dependency 'rubocop-rake', '~> 0.6.0'