Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V10: Initial rework #1759

Open
wants to merge 28 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
faa6aee
Remove calls to require deprecator that isn't needed
luke-hill Jul 10, 2024
b3aeca5
External programs that wanted to track available and invoked step def…
luke-hill Jul 10, 2024
9ee180f
Fix ordering of class methods in registry and more file
luke-hill Jul 10, 2024
69d9d92
Mark step definition light as ready for deletion
luke-hill Jul 10, 2024
c6cec3a
Curl Option parser is now package private
luke-hill Jul 10, 2024
782c92e
Remove webrick alias that is no longer needed
luke-hill Jul 10, 2024
53c4b2a
Remove tag expression sanitization completely. Proper tag expression …
luke-hill Jul 10, 2024
106487b
Remove a TODO from the generic rubocop config
luke-hill Jul 10, 2024
7f4ec3e
Deprecate use_legacy_autoloader
luke-hill Jul 10, 2024
ad28593
Convert 2 snippets to use heredocs
luke-hill Jul 10, 2024
2f9f501
Fix up snippet generation specs to use the #comment method instead of…
luke-hill Jul 10, 2024
f49eb0d
Remove #append_comment_to
luke-hill Jul 10, 2024
75150d9
Deprecate text? boolean checker in multiline arguments
luke-hill Jul 10, 2024
2815092
Fix deprecator requirement
luke-hill Jul 18, 2024
efa0620
Remove scriipts dir
luke-hill Jul 18, 2024
71f7e26
Update cucumber dependencies
luke-hill Jul 18, 2024
dc1e3f5
Minor rubocop tidy
luke-hill Jul 18, 2024
bd5d4e2
Update changelog
luke-hill Aug 8, 2024
982eddb
Update all dev dependencies aside from rubocop/rubocop-rspec
luke-hill Aug 8, 2024
a365ddb
Bump of runtime dependencies to permit latest
luke-hill Aug 8, 2024
73990c7
Fix ref to unskippable action from core update
luke-hill Aug 12, 2024
855b49d
Fix up references to defined action from core
luke-hill Aug 12, 2024
f4a655d
Permit latest gherkin this end
luke-hill Aug 12, 2024
b732f9b
Permit the next 2 majors for messages - 1 for codegen/dotnet and the …
luke-hill Aug 15, 2024
4ddc410
Bump CCK to latest version - issues to arise
luke-hill Aug 15, 2024
33fd1cb
Merge branch 'main' into refactor/v10_redundant_code
luke-hill Aug 23, 2024
c2b3306
Regenerate the TODO file
luke-hill Aug 23, 2024
0754a59
Merge branch 'main' into refactor/v10_redundant_code
luke-hill Sep 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 31 additions & 5 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2024-07-09 14:33:36 UTC using RuboCop version 1.61.0.
# on 2024-08-23 14:19:17 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
Expand All @@ -10,6 +10,19 @@
# TODO - [LH] -> Dec '23 - 350 files inspected, 595 offenses detected, 171 offenses autocorrectable
# 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
# TODO - [LH] -> Jul '24 - 369 files inspected, 661 offenses detected, 98 offenses autocorrectable

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EmptyLineBetweenMethodDefs, EmptyLineBetweenClassDefs, EmptyLineBetweenModuleDefs, DefLikeMacros, AllowAdjacentOneLineDefs, NumberOfEmptyLines.
Layout/EmptyLineBetweenDefs:
Exclude:
- 'lib/cucumber/glue/snippet.rb'

# Offense count: 2
Lint/IneffectiveAccessModifier:
Exclude:
- 'lib/cucumber/formatter/curl_option_parser.rb'

# Offense count: 4
Lint/RescueException:
Expand All @@ -19,6 +32,13 @@ Lint/RescueException:
- 'lib/cucumber/glue/invoke_in_world.rb'
- 'lib/cucumber/glue/proto_world.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AutoCorrect, ContextCreatingMethods, MethodCreatingMethods.
Lint/UselessAccessModifier:
Exclude:
- 'lib/cucumber/formatter/curl_option_parser.rb'

