From 9879b81609b0871a0dc3bf675ace7bd0cd88c3cc Mon Sep 17 00:00:00 2001 From: Luke Hill <20105237+luke-hill@users.noreply.github.com> Date: Fri, 13 Oct 2023 14:50:22 +0100 Subject: [PATCH] V3/version deps (#579) * Bump max permissible version of cucumber to v9.x and update minimum rubocop versions for a variety of gems * Update changelogs * Downgrade some gems and remove lockfile to attempt to get a partial gem update to work - See: https://github.com/rubygems/rubygems/issues/7044 * Permit v9 of cucumber again * Permit cucumber v9 in rails 6.1 testing * Remove final 2 issues we guard around (1 is redundant, 1 has been fixed) * Remove duplicate step from codebase, use aruba * Remove small file and absorb into env.rb * Lean on aruba command for features * Add changelog * Add max version restrictions for some of the older rails gems now 7.1 has been released * Ensure no args are passed downstream * This class was removed from the stdlib around ruby 1.9.3 * Add matrix gem in to mitigate slightly older capybara issues * Pass in a Minitest run-name if needed * Manually overload the matrix require until 3.36+ of capybara is the min * Update rails 6.1 gemfile to use a slightly higher version of capybara * Add 2 more workflows to the exclusion list (One will be flaky with psych, the other with capybara) * ACtually exclude the runs desired --- .github/workflows/test.yml | 7 ++++++- .rubocop.yml | 13 ------------- Appraisals | 8 ++++++-- CHANGELOG.md | 10 +++++----- cucumber-rails.gemspec | 13 +++++++------ features/allow_rescue.feature | 2 +- features/capybara_javascript_drivers.feature | 8 ++++---- .../choose_javascript_database_strategy.feature | 16 ++++++++-------- features/configuration.feature | 4 ++-- features/database_cleaner.feature | 6 +++--- .../disable_automatic_database_cleaning.feature | 2 +- features/emulate_javascript.feature | 4 ++-- features/rest_api.feature | 2 +- .../step_definitions/cucumber_rails_steps.rb | 12 ------------ features/support/aruba.rb | 5 ----- features/support/env.rb | 4 ++++ gemfiles/rails_6_0.gemfile | 2 ++ gemfiles/rails_6_1.gemfile | 3 ++- gemfiles/rails_7_0.gemfile | 1 + lib/cucumber/rails/world.rb | 2 +- 20 files changed, 56 insertions(+), 68 deletions(-) delete mode 100644 features/support/aruba.rb diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 35388800..663a5c26 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -39,11 +39,16 @@ jobs: - { ruby: '2.7', gemfile: 'rails_7_1' } # Ruby 3+ won't work with Rails 5.2: https://github.com/rails/rails/issues/40938 - { ruby: '3.0', gemfile: 'rails_5_2' } + # Capybara has an incompatibility here with rails 6. It's easier to just exclude this one run from the matrix until it's out of support + - { ruby: '3.0', gemfile: 'rails_6_0' } + - { ruby: '3.0', gemfile: 'rails_6_1' } - { ruby: '3.1', gemfile: 'rails_5_2' } - # Ruby 3.1+ has a conflicting Psych version with Rails 6.0 (And maybe 6.1...): https://stackoverflow.com/questions/71191685/visit-psych-nodes-alias-unknown-alias-default-psychbadalias + # Ruby 3.1+ has a conflicting Psych version with Rails 6.x: https://stackoverflow.com/questions/71191685/visit-psych-nodes-alias-unknown-alias-default-psychbadalias - { ruby: '3.1', gemfile: 'rails_6_0' } + - { ruby: '3.1', gemfile: 'rails_6_1' } - { ruby: '3.2', gemfile: 'rails_5_2' } - { ruby: '3.2', gemfile: 'rails_6_0' } + - { ruby: '3.2', gemfile: 'rails_6_1' } env: BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile steps: diff --git a/.rubocop.yml b/.rubocop.yml index 8525b123..04f53ff4 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -24,19 +24,6 @@ Layout/LineLength: - '^When' - '^Then' -# This needs fixing as it's inheriting a lot more than what we originally need. -# The inheritance chain goes all the way down to a single test case which the world -# definitely doesn't represent. GH issue 505 -Lint/MissingSuper: - Exclude: - - lib/cucumber/rails/world.rb - -# These can both be removed once we upgrade rubocop and rubocop-rspec to more up to date versions -Metrics/BlockLength: - Exclude: - - './spec/**/*_spec.rb' - - 'cucumber-rails.gemspec' - # This allows us to read the chmod action in a more reproducible way Style/NumericLiteralPrefix: EnforcedOctalStyle: zero_only diff --git a/Appraisals b/Appraisals index 558905bb..694db412 100644 --- a/Appraisals +++ b/Appraisals @@ -12,7 +12,9 @@ end appraise 'rails_6_0' do gem 'activerecord' + gem 'capybara', '< 3.35' gem 'cucumber', '< 6' + gem 'matrix' # Until capybara 3.36+ gem 'psych', '< 4' gem 'rails-html-sanitizer', '< 1.4.3' gem 'railties', '~> 6.0.3' @@ -21,7 +23,8 @@ end appraise 'rails_6_1' do gem 'activerecord' - gem 'cucumber', '< 9' + gem 'capybara', '< 3.38' + gem 'cucumber', '< 10' gem 'psych', '< 4' gem 'railties', '~> 6.1.3' gem 'sqlite3', '~> 1.4' @@ -29,7 +32,8 @@ end appraise 'rails_7_0' do gem 'activerecord' - gem 'railties', '~> 7.0.0' + gem 'cucumber', '< 10' + gem 'railties', '~> 7.0.0' gem 'sqlite3', '~> 1.4' end diff --git a/CHANGELOG.md b/CHANGELOG.md index 07a320b3..81cf47e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,11 +13,11 @@ This file is intended to be modified using the [`changelog`](github.com/cucumber ### Fixed - Some of the rails 5.2 tests were installing lots of old conflicting gems ([luke-hill]) -- Generator updates: - - Updated the install locations for some scripts from `script/` to `bin/` - - Changed some install generators to remove some legacy items - - Updates have facilitated minimum support versions altering: capybara must be `v3.11+` and cucumber must be `v5+` - ([luke-hill]) +- Generator updates (Updated the install locations for some scripts from `script/` to `bin/` and remove some legacy items) + ([luke-hill]) +- Update minimum versions of several gems: capybara must be `v3.11+` and cucumber must be `v5+` (cucumber v9 is also permissible) + ([luke-hill]) +- Fixed an issue where the World instantiation didn't re-run the inherited classes initializer ([luke-hill]) ## [3.0.0.rc.1] - 2023-09-15 ### Removed diff --git a/cucumber-rails.gemspec b/cucumber-rails.gemspec index 5bcc9ce2..eb4b6805 100644 --- a/cucumber-rails.gemspec +++ b/cucumber-rails.gemspec @@ -13,6 +13,9 @@ Gem::Specification.new do |s| s.license = 'MIT' + s.required_ruby_version = '>= 2.6.0' + s.required_rubygems_version = '>= 3.2.3' + s.metadata = { 'bug_tracker_uri' => 'https://github.com/cucumber/cucumber-rails/issues', 'changelog_uri' => "https://github.com/cucumber/cucumber-rails/blob/v#{s.version}/CHANGELOG.md", @@ -22,7 +25,7 @@ Gem::Specification.new do |s| } s.add_runtime_dependency('capybara', '>= 3.11', '< 4') - s.add_runtime_dependency('cucumber', '>= 5', '< 9') + s.add_runtime_dependency('cucumber', '>= 5', '< 10') s.add_runtime_dependency('railties', '>= 5.2', '< 8') # Main development dependencies @@ -33,16 +36,14 @@ Gem::Specification.new do |s| s.add_development_dependency('rails', '>= 5.2', '< 8') s.add_development_dependency('rake', '>= 12.0') s.add_development_dependency('rspec', '~> 3.6') - s.add_development_dependency('rubocop', '~> 1.28.2') + s.add_development_dependency('rubocop', '~> 1.31.0') s.add_development_dependency('rubocop-packaging', '~> 0.5.1') - s.add_development_dependency('rubocop-performance', '~> 1.13.3') - s.add_development_dependency('rubocop-rspec', '~> 2.10.0') + s.add_development_dependency('rubocop-performance', '~> 1.17.0') + s.add_development_dependency('rubocop-rspec', '~> 2.12.0') # For Documentation: s.add_development_dependency('yard', '~> 0.9.10') - s.required_ruby_version = '>= 2.6.0' - s.required_rubygems_version = '>= 3.2.3' s.require_path = 'lib' s.files = Dir['lib/**/*', 'CHANGELOG.md', 'CONTRIBUTING.md', 'LICENSE', 'README.md'] end diff --git a/features/allow_rescue.feature b/features/allow_rescue.feature index 62584ab0..a4922bd5 100644 --- a/features/allow_rescue.feature +++ b/features/allow_rescue.feature @@ -38,7 +38,7 @@ Feature: Allow Cucumber to rescue exceptions """ And I run `bundle exec rake db:migrate` And I run `bundle exec cucumber` - Then the feature run should pass with: + Then the feature should pass with: """ 1 scenario (1 passed) 2 steps (2 passed) diff --git a/features/capybara_javascript_drivers.feature b/features/capybara_javascript_drivers.feature index aa63db0d..c611a6a2 100644 --- a/features/capybara_javascript_drivers.feature +++ b/features/capybara_javascript_drivers.feature @@ -40,7 +40,7 @@ Feature: Capybara Javascript Drivers """ And I run `bundle exec rake db:migrate` And I run `bundle exec rake cucumber` - Then the feature run should pass with: + Then the feature should pass with: """ 1 scenario (1 passed) 6 steps (6 passed) @@ -87,7 +87,7 @@ Feature: Capybara Javascript Drivers """ And I run `bundle exec rake db:migrate` And I run `bundle exec rake cucumber` - Then the feature run should pass with: + Then the feature should pass with: """ 1 scenario (1 passed) 6 steps (6 passed) @@ -126,7 +126,7 @@ Feature: Capybara Javascript Drivers """ And I run `bundle exec rake db:migrate` And I run `bundle exec rake cucumber` - Then the feature run should pass with: + Then the feature should pass with: """ 1 scenario (1 passed) 3 steps (3 passed) @@ -176,7 +176,7 @@ Feature: Capybara Javascript Drivers """ And I run `bundle exec rake db:migrate` And I run `bundle exec rake cucumber` - Then the feature run should pass with: + Then the feature should pass with: """ 1 scenario (1 passed) 6 steps (6 passed) diff --git a/features/choose_javascript_database_strategy.feature b/features/choose_javascript_database_strategy.feature index 100ebfb8..f242c862 100644 --- a/features/choose_javascript_database_strategy.feature +++ b/features/choose_javascript_database_strategy.feature @@ -71,8 +71,8 @@ Feature: Choose javascript database strategy Then the DatabaseCleaner strategy should be transaction And I should have 2 widgets """ - And I run the cukes - Then the feature run should pass with: + And I run `bundle exec cucumber` + Then the feature should pass with: """ 3 scenarios (3 passed) 10 steps (10 passed) @@ -97,8 +97,8 @@ Feature: Choose javascript database strategy Scenario: Then I should have 2 widgets """ - And I run the cukes - Then the feature run should pass with: + And I run `bundle exec cucumber` + Then the feature should pass with: """ 2 scenarios (2 passed) 5 steps (5 passed) @@ -126,8 +126,8 @@ Feature: Choose javascript database strategy Then I should have 2 widgets And the DatabaseCleaner strategy should be transaction """ - And I run the cukes - Then the feature run should pass with: + And I run `bundle exec cucumber` + Then the feature should pass with: """ 2 scenarios (2 passed) 7 steps (7 passed) @@ -149,8 +149,8 @@ Feature: Choose javascript database strategy Scenario: Then I should have 3 widgets """ - And I run the cukes - Then the feature run should pass with: + And I run `bundle exec cucumber` + Then the feature should pass with: """ 2 scenarios (2 passed) 3 steps (3 passed) diff --git a/features/configuration.feature b/features/configuration.feature index 7d011282..87a406b8 100644 --- a/features/configuration.feature +++ b/features/configuration.feature @@ -19,7 +19,7 @@ Feature: Cucumber Rails Configuration end """ And I run `bundle exec rake cucumber` - Then the feature run should pass with: + Then the feature should pass with: """ 1 scenario (1 passed) 1 step (1 passed) @@ -41,7 +41,7 @@ Feature: Cucumber Rails Configuration end """ And I run `bundle exec rake cucumber` - Then the feature run should pass with: + Then the feature should pass with: """ 1 scenario (1 passed) 1 step (1 passed) diff --git a/features/database_cleaner.feature b/features/database_cleaner.feature index 5bf1d98c..b837a7d0 100644 --- a/features/database_cleaner.feature +++ b/features/database_cleaner.feature @@ -37,7 +37,7 @@ Feature: Database Cleaner """ And I run `bundle exec rake db:migrate` And I run `bundle exec rake cucumber` - Then the feature run should pass with: + Then the feature should pass with: """ 2 scenarios (2 passed) 6 steps (6 passed) @@ -80,7 +80,7 @@ Feature: Database Cleaner """ And I run `bundle exec rake db:migrate` And I run `bundle exec rake cucumber` - Then the feature run should pass with: + Then the feature should pass with: """ 2 scenarios (2 passed) 6 steps (6 passed) @@ -124,7 +124,7 @@ Feature: Database Cleaner """ And I run `bundle exec rake db:migrate` And I run `bundle exec rake cucumber` - Then the feature run should pass with: + Then the feature should pass with: """ 2 scenarios (2 passed) 6 steps (6 passed) diff --git a/features/disable_automatic_database_cleaning.feature b/features/disable_automatic_database_cleaning.feature index 8d42ad45..b677a9e8 100644 --- a/features/disable_automatic_database_cleaning.feature +++ b/features/disable_automatic_database_cleaning.feature @@ -42,7 +42,7 @@ Feature: Disable automatic database cleaning """ And I run `bundle exec rake db:migrate` And I run `bundle exec rake cucumber` - Then the feature run should pass with: + Then the feature should pass with: """ 2 scenarios (2 passed) 4 steps (4 passed) diff --git a/features/emulate_javascript.feature b/features/emulate_javascript.feature index a08aafc2..59e65a0f 100644 --- a/features/emulate_javascript.feature +++ b/features/emulate_javascript.feature @@ -39,7 +39,7 @@ Feature: Emulate Javascript """ And I run `bundle exec rake db:migrate` And I run `bundle exec rake cucumber` - Then the feature run should pass with: + Then the feature should pass with: """ 1 scenario (1 passed) 3 steps (3 passed) @@ -118,7 +118,7 @@ Feature: Emulate Javascript """ And I run `bundle exec rake db:migrate` And I run `bundle exec rake cucumber` - Then the feature run should pass with: + Then the feature should pass with: """ 1 scenario (1 passed) 9 steps (9 passed) diff --git a/features/rest_api.feature b/features/rest_api.feature index 078ce57f..920ed1fa 100644 --- a/features/rest_api.feature +++ b/features/rest_api.feature @@ -40,7 +40,7 @@ Feature: REST API """ And I run `bundle exec rake db:migrate` And I run `bundle exec rake cucumber` - Then the feature run should pass with: + Then the feature should pass with: """ 1 scenario (1 passed) 2 steps (2 passed) diff --git a/features/step_definitions/cucumber_rails_steps.rb b/features/step_definitions/cucumber_rails_steps.rb index eb0da4f8..632f4132 100644 --- a/features/step_definitions/cucumber_rails_steps.rb +++ b/features/step_definitions/cucumber_rails_steps.rb @@ -73,15 +73,3 @@ overwrite_file(file, content.gsub(/\.(datetime|time|date)_field/, '.\1_select')) end - -When('I run the cukes') do - run_command_and_stop('bundle exec cucumber') -end - -# Copied from Aruba -Then('the feature run should pass with:') do |string| - step 'the output should not contain " failed)"' - step 'the output should not contain " undefined)"' - step 'the exit status should be 0' - step 'the output should contain:', string -end diff --git a/features/support/aruba.rb b/features/support/aruba.rb deleted file mode 100644 index e7a02105..00000000 --- a/features/support/aruba.rb +++ /dev/null @@ -1,5 +0,0 @@ -# frozen_string_literal: true - -Aruba.configure do |config| - config.exit_timeout = 360 -end diff --git a/features/support/env.rb b/features/support/env.rb index 474f9b9f..94b98a93 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -4,3 +4,7 @@ require 'rspec/expectations' require 'aruba/cucumber' + +Aruba.configure do |config| + config.exit_timeout = 360 +end diff --git a/gemfiles/rails_6_0.gemfile b/gemfiles/rails_6_0.gemfile index 233edb95..25ee6c3f 100644 --- a/gemfiles/rails_6_0.gemfile +++ b/gemfiles/rails_6_0.gemfile @@ -3,7 +3,9 @@ source "https://rubygems.org" gem "activerecord" +gem "capybara", "< 3.35" gem "cucumber", "< 6" +gem "matrix" gem "psych", "< 4" gem "rails-html-sanitizer", "< 1.4.3" gem "railties", "~> 6.0.3" diff --git a/gemfiles/rails_6_1.gemfile b/gemfiles/rails_6_1.gemfile index d82a1b12..ef23c41d 100644 --- a/gemfiles/rails_6_1.gemfile +++ b/gemfiles/rails_6_1.gemfile @@ -3,7 +3,8 @@ source "https://rubygems.org" gem "activerecord" -gem "cucumber", "< 9" +gem "capybara", "< 3.38" +gem "cucumber", "< 10" gem "psych", "< 4" gem "railties", "~> 6.1.3" gem "sqlite3", "~> 1.4" diff --git a/gemfiles/rails_7_0.gemfile b/gemfiles/rails_7_0.gemfile index 821e2178..a2328f80 100644 --- a/gemfiles/rails_7_0.gemfile +++ b/gemfiles/rails_7_0.gemfile @@ -3,6 +3,7 @@ source "https://rubygems.org" gem "activerecord" +gem "cucumber", "< 10" gem "railties", "~> 7.0.0" gem "sqlite3", "~> 1.4" diff --git a/lib/cucumber/rails/world.rb b/lib/cucumber/rails/world.rb index 42124f8f..846c6ea8 100644 --- a/lib/cucumber/rails/world.rb +++ b/lib/cucumber/rails/world.rb @@ -25,7 +25,7 @@ class World < ::ActionDispatch::IntegrationTest include ActiveSupport::Testing::SetupAndTeardown if ActiveSupport::Testing.const_defined?(:SetupAndTeardown) def initialize - @_result = Test::Unit::TestResult.new if defined?(Test::Unit::TestResult) + super('MiniTest run-name if needed') end unless defined?(ActiveRecord::Base)