From 1055b9a7255d16a1c1b53f660c425c28df682d52 Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Thu, 26 Sep 2024 15:05:19 +0100 Subject: [PATCH 01/20] Bump ruby and gem deps --- cucumber-wire.gemspec | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/cucumber-wire.gemspec b/cucumber-wire.gemspec index e9bd0f0..3dc5f13 100644 --- a/cucumber-wire.gemspec +++ b/cucumber-wire.gemspec @@ -12,21 +12,21 @@ Gem::Specification.new do |s| s.homepage = 'http://cucumber.io' s.platform = Gem::Platform::RUBY s.license = 'MIT' - s.required_ruby_version = '>= 2.6' - s.required_rubygems_version = '>= 3.0.3' + s.required_ruby_version = '>= 3.0' + s.required_rubygems_version = '>= 3.2.8' - s.add_dependency 'cucumber-core', '> 10.1', '< 14' + s.add_dependency 'cucumber-core', '> 11', '< 15' s.add_dependency 'cucumber-cucumber-expressions', '> 14', '< 18' - s.add_development_dependency 'aruba', '~> 2.0' - s.add_development_dependency 'cucumber', '> 7.1', '< 10' - s.add_development_dependency 'rake', '~> 13.1' - s.add_development_dependency 'rspec', '~> 3.12' - s.add_development_dependency 'rubocop', '~> 1.44.1' + s.add_development_dependency 'aruba', '~> 2.2' + s.add_development_dependency 'cucumber', '> 8', '< 10' + s.add_development_dependency 'rake', '~> 13.2' + s.add_development_dependency 'rspec', '~> 3.13' + s.add_development_dependency 'rubocop', '~> 1.66.1' s.add_development_dependency 'rubocop-packaging', '~> 0.5.2' - s.add_development_dependency 'rubocop-performance', '~> 1.17.1' - s.add_development_dependency 'rubocop-rake', '~> 0.5.0' - s.add_development_dependency 'rubocop-rspec', '~> 2.14.2' + s.add_development_dependency 'rubocop-performance', '~> 1.22.1' + s.add_development_dependency 'rubocop-rake', '~> 0.6.0' + s.add_development_dependency 'rubocop-rspec', '~> 3.0.5' s.files = Dir['CHANGELOG.md', 'CHANGELOG.old.md', 'CONTRIBUTING.md', 'README.md', 'LICENSE', 'lib/**/*'] s.rdoc_options = ['--charset=UTF-8'] From e69abdd5e799fa677f6b1ddae51318605454ac3d Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Thu, 26 Sep 2024 15:06:42 +0100 Subject: [PATCH 02/20] Autofi new rubocop offenses --- .rubocop.yml | 5 ++++- features/step_definitions/wire_steps.rb | 2 +- lib/cucumber/wire/data_packet.rb | 2 +- lib/cucumber/wire/exception.rb | 2 +- lib/cucumber/wire/request_handler.rb | 2 +- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 1ace937..9ab2afc 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -7,9 +7,12 @@ require: - rubocop-rspec AllCops: - TargetRubyVersion: 2.6 + TargetRubyVersion: 3.0 NewCops: enable +Gemspec/DevelopmentDependencies: + Enabled: false + # Disabled on our repo's to enable polyglot-release Gemspec/RequireMFA: Enabled: false diff --git a/features/step_definitions/wire_steps.rb b/features/step_definitions/wire_steps.rb index 7118630..6b4893a 100644 --- a/features/step_definitions/wire_steps.rb +++ b/features/step_definitions/wire_steps.rb @@ -2,7 +2,7 @@ Given(/^there is a wire server (running |)on port (\d+) which understands the following protocol:$/) do |running, port, table| protocol = table.hashes.map do |table_hash| - table_hash['response'] = table_hash['response'].gsub(/\n/, '\n') + table_hash['response'] = table_hash['response'].gsub("\n", '\n') table_hash end diff --git a/lib/cucumber/wire/data_packet.rb b/lib/cucumber/wire/data_packet.rb index 6055a49..88fc109 100644 --- a/lib/cucumber/wire/data_packet.rb +++ b/lib/cucumber/wire/data_packet.rb @@ -29,7 +29,7 @@ def to_json end def handle_with(handler) - handler.send("handle_#{@message}", @params) + handler.send(:"handle_#{@message}", @params) end end end diff --git a/lib/cucumber/wire/exception.rb b/lib/cucumber/wire/exception.rb index 8a8ec59..7fa7afe 100644 --- a/lib/cucumber/wire/exception.rb +++ b/lib/cucumber/wire/exception.rb @@ -13,7 +13,7 @@ def to_s end def initialize(args, config) - super args['message'] + super(args['message']) if args['exception'] self.class.extend(CanSetName) diff --git a/lib/cucumber/wire/request_handler.rb b/lib/cucumber/wire/request_handler.rb index a38eeb3..1f92201 100644 --- a/lib/cucumber/wire/request_handler.rb +++ b/lib/cucumber/wire/request_handler.rb @@ -23,7 +23,7 @@ def handle_success(params); end # Props to Rails def underscore(camel_cased_word) - camel_cased_word.to_s.gsub(/::/, '/') + camel_cased_word.to_s.gsub('::', '/') .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2') .gsub(/([a-z\d])([A-Z])/, '\1_\2') .tr('-', '_') From ef39ad1ab2e28f93a1f1d39663b0318da33069e2 Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Thu, 26 Sep 2024 15:08:01 +0100 Subject: [PATCH 03/20] Tweak line breaks for camel case method --- lib/cucumber/wire/request_handler.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/cucumber/wire/request_handler.rb b/lib/cucumber/wire/request_handler.rb index 1f92201..4600671 100644 --- a/lib/cucumber/wire/request_handler.rb +++ b/lib/cucumber/wire/request_handler.rb @@ -23,11 +23,13 @@ def handle_success(params); end # Props to Rails def underscore(camel_cased_word) - camel_cased_word.to_s.gsub('::', '/') - .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2') - .gsub(/([a-z\d])([A-Z])/, '\1_\2') - .tr('-', '_') - .downcase + camel_cased_word + .to_s + .gsub('::', '/') + .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2') + .gsub(/([a-z\d])([A-Z])/, '\1_\2') + .tr('-', '_') + .downcase end end end From 760d8fc38e6aed906f5697d20266a900510c6cf3 Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Thu, 26 Sep 2024 15:12:11 +0100 Subject: [PATCH 04/20] Fix spec into top level ns --- spec/cucumber/wire/connection_spec.rb | 90 ++++++++++++++------------- 1 file changed, 46 insertions(+), 44 deletions(-) diff --git a/spec/cucumber/wire/connection_spec.rb b/spec/cucumber/wire/connection_spec.rb index 9c84b20..44f450a 100644 --- a/spec/cucumber/wire/connection_spec.rb +++ b/spec/cucumber/wire/connection_spec.rb @@ -3,63 +3,65 @@ require 'cucumber/wire/connection' require 'cucumber/wire/configuration' -module Cucumber - module Wire - describe Connection do - class TestConnection < Connection - attr_accessor :socket - end +describe Cucumber::Wire::Connection do + let(:test_connection) do + Class.new(described_class) do + attr_accessor :socket + end + end + + # class TestConnection < Connection + # attr_accessor :socket + # end - class TestConfiguration - attr_reader :custom_timeout + class TestConfiguration + attr_reader :custom_timeout - def initialize - @custom_timeout = {} - end + def initialize + @custom_timeout = {} + end - def timeout(message = nil) - return :default_timeout if message.nil? + def timeout(message = nil) + return :default_timeout if message.nil? - @custom_timeout[message] || Configuration::DEFAULT_TIMEOUTS.fetch(message) - end + @custom_timeout[message] || Cucumber::Wire::Configuration::DEFAULT_TIMEOUTS.fetch(message) + end - def host - 'localhost' - end + def host + 'localhost' + end - def port - '3902' - end - end + def port + '3902' + end + end - before(:each) do - @config = TestConfiguration.new - @connection = TestConnection.new(@config) - @connection.socket = @socket = double('socket').as_null_object - @response = '["response"]' - end + before(:each) do + @config = TestConfiguration.new + @connection = test_connection.new(@config) + @connection.socket = @socket = double('socket').as_null_object + @response = '["response"]' + end - it 're-raises a timeout error' do - allow(Timeout).to receive(:timeout).and_raise(Timeout::Error.new('')) - expect { @connection.call_remote(nil, :foo, []) }.to raise_error(Timeout::Error) - end + it 're-raises a timeout error' do + allow(Timeout).to receive(:timeout).and_raise(Timeout::Error.new('')) + expect { @connection.call_remote(nil, :foo, []) }.to raise_error(Timeout::Error) + end - it 'ignores timeout errors when configured to do so' do - @config.custom_timeout[:foo] = :never + it 'ignores timeout errors when configured to do so' do + @config.custom_timeout[:foo] = :never - allow(@socket).to receive(:gets) { @response } + allow(@socket).to receive(:gets) { @response } - handler = double(handle_response: :response) + handler = double(handle_response: :response) - expect(@connection.call_remote(handler, :foo, [])).to eq(:response) - end + expect(@connection.call_remote(handler, :foo, [])).to eq(:response) + end - it 'raises an exception on remote connection closed' do - @config.custom_timeout[:foo] = :never + it 'raises an exception on remote connection closed' do + @config.custom_timeout[:foo] = :never - allow(@socket).to receive(:gets) - expect { @connection.call_remote(nil, :foo, []) }.to raise_error(Wire::Exception, 'Remote Socket with localhost:3902 closed.') - end - end + allow(@socket).to receive(:gets) + expect { @connection.call_remote(nil, :foo, []) }.to raise_error(Cucumber::Wire::Exception, 'Remote Socket with localhost:3902 closed.') end end From c765d025c13d51a56019e4c48d4d3e33bf1b972b Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Thu, 26 Sep 2024 15:13:38 +0100 Subject: [PATCH 05/20] Migrate to using anonymous classes in let --- spec/cucumber/wire/connection_spec.rb | 32 ++++++++++++--------------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/spec/cucumber/wire/connection_spec.rb b/spec/cucumber/wire/connection_spec.rb index 44f450a..db160f1 100644 --- a/spec/cucumber/wire/connection_spec.rb +++ b/spec/cucumber/wire/connection_spec.rb @@ -9,27 +9,23 @@ attr_accessor :socket end end + let(:test_configuration) do + Class.new do + attr_reader :custom_timeout - # class TestConnection < Connection - # attr_accessor :socket - # end + def initialize + @custom_timeout = {} + end - class TestConfiguration - attr_reader :custom_timeout + def timeout(message = nil) + return :default_timeout if message.nil? - def initialize - @custom_timeout = {} - end - - def timeout(message = nil) - return :default_timeout if message.nil? + @custom_timeout[message] || Cucumber::Wire::Configuration::DEFAULT_TIMEOUTS.fetch(message) + end - @custom_timeout[message] || Cucumber::Wire::Configuration::DEFAULT_TIMEOUTS.fetch(message) - end - - def host - 'localhost' - end + def host + 'localhost' + end def port '3902' @@ -37,7 +33,7 @@ def port end before(:each) do - @config = TestConfiguration.new + @config = test_configuration.new @connection = test_connection.new(@config) @connection.socket = @socket = double('socket').as_null_object @response = '["response"]' From 16a93e94e91de2240833db30728c96f23f746d0b Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Thu, 26 Sep 2024 15:21:07 +0100 Subject: [PATCH 06/20] Remove all iVars from connection spec --- spec/cucumber/wire/connection_spec.rb | 31 ++++++++++++++------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/spec/cucumber/wire/connection_spec.rb b/spec/cucumber/wire/connection_spec.rb index db160f1..d9840ca 100644 --- a/spec/cucumber/wire/connection_spec.rb +++ b/spec/cucumber/wire/connection_spec.rb @@ -4,6 +4,8 @@ require 'cucumber/wire/configuration' describe Cucumber::Wire::Connection do + subject(:connection) { test_connection.new(config) } + let(:test_connection) do Class.new(described_class) do attr_accessor :socket @@ -27,37 +29,36 @@ def host 'localhost' end - def port - '3902' + def port + '3902' + end end end + let(:socket) { double('socket').as_null_object } + let(:config) { test_configuration.new } - before(:each) do - @config = test_configuration.new - @connection = test_connection.new(@config) - @connection.socket = @socket = double('socket').as_null_object - @response = '["response"]' - end + before(:each) { connection.socket = socket } it 're-raises a timeout error' do allow(Timeout).to receive(:timeout).and_raise(Timeout::Error.new('')) - expect { @connection.call_remote(nil, :foo, []) }.to raise_error(Timeout::Error) + + expect { connection.call_remote(nil, :foo, []) }.to raise_error(Timeout::Error) end it 'ignores timeout errors when configured to do so' do - @config.custom_timeout[:foo] = :never + config.custom_timeout[:foo] = :never - allow(@socket).to receive(:gets) { @response } + allow(socket).to receive(:gets).and_return('["response"]') handler = double(handle_response: :response) - expect(@connection.call_remote(handler, :foo, [])).to eq(:response) + expect(connection.call_remote(handler, :foo, [])).to eq(:response) end it 'raises an exception on remote connection closed' do - @config.custom_timeout[:foo] = :never + config.custom_timeout[:foo] = :never + allow(socket).to receive(:gets) - allow(@socket).to receive(:gets) - expect { @connection.call_remote(nil, :foo, []) }.to raise_error(Cucumber::Wire::Exception, 'Remote Socket with localhost:3902 closed.') + expect { connection.call_remote(nil, :foo, []) }.to raise_error(Cucumber::Wire::Exception, 'Remote Socket with localhost:3902 closed.') end end From c40c78956c06b89ca8449b227cc3e064af9e4858 Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Thu, 26 Sep 2024 15:21:46 +0100 Subject: [PATCH 07/20] AF: Lint/ToJSON --- lib/cucumber/wire/data_packet.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cucumber/wire/data_packet.rb b/lib/cucumber/wire/data_packet.rb index 88fc109..3c33d1c 100644 --- a/lib/cucumber/wire/data_packet.rb +++ b/lib/cucumber/wire/data_packet.rb @@ -22,7 +22,7 @@ def initialize(message, params = nil) @message, @params = message, params end - def to_json + def to_json(*_args) packet = [@message] packet << @params if @params JSON.generate(packet) From eed359cb64329cc24db53b91fd969b4154940bcf Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Thu, 26 Sep 2024 15:23:03 +0100 Subject: [PATCH 08/20] AF: Style/BlockDelimiters --- features/step_definitions/wire_steps.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/features/step_definitions/wire_steps.rb b/features/step_definitions/wire_steps.rb index 6b4893a..34c91f1 100644 --- a/features/step_definitions/wire_steps.rb +++ b/features/step_definitions/wire_steps.rb @@ -29,10 +29,10 @@ module WireHelper def start_wire_server @messages_received = [] reader, writer = IO.pipe - @wire_pid = fork { + @wire_pid = fork do reader.close @server.run(writer) - } + end writer.close Thread.new do while message = reader.gets From 9fd5179c59e546298d11a86373931168348a9a08 Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Thu, 26 Sep 2024 15:24:13 +0100 Subject: [PATCH 09/20] Fix up the fake wire server response to use concatenation --- features/support/fake_wire_server.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/support/fake_wire_server.rb b/features/support/fake_wire_server.rb index bad3dd3..9446c4c 100644 --- a/features/support/fake_wire_server.rb +++ b/features/support/fake_wire_server.rb @@ -69,7 +69,7 @@ def response_to(data) end def send_response(response) - @socket.puts response + "\n" + @socket.puts("#{response}\n") end def delay(data) From fe3c2ea8e88a604defcdf52d499b9c14b539becc Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Thu, 26 Sep 2024 15:24:21 +0100 Subject: [PATCH 10/20] Add rake task descriptions --- Rakefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Rakefile b/Rakefile index 545b8b5..3bae795 100644 --- a/Rakefile +++ b/Rakefile @@ -6,10 +6,12 @@ Bundler::GemHelper.install_tasks task default: %i[unit_tests acceptance_tests] +desc 'Unit tests for Cucumber Ruby Wire' task :unit_tests do sh 'bundle exec rspec' end +desc 'Acceptance tests for Cucumber Ruby Wire' task :acceptance_tests do sh 'bundle exec cucumber' end From 27ed02cfab201ac1b82954e337bc3c8d803868c1 Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Thu, 26 Sep 2024 15:24:59 +0100 Subject: [PATCH 11/20] AF: Style/ParallelAssignment --- features/support/fake_wire_server.rb | 3 ++- lib/cucumber/wire/data_packet.rb | 3 ++- lib/cucumber/wire/step_argument.rb | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/features/support/fake_wire_server.rb b/features/support/fake_wire_server.rb index 9446c4c..a7a3c49 100644 --- a/features/support/fake_wire_server.rb +++ b/features/support/fake_wire_server.rb @@ -5,7 +5,8 @@ class FakeWireServer def initialize(port, protocol_table) - @port, @protocol_table = port, protocol_table + @port = port + @protocol_table = protocol_table @delays = {} end diff --git a/lib/cucumber/wire/data_packet.rb b/lib/cucumber/wire/data_packet.rb index 3c33d1c..59365e5 100644 --- a/lib/cucumber/wire/data_packet.rb +++ b/lib/cucumber/wire/data_packet.rb @@ -19,7 +19,8 @@ def parse(raw) attr_reader :message, :params def initialize(message, params = nil) - @message, @params = message, params + @message = message + @params = params end def to_json(*_args) diff --git a/lib/cucumber/wire/step_argument.rb b/lib/cucumber/wire/step_argument.rb index cce7f8d..294119b 100644 --- a/lib/cucumber/wire/step_argument.rb +++ b/lib/cucumber/wire/step_argument.rb @@ -10,7 +10,8 @@ class StepArgument attr_reader :offset def initialize(offset, val) - @offset, @value = offset, val + @offset = offset + @value = val end def value(_current_world) From 2dbe66b4323b6f496a2527dfcb43714c13ea55b6 Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Thu, 26 Sep 2024 15:25:53 +0100 Subject: [PATCH 12/20] Regenerate TODO file with new version of rubocop and some cops fixed --- .rubocop_todo.yml | 69 +++++++---------------------------------------- 1 file changed, 9 insertions(+), 60 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index a660c1f..448983b 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2023-12-21 16:12:21 UTC using RuboCop version 1.44.1. +# on 2024-09-26 14:25:12 UTC using RuboCop version 1.66.1. # 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,30 +8,16 @@ # TODO: Nov '23 -> 25 files inspected, 132 offenses detected, 102 offenses autocorrectable # TODO: Nov '23 -> 25 files inspected, 53 offenses detected, 28 offenses autocorrectable - -# Offense count: 4 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: aligned, indented, indented_relative_to_receiver -Layout/MultilineMethodCallIndentation: - Exclude: - - 'lib/cucumber/wire/request_handler.rb' +# TODO: Sep '24 -> 25 files inspected, 37 offenses detected, 19 offenses autocorrectable # Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). +# This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: AllowSafeAssignment. Lint/AssignmentInCondition: Exclude: - 'features/step_definitions/wire_steps.rb' - 'features/support/fake_wire_server.rb' -# Offense count: 2 -# Configuration parameters: AllowedMethods. -# AllowedMethods: enums -Lint/ConstantDefinitionInBlock: - Exclude: - - 'spec/cucumber/wire/connection_spec.rb' - # Offense count: 1 Lint/RescueException: Exclude: @@ -39,11 +25,7 @@ Lint/RescueException: # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). -Lint/ToJSON: - Exclude: - - 'lib/cucumber/wire/data_packet.rb' - -# Offense count: 1 +# Configuration parameters: AutoCorrect. Lint/UselessAssignment: Exclude: - 'lib/cucumber/wire/connection.rb' @@ -54,12 +36,12 @@ Lint/UselessRescue: - 'features/support/fake_wire_server.rb' # Offense count: 2 -# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, CountRepeatedAttributes. +# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes. Metrics/AbcSize: Max: 21 # Offense count: 2 -# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods. +# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. Metrics/MethodLength: Max: 13 @@ -83,15 +65,13 @@ RSpec/ExampleLength: # Offense count: 6 # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: . +# Configuration parameters: EnforcedStyle. # SupportedStyles: implicit, each, example RSpec/HookArgument: - EnforcedStyle: each - -# Offense count: 2 -RSpec/LeakyConstantDeclaration: Exclude: + - 'spec/cucumber/wire/configuration_spec.rb' - 'spec/cucumber/wire/connection_spec.rb' + - 'spec/cucumber/wire/exception_spec.rb' # Offense count: 3 RSpec/MultipleExpectations: @@ -104,28 +84,12 @@ RSpec/VerifiedDoubles: - 'spec/cucumber/wire/connection_spec.rb' - 'spec/cucumber/wire/connections_spec.rb' -# Offense count: 2 -Rake/Desc: - Exclude: - - 'Rakefile' - # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). Security/YAMLLoad: Exclude: - 'lib/cucumber/wire/configuration.rb' -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, AllowedMethods, AllowedPatterns, IgnoredMethods, AllowBracesOnProceduralOneLiners, BracesRequiredMethods. -# SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces -# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object -# FunctionalMethods: let, let!, subject, watch -# AllowedMethods: lambda, proc, it -Style/BlockDelimiters: - Exclude: - - 'features/step_definitions/wire_steps.rb' - # Offense count: 2 Style/ClassVars: Exclude: @@ -155,14 +119,6 @@ Style/MutableConstant: Exclude: - 'lib/cucumber/wire/configuration.rb' -# Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). -Style/ParallelAssignment: - Exclude: - - 'features/support/fake_wire_server.rb' - - 'lib/cucumber/wire/data_packet.rb' - - 'lib/cucumber/wire/step_argument.rb' - # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). Style/RescueModifier: @@ -183,10 +139,3 @@ Style/RescueStandardError: Style/Semicolon: Exclude: - 'lib/cucumber/wire/connection.rb' - -# Offense count: 1 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: Mode. -Style/StringConcatenation: - Exclude: - - 'features/support/fake_wire_server.rb' From 6cabc659ee127b6dd3f3c3170ff4e4d840a74659 Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Thu, 26 Sep 2024 15:26:55 +0100 Subject: [PATCH 13/20] Update changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bbd529b..e68836e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,9 +10,10 @@ Please visit [cucumber/CONTRIBUTING.md](https://github.com/cucumber/cucumber/blo ## [Unreleased] ### Added -- Added some basic rubocop compliance to suite (More fixes to come) ([#69](https://github.com/cucumber/cucumber-ruby-wire/pull/69) [#70](https://github.com/cucumber/cucumber-ruby-wire/pull/70)) +- Added some basic rubocop compliance to suite (More fixes to come) ([#69](https://github.com/cucumber/cucumber-ruby-wire/pull/69) [#70](https://github.com/cucumber/cucumber-ruby-wire/pull/70) [#71](https://github.com/cucumber/cucumber-ruby-wire/pull/71)) ### Changed +- Minimum ruby version is now 3.0 ([#71](https://github.com/cucumber/cucumber-ruby-wire/pull/71)) ### Fixed From 6c3f93465f5c69b426ab990032cbc478e3f56923 Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Thu, 26 Sep 2024 15:35:11 +0100 Subject: [PATCH 14/20] Update and re-enable workflows --- .github/workflows/release.yaml | 4 ++-- .github/workflows/test.yaml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index bb827e1..2e076d8 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -20,10 +20,10 @@ jobs: strategy: matrix: os: [ubuntu-latest] - ruby: ['2.6', '2.7', '3.0', '3.1', '3.2'] + ruby: ['3.0', '3.1', '3.2', '3.3'] include: - os: macos-latest - ruby: '3.2' + ruby: '3.3' runs-on: ${{ matrix.os }} steps: diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 4bcd20d..52f297c 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,10 +16,10 @@ jobs: strategy: matrix: os: [ubuntu-latest] - ruby: ['2.6', '2.7', '3.0', '3.1', '3.2'] + ruby: ['3.0', '3.1', '3.2', '3.3'] include: - os: macos-latest - ruby: '3.2' + ruby: '3.3' runs-on: ${{ matrix.os }} steps: From 9ac7ddded8b7a650e78a96eb84a29be4f9025f03 Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Thu, 26 Sep 2024 15:35:47 +0100 Subject: [PATCH 15/20] AF: Style/SemiColon --- lib/cucumber/wire/connection.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/cucumber/wire/connection.rb b/lib/cucumber/wire/connection.rb index c9cd606..966ded6 100644 --- a/lib/cucumber/wire/connection.rb +++ b/lib/cucumber/wire/connection.rb @@ -24,7 +24,8 @@ def call_remote(request_handler, message, params) response = fetch_data_from_socket(@config.timeout(message)) response.handle_with(request_handler) rescue Timeout::Error => e - backtrace = e.backtrace; backtrace.shift # because Timeout puts some wierd stuff in there + backtrace = e.backtrace + backtrace.shift # because Timeout puts some wierd stuff in there raise Timeout::Error, "Timed out calling wire server with message '#{message}'", backtrace end end From 1866852a35d61f9e6d31da84a4df13e19c947d7e Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Thu, 26 Sep 2024 15:36:25 +0100 Subject: [PATCH 16/20] AF: Syle/RescueModifier --- lib/cucumber/wire/step_definition.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/cucumber/wire/step_definition.rb b/lib/cucumber/wire/step_definition.rb index 8581dae..03c0533 100644 --- a/lib/cucumber/wire/step_definition.rb +++ b/lib/cucumber/wire/step_definition.rb @@ -11,7 +11,11 @@ def initialize(connection, data, registry) @connection = connection @registry = registry @id = data['id'] - @regexp_source = Regexp.new(data['regexp']) rescue data['regexp'] || 'Unknown' + @regexp_source = begin + Regexp.new(data['regexp']) + rescue StandardError + data['regexp'] || 'Unknown' + end @expression = registry.create_expression(@regexp_source) @location = Core::Test::Location.from_file_colon_line(data['source'] || 'unknown:0') end From e52b71975c8d40e3bc31cd1d2f161302e26df8f4 Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Thu, 26 Sep 2024 15:37:21 +0100 Subject: [PATCH 17/20] AF: Performance/RegexpMatch --- lib/cucumber/wire/configuration.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cucumber/wire/configuration.rb b/lib/cucumber/wire/configuration.rb index 8f08ac5..49ab6b7 100644 --- a/lib/cucumber/wire/configuration.rb +++ b/lib/cucumber/wire/configuration.rb @@ -16,7 +16,7 @@ def self.from_file(wire_file) def initialize(args) @host = args['host'] @port = args['port'] - @unix = args['unix'] if RUBY_PLATFORM !~ /mingw|mswin/ + @unix = args['unix'] unless RUBY_PLATFORM.match?(/mingw|mswin/) @timeouts = DEFAULT_TIMEOUTS.merge(args['timeout'] || {}) end From 738226853f609159e5991b305a6a64e2a107c96f Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Thu, 26 Sep 2024 15:37:53 +0100 Subject: [PATCH 18/20] AF: Naming/RescuedExceptionVariableName --- lib/cucumber/wire/connection.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cucumber/wire/connection.rb b/lib/cucumber/wire/connection.rb index 966ded6..d38ca43 100644 --- a/lib/cucumber/wire/connection.rb +++ b/lib/cucumber/wire/connection.rb @@ -60,7 +60,7 @@ def socket else @socket = TCPSocket.new(@config.host, @config.port) end - rescue Errno::ECONNREFUSED => exception + rescue Errno::ECONNREFUSED => e raise(ConnectionError, "Unable to contact the wire server at #{@config}. Is it up?") end end From 646bec2b0fd40dd468d77af2e076fdbf03870168 Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Thu, 26 Sep 2024 15:38:25 +0100 Subject: [PATCH 19/20] AF: UselessAssignment --- lib/cucumber/wire/connection.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cucumber/wire/connection.rb b/lib/cucumber/wire/connection.rb index d38ca43..9598d1d 100644 --- a/lib/cucumber/wire/connection.rb +++ b/lib/cucumber/wire/connection.rb @@ -60,7 +60,7 @@ def socket else @socket = TCPSocket.new(@config.host, @config.port) end - rescue Errno::ECONNREFUSED => e + rescue Errno::ECONNREFUSED raise(ConnectionError, "Unable to contact the wire server at #{@config}. Is it up?") end end From 107abb4326b1aaee72f69da21eb7f4ecb11e3731 Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Thu, 26 Sep 2024 15:40:58 +0100 Subject: [PATCH 20/20] Update docs --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index da866f1..6b2ad35 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ -[![Test cucumber-wire](https://github.com/cucumber/cucumber-ruby-wire/actions/workflows/cucumber-ruby-wire.yml/badge.svg)](https://github.com/cucumber/cucumber-ruby-wire/actions/workflows/cucumber-ruby-wire.yml) +[![Test cucumber-wire](https://github.com/cucumber/cucumber-ruby-wire/actions/workflows/test.yaml/badge.svg)](https://github.com/cucumber/cucumber-ruby-wire/actions/workflows/test.yaml) # cucumber-wire -This gem was extracted from the [cucumber gem](https://github.com/cucumber/cucumber-ruby), and remains a runtime dependency to that gem. +This gem was extracted from the [cucumber gem](https://github.com/cucumber/cucumber-ruby) -Its tests are a bit hairy and prone to the occasional flicker. +This is available as an optional runtime dependency for cucumber-ruby and also as a runtime dependency for cucumber cpp. -In the future, it may become an opt-in plugin rather than a direct dependency on every Cucumber. +The tests here are a bit hairy and prone to the occasional flicker. ## Configuration