# Offense count: 2
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: AutoCorrect.
Expand Down Expand Up @@ -90,7 +110,7 @@ RSpec/Capybara/FeatureMethods:
Exclude:
- 'spec/cucumber/filters/activate_steps_spec.rb'

# Offense count: 5
# Offense count: 6
# Configuration parameters: Prefixes, AllowedPatterns.
# Prefixes: when, with, without
RSpec/ContextWording:
Expand All @@ -99,6 +119,7 @@ RSpec/ContextWording:
- 'spec/cucumber/formatter/http_io_spec.rb'
- 'spec/cucumber/formatter/junit_spec.rb'
- 'spec/cucumber/formatter/publish_banner_printer_spec.rb'
- 'spec/cucumber/formatter/query/hook_by_test_step_spec.rb'
- 'spec/support/shared_context/http_server.rb'

# Offense count: 2
Expand Down Expand Up @@ -146,10 +167,11 @@ RSpec/ExpectOutput:
RSpec/HookArgument:
Enabled: false

# Offense count: 8
# Offense count: 26
# Configuration parameters: AssignmentOnly.
RSpec/InstanceVariable:
Exclude:
- 'spec/cucumber/formatter/query/hook_by_test_step_spec.rb'
- 'spec/support/shared_context/http_server.rb'

# Offense count: 5
Expand Down Expand Up @@ -197,6 +219,11 @@ RSpec/NamedSubject:
- 'spec/cucumber/runtime/support_code_spec.rb'
- 'spec/cucumber/runtime_spec.rb'

# Offense count: 2
# Configuration parameters: AllowedGroups.
RSpec/NestedGroups:
Max: 4

# Offense count: 1
RSpec/OverwritingSetup:
Exclude:
Expand Down Expand Up @@ -257,14 +284,13 @@ Style/ClassVars:
Exclude:
- 'spec/cucumber/glue/step_definition_spec.rb'

# Offense count: 2
# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: always, always_true, never
Style/FrozenStringLiteralComment:
Exclude:
- 'spec/support/shared_context/http_server.rb'
- 'spec/support/webrick_proc_handler_alias.rb'

