Skip to content

Commit

Permalink
Bugfix/cck conformance fix (#1756)
Browse files Browse the repository at this point in the history
* Pin CCK to passing version

* Add new steps

* Spike solution for loading files from cck

* Remove env.rb - add note about bloat of errors checking being 200+ blank objects

* Use path in gem proper for assets

* Remove legacy duplicated assets and DRY up path ref

* Remove duplicate assets for hooks test

* Remove unused retry arguments file

* Fix path to hooks assets

* Rename of steps files to closer align to ruby conventions

* Unrestrict CCK again now fixes are in

* Bump CCK to v16

* Remove redundant require call and fix up attachments to be v16 conformant

* Bump minimum ruby

* Update workflows to ruby 3.0

* Update rubocop to a version to avoid a bug causing execution failure and regenerate TODO

* Changelog entries for v10
  • Loading branch information
luke-hill authored Jul 18, 2024
1 parent d9d6f38 commit f99b285
Show file tree
Hide file tree
Showing 29 changed files with 73 additions and 127 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rubocop.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 1 addition & 8 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
128 changes: 33 additions & 95 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,15 @@
# 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
# versions of RuboCop, may require this file to be generated again.

# 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:
Expand All @@ -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:
Expand All @@ -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.
Expand All @@ -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
Expand All @@ -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:
Expand All @@ -130,46 +90,24 @@ 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:
Exclude:
- '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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion compatibility/cck_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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' }
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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
Binary file removed compatibility/features/attachments/cucumber.jpeg
Binary file not shown.
Binary file removed compatibility/features/attachments/cucumber.png
Binary file not shown.
Binary file removed compatibility/features/attachments/document.pdf
Binary file not shown.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,20 @@
@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

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
7 changes: 0 additions & 7 deletions compatibility/features/hooks/cucumber.svg

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
1 change: 0 additions & 1 deletion compatibility/features/retry/retry.arguments.txt

This file was deleted.

File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions compatibility/support/cck/messages_comparator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions compatibility/support/shared_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading

0 comments on commit f99b285

Please sign in to comment.