# Offense count: 7
# Configuration parameters: AllowedVariables.
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,24 @@ Please visit [cucumber/CONTRIBUTING.md](https://github.com/cucumber/cucumber/blo
### 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))
- Permit usage of latest versions of all cucumber internal gems
- The auto-generation of all placeholder `pending` steps has been refactored (_There should be no visible changes
but the code is now refactored to work using newer ruby standards_)
- The `#text?` method for checking Differences in multi-line text is now deprecated (Users
should lean on an appropriate testing library for this)
- `Cucumber.use_legacy_autoloader` that was intended as a stop-gap for v4/v5 is now deprecated (People
that need to rely on procedural loading / reloading of files should use method invocations) ([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))
- Fixed an issue for Ruby 3.4.0 where a default hash instantiation was being picked up as keyword arguments ([Jon Rowe](https://github.com/JonRowe))

### Removed
- `StepDefinitionLight` associated methods. The class itself is present but deprecated
- `Webrick` Proc handling aliases that were long redundant
- Associated legacy scripts for updating dependencies that are no longer used
- Tag Expressions using legacy syntax that were handled / sanitized are no longer done so
(This applies to both regular usage and internal testing)
- Removed support for Ruby 2.7 ([luke-hill](https://github.com/luke-hill))

## [9.2.0] - 2024-03-19
Expand Down
16 changes: 8 additions & 8 deletions bin/rspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@
# this file is here to facilitate running it.
#

require "pathname"
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile.local",
require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile.local',
Pathname.new(__FILE__).realpath)

bundle_binstub = File.expand_path("../bundle", __FILE__)
bundle_binstub = File.expand_path('../bundle', __FILE__)

if File.file?(bundle_binstub)
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
load(bundle_binstub)
else
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
abort('Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.')
end
end

require "rubygems"
require "bundler/setup"
require 'rubygems'
require 'bundler/setup'

load Gem.bin_path("rspec-core", "rspec")
load Gem.bin_path('rspec-core', 'rspec')
16 changes: 8 additions & 8 deletions cucumber.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@ Gem::Specification.new do |s|

s.add_dependency 'builder', '~> 3.2'
s.add_dependency 'cucumber-ci-environment', '> 9', '< 11'
s.add_dependency 'cucumber-core', '> 13', '< 14'
s.add_dependency 'cucumber-core', '> 13', '< 15'
s.add_dependency 'cucumber-cucumber-expressions', '~> 17.0'
s.add_dependency 'cucumber-gherkin', '> 24', '< 28'
s.add_dependency 'cucumber-gherkin', '> 24', '< 30'
s.add_dependency 'cucumber-html-formatter', '> 20.3', '< 22'
s.add_dependency 'cucumber-messages', '> 19', '< 26'
s.add_dependency 'cucumber-messages', '> 19', '< 28'
s.add_dependency 'diff-lcs', '~> 1.5'
s.add_dependency 'mini_mime', '~> 1.1'
s.add_dependency 'multi_test', '~> 1.1'
s.add_dependency 'sys-uname', '~> 1.2'
s.add_dependency 'sys-uname', '~> 1.3'

s.add_development_dependency 'cucumber-compatibility-kit', '~> 16.0'
s.add_development_dependency 'cucumber-compatibility-kit', '~> 16.2'
# 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 'nokogiri', '~> 1.15'
s.add_development_dependency 'rake', '~> 13.2'
s.add_development_dependency 'rspec', '~> 3.13'
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'
Expand Down
12 changes: 11 additions & 1 deletion lib/cucumber.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

module Cucumber
class << self
attr_accessor :wants_to_quit, :use_legacy_autoloader
attr_accessor :wants_to_quit
attr_reader :use_legacy_autoloader

def logger
return @log if @log
Expand All @@ -23,5 +24,14 @@ def logger
def logger=(logger)
@log = logger
end

def use_legacy_autoloader=(value)
Cucumber.deprecate(
'This will be phased out of cucumber and should not be used. It is only there to support legacy systems',
'.use_legacy_autoloader',
'11.0.0'
)
@use_legacy_autoloader = value
end
end
end
3 changes: 2 additions & 1 deletion lib/cucumber/formatter/curl_option_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ def self.parse(options)
[url, http_method, headers]
end

# TODO: [LH] -> Switch below methods to private
private

def self.remove_arg_for(args, arg)
return args.shift unless args.empty?

Expand Down
1 change: 0 additions & 1 deletion lib/cucumber/glue/dsl.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

require 'cucumber/cucumber_expressions/parameter_type'
require 'cucumber/deprecate'

module Cucumber
module Glue
Expand Down
25 changes: 2 additions & 23 deletions lib/cucumber/glue/hook.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

require 'cucumber/glue/invoke_in_world'
require 'cucumber/deprecate'

module Cucumber
module Glue
Expand All @@ -12,10 +13,9 @@ def initialize(id, registry, tag_expressions, proc, name: nil)
@id = id
@registry = registry
@name = name
@tag_expressions = sanitize_tag_expressions(tag_expressions)
@tag_expressions = tag_expressions
@proc = proc
@location = Cucumber::Core::Test::Location.from_source_location(*@proc.source_location)
fail_for_old_style_tag_expressions(@tag_expressions)
end

def invoke(pseudo_method, arguments, &block)
Expand Down Expand Up @@ -44,27 +44,6 @@ def to_envelope
)
)
end

private

def sanitize_tag_expressions(tag_expressions)
# TODO: remove when '~@no-clobber' has been changed to 'not @no-clobber' in aruba
tag_expressions.map { |tag_expression| tag_expression == '~@no-clobber' ? 'not @no-clobber' : tag_expression }
end

def fail_for_old_style_tag_expressions(tag_expressions)
tag_expressions.each do |tag_expression|
if tag_expression.include?('~')
raise("Found tagged hook with '#{tag_expression}'." \
"'~@tag' is no longer supported, use 'not @tag' instead.")
end

next unless tag_expression.include?(',')

warn("Found tagged hook with '#{tag_expression}'." \
"'@tag1,@tag2' is no longer supported, use '@tag or @tag2' instead.")
end
end
end
end
end
1 change: 0 additions & 1 deletion lib/cucumber/glue/proto_world.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

require 'cucumber/gherkin/formatter/ansi_escapes'
require 'cucumber/core/test/data_table'
require 'cucumber/deprecate'
require 'mini_mime'

module Cucumber
Expand Down
52 changes: 15 additions & 37 deletions lib/cucumber/glue/registry_and_more.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@

module Cucumber
module Glue
def self.backtrace_line(proc, name)
location = Cucumber::Core::Test::Location.from_source_location(*proc.source_location)
"#{location}:in `#{name}'"
end

# Raised if a World block returns Nil.
class NilWorld < StandardError
def initialize
Expand All @@ -43,8 +48,7 @@ def initialize(first_proc, second_proc)

# TODO: This class has too many responsibilities, split off
class RegistryAndMore
attr_reader :current_world,
:step_definitions
attr_reader :current_world, :step_definitions

all_keywords = ::Gherkin::DIALECTS.keys.map do |dialect_name|
dialect = ::Gherkin::Dialect.for(dialect_name)
Expand All @@ -54,6 +58,14 @@ class RegistryAndMore
Glue::Dsl.alias_adverb(adverb.strip)
end

def self.cli_snippet_type_options
registry = CucumberExpressions::ParameterTypeRegistry.new
cucumber_expression_generator = CucumberExpressions::CucumberExpressionGenerator.new(registry)
Snippet::SNIPPET_TYPES.keys.sort_by(&:to_s).map do |type|
Snippet::SNIPPET_TYPES[type].cli_option_string(type, cucumber_expression_generator)
end
end

def initialize(runtime, configuration)
@runtime = runtime
@configuration = configuration
Expand Down Expand Up @@ -129,8 +141,7 @@ def begin_scenario(test_case)
@current_world = WorldFactory.new(@world_proc).create_world
@current_world.extend(ProtoWorld.for(@runtime, test_case.language))
MultiTest.extend_with_best_assertion_library(@current_world)
@current_world.add_modules!(@world_modules || [],
@namespaced_world_modules || {})
@current_world.add_modules!(@world_modules || [], @namespaced_world_modules || {})
end

def end_scenario
Expand Down Expand Up @@ -168,33 +179,13 @@ def hooks_for(phase, scenario) # :nodoc:
hooks[phase.to_sym].select { |hook| scenario.accept_hook?(hook) }
end

def unmatched_step_definitions
available_step_definition_hash.keys - invoked_step_definition_hash.keys
end

def available_step_definition(regexp_source, file_colon_line)
available_step_definition_hash[StepDefinitionLight.new(regexp_source, file_colon_line)] = nil
end

def invoked_step_definition(regexp_source, file_colon_line)
invoked_step_definition_hash[StepDefinitionLight.new(regexp_source, file_colon_line)] = nil
end

def create_expression(string_or_regexp)
return CucumberExpressions::CucumberExpression.new(string_or_regexp, @parameter_type_registry) if string_or_regexp.is_a?(String)
return CucumberExpressions::RegularExpression.new(string_or_regexp, @parameter_type_registry) if string_or_regexp.is_a?(Regexp)

raise ArgumentError, 'Expression must be a String or Regexp'
end

def self.cli_snippet_type_options
registry = CucumberExpressions::ParameterTypeRegistry.new
cucumber_expression_generator = CucumberExpressions::CucumberExpressionGenerator.new(registry)
Snippet::SNIPPET_TYPES.keys.sort_by(&:to_s).map do |type|
Snippet::SNIPPET_TYPES[type].cli_option_string(type, cucumber_expression_generator)
end
end

private

def parameter_type_envelope(parameter_type)
Expand All @@ -215,22 +206,9 @@ def parameter_type_envelope(parameter_type)
)
end

def available_step_definition_hash
@available_step_definition_hash ||= {}
end

def invoked_step_definition_hash
@invoked_step_definition_hash ||= {}
end

def hooks
@hooks ||= Hash.new { |h, k| h[k] = [] }
end
end

def self.backtrace_line(proc, name)
location = Cucumber::Core::Test::Location.from_source_location(*proc.source_location)
"#{location}:in `#{name}'"
end
end
end
Loading
Loading