From d65041812558df6d1287b7b39083c0cf9d9c586a Mon Sep 17 00:00:00 2001 From: aurelien-reeves Date: Wed, 4 Aug 2021 15:58:51 +0200 Subject: [PATCH 01/38] Upgrade Rubocop to 0.92 --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index b0bf7d3a79..8714768739 100644 --- a/Gemfile +++ b/Gemfile @@ -27,6 +27,6 @@ is_windows = !!(RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/) # rubocop:enable Style/DoubleNegation install_if -> { !is_windows } do - gem 'rubocop', '~> 0.89', '= 0.89.1' + gem 'rubocop', '~> 0.92', '= 0.92.0' gem 'rubocop-packaging', '~> 0.3', '= 0.5.1' end From 9dc538da343f0e6764435ab5c66fe87e384f9fad Mon Sep 17 00:00:00 2001 From: aurelien-reeves Date: Wed, 4 Aug 2021 15:59:35 +0200 Subject: [PATCH 02/38] Fix offence: explicitely extend Object class --- lib/cucumber/glue/dsl.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/cucumber/glue/dsl.rb b/lib/cucumber/glue/dsl.rb index 01de78f976..3879c7629d 100644 --- a/lib/cucumber/glue/dsl.rb +++ b/lib/cucumber/glue/dsl.rb @@ -136,5 +136,7 @@ def register_rb_step_definition(regexp, symbol = nil, options = {}, &proc) end end -# TODO: can we avoid adding methods to the global namespace (Kernel) -extend(Cucumber::Glue::Dsl) +class Object + # TODO: can we avoid adding methods to the global namespace (Kernel) + prepend(Cucumber::Glue::Dsl) +end From 829c0f6ce2ad17d7dadc23f7aa3cfb0fdfe0b5a8 Mon Sep 17 00:00:00 2001 From: aurelien-reeves Date: Thu, 5 Aug 2021 14:30:34 +0200 Subject: [PATCH 03/38] Restore the extension of the global namespace Ignore rubocop for that specific line And added comments to explain why. --- lib/cucumber/glue/dsl.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/cucumber/glue/dsl.rb b/lib/cucumber/glue/dsl.rb index 3879c7629d..61b2db2d56 100644 --- a/lib/cucumber/glue/dsl.rb +++ b/lib/cucumber/glue/dsl.rb @@ -136,7 +136,8 @@ def register_rb_step_definition(regexp, symbol = nil, options = {}, &proc) end end -class Object - # TODO: can we avoid adding methods to the global namespace (Kernel) - prepend(Cucumber::Glue::Dsl) -end +# rubocop:disable Style/MixinUsage +# This "should" always be present, because it allows users to write `Before` and `After` +# See. https://github.com/cucumber/cucumber-ruby/pull/1566#discussion_r683235396 +extend(Cucumber::Glue::Dsl) +# rubocop:enable Style/MixinUsage From 1d5e4633ae658d816f076e17007dc712a7b7a9a4 Mon Sep 17 00:00:00 2001 From: aurelien-reeves Date: Thu, 5 Aug 2021 14:42:44 +0200 Subject: [PATCH 04/38] Upgrade rubocop to 1.0 --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index a0dfa37753..b2716f96e9 100644 --- a/Gemfile +++ b/Gemfile @@ -21,5 +21,5 @@ gem 'cucumber-gherkin', path: ENV['GHERKIN_RUBY'] if ENV['GHERKIN_RUBY'] gem 'cucumber-html-formatter', path: ENV['CUCUMBER_HTML_FORMATTER_RUBY'] if ENV['CUCUMBER_HTML_FORMATTER_RUBY'] gem 'cucumber-messages', path: ENV['CUCUMBER_MESSAGES_RUBY'] if ENV['CUCUMBER_MESSAGES_RUBY'] -gem 'rubocop', '~> 0.92', '= 0.92.0' +gem 'rubocop', '~> 1.0', '= 1.0.0' gem 'rubocop-packaging', '~> 0.3', '= 0.5.1' From 2be14aebb3bc704ac787cf6747d67b9e9a2d1441 Mon Sep 17 00:00:00 2001 From: aurelien-reeves Date: Thu, 5 Aug 2021 14:42:59 +0200 Subject: [PATCH 05/38] Apply safe auto-correct --- .../hu/features/step_definitions/calculator_steps.rb | 4 ++-- lib/cucumber/cli/options.rb | 2 +- lib/cucumber/events/hook_test_step_created.rb | 3 +-- lib/cucumber/events/test_case_created.rb | 3 +-- lib/cucumber/events/test_step_created.rb | 3 +-- lib/cucumber/events/undefined_parameter_type.rb | 3 +-- lib/cucumber/filters/tag_limits.rb | 4 +--- lib/cucumber/filters/tag_limits/verifier.rb | 4 +--- lib/cucumber/formatter/ansicolor.rb | 2 ++ lib/cucumber/formatter/ast_lookup.rb | 3 +-- lib/cucumber/formatter/console.rb | 1 + lib/cucumber/formatter/duration_extractor.rb | 1 + lib/cucumber/formatter/junit.rb | 1 + lib/cucumber/formatter/pretty.rb | 4 +--- lib/cucumber/glue/registry_and_more.rb | 2 +- lib/cucumber/glue/step_definition.rb | 3 +-- lib/cucumber/multiline_argument/data_table.rb | 9 +++++---- lib/cucumber/rake/task.rb | 1 + spec/cucumber/glue/registry_and_more_spec.rb | 2 +- spec/cucumber/glue/step_definition_spec.rb | 4 ++-- 20 files changed, 27 insertions(+), 32 deletions(-) diff --git a/examples/i18n/hu/features/step_definitions/calculator_steps.rb b/examples/i18n/hu/features/step_definitions/calculator_steps.rb index ec6f0e3d3d..681ac6c557 100644 --- a/examples/i18n/hu/features/step_definitions/calculator_steps.rb +++ b/examples/i18n/hu/features/step_definitions/calculator_steps.rb @@ -15,7 +15,7 @@ After do end -Ha(/^beütök a számológépbe egy (\d+)\-(?:es|as|ös|ás)t$/) do |n| +Ha(/^beütök a számológépbe egy (\d+)-(?:es|as|ös|ás)t$/) do |n| @calc.push n.to_i end @@ -23,6 +23,6 @@ @result = @calc.send op end -Akkor(/^eredményül (.*)\-(?:e|a|ö|á|)t kell kapnom$/) do |result| +Akkor(/^eredményül (.*)-(?:e|a|ö|á|)t kell kapnom$/) do |result| expect(@result).to eq(result.to_f) end diff --git a/lib/cucumber/cli/options.rb b/lib/cucumber/cli/options.rb index 233bfd5aa4..e996cfdc74 100644 --- a/lib/cucumber/cli/options.rb +++ b/lib/cucumber/cli/options.rb @@ -63,7 +63,7 @@ class Options '--lines', '--port', '-I', '--snippet-type' ].freeze ORDER_TYPES = %w[defined random].freeze - TAG_LIMIT_MATCHER = /(?\@\w+):(?\d+)/x + TAG_LIMIT_MATCHER = /(?@\w+):(?\d+)/x def self.parse(args, out_stream, error_stream, options = {}) new(out_stream, error_stream, options).parse!(args) diff --git a/lib/cucumber/events/hook_test_step_created.rb b/lib/cucumber/events/hook_test_step_created.rb index 2f3941066c..4e1596dcbd 100644 --- a/lib/cucumber/events/hook_test_step_created.rb +++ b/lib/cucumber/events/hook_test_step_created.rb @@ -6,8 +6,7 @@ module Cucumber module Events # Event fired when a step is created from a hook class HookTestStepCreated < Core::Event.new(:test_step, :hook) - attr_reader :test_step - attr_reader :hook + attr_reader :test_step, :hook end end end diff --git a/lib/cucumber/events/test_case_created.rb b/lib/cucumber/events/test_case_created.rb index bd682f97c6..c23e2a9d6e 100644 --- a/lib/cucumber/events/test_case_created.rb +++ b/lib/cucumber/events/test_case_created.rb @@ -6,8 +6,7 @@ module Cucumber module Events # Event fired when a Test::Case is created from a Pickle class TestCaseCreated < Core::Event.new(:test_case, :pickle) - attr_reader :test_case - attr_reader :pickle + attr_reader :test_case, :pickle end end end diff --git a/lib/cucumber/events/test_step_created.rb b/lib/cucumber/events/test_step_created.rb index 4d645354b2..577d8f831f 100644 --- a/lib/cucumber/events/test_step_created.rb +++ b/lib/cucumber/events/test_step_created.rb @@ -6,8 +6,7 @@ module Cucumber module Events # Event fired when a TestStep is created from a PickleStep class TestStepCreated < Core::Event.new(:test_step, :pickle_step) - attr_reader :test_step - attr_reader :pickle_step + attr_reader :test_step, :pickle_step end end end diff --git a/lib/cucumber/events/undefined_parameter_type.rb b/lib/cucumber/events/undefined_parameter_type.rb index 8b6e21f4e0..59ae1a61b1 100644 --- a/lib/cucumber/events/undefined_parameter_type.rb +++ b/lib/cucumber/events/undefined_parameter_type.rb @@ -3,8 +3,7 @@ module Cucumber module Events class UndefinedParameterType < Core::Event.new(:type_name, :expression) - attr_reader :type_name - attr_reader :expression + attr_reader :type_name, :expression end end end diff --git a/lib/cucumber/filters/tag_limits.rb b/lib/cucumber/filters/tag_limits.rb index d4a7f78e62..d3f851bb29 100644 --- a/lib/cucumber/filters/tag_limits.rb +++ b/lib/cucumber/filters/tag_limits.rb @@ -38,9 +38,7 @@ def with_receiver(receiver) private - attr_reader :gated_receiver - attr_reader :test_case_index - attr_reader :verifier + attr_reader :gated_receiver, :test_case_index, :verifier end end end diff --git a/lib/cucumber/filters/tag_limits/verifier.rb b/lib/cucumber/filters/tag_limits/verifier.rb index 56ec38d5c5..99d4db0bbc 100644 --- a/lib/cucumber/filters/tag_limits/verifier.rb +++ b/lib/cucumber/filters/tag_limits/verifier.rb @@ -47,9 +47,7 @@ def tag_count locations.count end - attr_reader :tag_name - attr_reader :limit - attr_reader :locations + attr_reader :tag_name, :limit, :locations end end end diff --git a/lib/cucumber/formatter/ansicolor.rb b/lib/cucumber/formatter/ansicolor.rb index 29be8e86ef..8e6f60e184 100644 --- a/lib/cucumber/formatter/ansicolor.rb +++ b/lib/cucumber/formatter/ansicolor.rb @@ -108,6 +108,7 @@ def self.define_grey #:nodoc: define_real_grey end rescue Exception => e # rubocop:disable Lint/RescueException + # rubocop:disable Style/ClassEqualityComparison if e.class.name == 'TermInfo::TermInfoError' STDERR.puts '*** WARNING ***' STDERR.puts "You have the genki-ruby-terminfo gem installed, but you haven't set your TERM variable." @@ -117,6 +118,7 @@ def self.define_grey #:nodoc: else define_real_grey end + # rubocop:enable Style/ClassEqualityComparison end def self.define_real_grey #:nodoc: diff --git a/lib/cucumber/formatter/ast_lookup.rb b/lib/cucumber/formatter/ast_lookup.rb index 4d97354348..e24ca2410d 100644 --- a/lib/cucumber/formatter/ast_lookup.rb +++ b/lib/cucumber/formatter/ast_lookup.rb @@ -48,8 +48,7 @@ def snippet_step_keyword(test_step) node = node.previous_node end keyword = dialect.given_keywords.reject { |kw| kw == '* ' }[0] if keyword.nil? - keyword = Cucumber::Gherkin::I18n.code_keyword_for(keyword) - keyword + Cucumber::Gherkin::I18n.code_keyword_for(keyword) end ScenarioSource = Struct.new(:type, :scenario) diff --git a/lib/cucumber/formatter/console.rb b/lib/cucumber/formatter/console.rb index fa4c439c44..8213227f8b 100644 --- a/lib/cucumber/formatter/console.rb +++ b/lib/cucumber/formatter/console.rb @@ -246,6 +246,7 @@ def snippet_text(step_keyword, step_name, multiline_arg) class SnippetData attr_reader :actual_keyword, :step + def initialize(actual_keyword, step) @actual_keyword = actual_keyword @step = step diff --git a/lib/cucumber/formatter/duration_extractor.rb b/lib/cucumber/formatter/duration_extractor.rb index ab35b61bbb..5917c272ef 100644 --- a/lib/cucumber/formatter/duration_extractor.rb +++ b/lib/cucumber/formatter/duration_extractor.rb @@ -4,6 +4,7 @@ module Cucumber module Formatter class DurationExtractor attr_reader :result_duration + def initialize(result) @result_duration = 0 result.describe_to(self) diff --git a/lib/cucumber/formatter/junit.rb b/lib/cucumber/formatter/junit.rb index e88d9be67f..07899fc75f 100644 --- a/lib/cucumber/formatter/junit.rb +++ b/lib/cucumber/formatter/junit.rb @@ -235,6 +235,7 @@ def examples_table_row(row) class ResultBuilder attr_reader :test_case_duration + def initialize(result) @test_case_duration = 0 result.describe_to(self) diff --git a/lib/cucumber/formatter/pretty.rb b/lib/cucumber/formatter/pretty.rb index a15f7ddf7e..671c936b0d 100644 --- a/lib/cucumber/formatter/pretty.rb +++ b/lib/cucumber/formatter/pretty.rb @@ -24,11 +24,9 @@ class Pretty # rubocop:disable Metrics/ClassLength include Console include Io include Cucumber::Gherkin::Formatter::Escaping - attr_reader :config, :options + attr_reader :config, :options, :current_feature_uri, :current_scenario_outline, :current_examples, :current_test_case, :in_scenario_outline, :print_background_steps private :config, :options - attr_reader :current_feature_uri, :current_scenario_outline, :current_examples, :current_test_case private :current_feature_uri, :current_scenario_outline, :current_examples, :current_test_case - attr_reader :in_scenario_outline, :print_background_steps private :in_scenario_outline, :print_background_steps def initialize(config) diff --git a/lib/cucumber/glue/registry_and_more.rb b/lib/cucumber/glue/registry_and_more.rb index ff49746e55..d479e8b209 100644 --- a/lib/cucumber/glue/registry_and_more.rb +++ b/lib/cucumber/glue/registry_and_more.rb @@ -91,7 +91,7 @@ def register_rb_step_definition(string_or_regexp, proc_or_sym, options) step_definition rescue Cucumber::CucumberExpressions::UndefinedParameterTypeError => e # TODO: add a way to extract the parameter type directly from the error. - type_name = e.message.match(/^Undefined parameter type ['|\{](.*)['|\}].?$/)[1] + type_name = e.message.match(/^Undefined parameter type ['|{](.*)['|}].?$/)[1] @configuration.notify :undefined_parameter_type, type_name, string_or_regexp end diff --git a/lib/cucumber/glue/step_definition.rb b/lib/cucumber/glue/step_definition.rb index ea214f589a..31e8391cfd 100644 --- a/lib/cucumber/glue/step_definition.rb +++ b/lib/cucumber/glue/step_definition.rb @@ -122,9 +122,8 @@ def ==(other) # @api private def arguments_from(step_name) - args = @expression.match(step_name) + @expression.match(step_name) # @registry.invoked_step_definition(regexp_source, location) if args - args end # @api private diff --git a/lib/cucumber/multiline_argument/data_table.rb b/lib/cucumber/multiline_argument/data_table.rb index 5741ca3308..f8461cc181 100644 --- a/lib/cucumber/multiline_argument/data_table.rb +++ b/lib/cucumber/multiline_argument/data_table.rb @@ -346,6 +346,7 @@ def diff!(other_table, options = {}) class Different < StandardError attr_reader :table + def initialize(table) @table = table super("Tables were not identical:\n#{table}") @@ -475,10 +476,10 @@ def build_hashes def create_cell_matrix(ast_table) #:nodoc: ast_table.raw.map do |raw_row| line = begin - raw_row.line - rescue StandardError - -1 - end + raw_row.line + rescue StandardError + -1 + end raw_row.map do |raw_cell| Cell.new(raw_cell, self, line) end diff --git a/lib/cucumber/rake/task.rb b/lib/cucumber/rake/task.rb index a072f0a772..eb4124039d 100644 --- a/lib/cucumber/rake/task.rb +++ b/lib/cucumber/rake/task.rb @@ -110,6 +110,7 @@ def run # Extra options to pass to the cucumber binary. Can be overridden by the CUCUMBER_OPTS environment variable. # It's recommended to pass an Array, but if it's a String it will be #split by ' '. attr_reader :cucumber_opts + def cucumber_opts=(opts) #:nodoc: @cucumber_opts = String == opts.class ? opts.split(' ') : opts end diff --git a/spec/cucumber/glue/registry_and_more_spec.rb b/spec/cucumber/glue/registry_and_more_spec.rb index fe516c2603..4124e06d9b 100644 --- a/spec/cucumber/glue/registry_and_more_spec.rb +++ b/spec/cucumber/glue/registry_and_more_spec.rb @@ -144,7 +144,7 @@ def a_file_called(name) rescue Glue::NilWorld => e expect(e.message).to eq 'World procs should never return nil' expect(e.backtrace.length).to eq 1 - expect(e.backtrace[0]).to match(/spec\/cucumber\/glue\/registry_and_more_spec\.rb\:\d+\:in `World'/) # rubocop:disable Style/RegexpLiteral + expect(e.backtrace[0]).to match(/spec\/cucumber\/glue\/registry_and_more_spec\.rb:\d+:in `World'/) # rubocop:disable Style/RegexpLiteral end end diff --git a/spec/cucumber/glue/step_definition_spec.rb b/spec/cucumber/glue/step_definition_spec.rb index 3bc2faedd5..65b42a39cf 100644 --- a/spec/cucumber/glue/step_definition_spec.rb +++ b/spec/cucumber/glue/step_definition_spec.rb @@ -166,8 +166,8 @@ def step_match(text) context 'with ParameterType' do class Actor - attr_reader :name - attr_writer :name + attr_accessor :name + def initialize(name) @name = name end From 1917f85b8c33c8e38a1dbf32019e032f9abfd68f Mon Sep 17 00:00:00 2001 From: aurelien-reeves Date: Thu, 5 Aug 2021 14:46:49 +0200 Subject: [PATCH 06/38] Apply unsafe autocorrect --- Rakefile | 2 +- examples/i18n/Rakefile | 2 +- examples/i18n/ar/Rakefile | 2 +- .../step_definitions/calculator_steps.rb | 2 +- examples/i18n/bg/Rakefile | 2 +- examples/i18n/bg/features/support/env.rb | 2 +- examples/i18n/ca/Rakefile | 2 +- .../step_definitions/calculator_steps.rb | 2 +- examples/i18n/cs/Rakefile | 2 +- .../step_definitions/calculator_steps.rb | 2 +- examples/i18n/da/Rakefile | 2 +- .../step_definitions/lommeregner_steps.rb | 2 +- examples/i18n/de/Rakefile | 2 +- .../step_definitions/calculator_steps.rb | 2 +- examples/i18n/el/Rakefile | 2 +- .../step_definitions/calculator_steps.rb | 2 +- examples/i18n/en-lol/Rakefile | 2 +- examples/i18n/en-lol/features/support/env.rb | 2 +- examples/i18n/en/Rakefile | 2 +- .../step_definitions/calculator_steps.rb | 2 +- examples/i18n/eo/Rakefile | 2 +- .../step_definitions/calculator_steps.rb | 2 +- examples/i18n/es/Rakefile | 2 +- .../step_definitions/calculador_steps.rb | 2 +- examples/i18n/et/Rakefile | 2 +- .../step_definitions/kalkulaator_steps.rb | 2 +- examples/i18n/fi/Rakefile | 2 +- .../fi/features/step_definitions/laskin_steps.rb | 2 +- examples/i18n/fr/Rakefile | 2 +- examples/i18n/fr/features/support/env.rb | 2 +- examples/i18n/he/Rakefile | 2 +- .../step_definitions/calculator_steps.rb | 2 +- examples/i18n/hi/Rakefile | 2 +- .../step_definitions/calculator_steps.rb | 2 +- examples/i18n/ht/Rakefile | 2 +- .../step_definitions/kalkilatris_steps.rb | 2 +- examples/i18n/hu/Rakefile | 2 +- .../step_definitions/calculator_steps.rb | 2 +- examples/i18n/id/Rakefile | 2 +- .../step_definitions/calculator_steps.rb | 2 +- examples/i18n/it/Rakefile | 2 +- .../step_definitions/calcolatrice_steps.rb | 2 +- examples/i18n/ja/Rakefile | 2 +- examples/i18n/ja/features/support/env.rb | 2 +- examples/i18n/ko/Rakefile | 2 +- .../step_definitions/calculator_steps.rb | 2 +- examples/i18n/lt/Rakefile | 2 +- .../step_definitions/calculator_steps.rb | 2 +- examples/i18n/lv/Rakefile | 2 +- .../step_definitions/calculator_steps.rb | 2 +- examples/i18n/no/Rakefile | 2 +- examples/i18n/no/features/support/env.rb | 2 +- examples/i18n/pl/Rakefile | 2 +- .../step_definitions/calculator_steps.rb | 2 +- examples/i18n/pl/features/support/env.rb | 2 +- examples/i18n/pt/Rakefile | 2 +- examples/i18n/pt/features/support/env.rb | 2 +- examples/i18n/ro/Rakefile | 2 +- .../step_definitions/calculator_steps.rb | 2 +- examples/i18n/ru/Rakefile | 2 +- examples/i18n/ru/features/support/env.rb | 2 +- examples/i18n/sk/Rakefile | 2 +- .../step_definitions/calculator_steps.rb | 2 +- examples/i18n/sr-Cyrl/Rakefile | 2 +- examples/i18n/sr-Cyrl/features/support/env.rb | 2 +- examples/i18n/sr-Latn/Rakefile | 2 +- .../step_definitions/calculator_steps.rb | 2 +- examples/i18n/sv/Rakefile | 2 +- .../step_definitions/kalkulator_steps.rb | 2 +- examples/i18n/tr/Rakefile | 2 +- .../step_definitions/hesap_makinesi_adimlari.rb | 2 +- examples/i18n/uk/Rakefile | 2 +- examples/i18n/uk/features/support/env.rb | 2 +- examples/i18n/uz/Rakefile | 2 +- examples/i18n/uz/features/support/env.rb | 2 +- examples/i18n/zh-CN/Rakefile | 2 +- .../step_definitions/calculator_steps.rb | 2 +- examples/i18n/zh-TW/Rakefile | 2 +- .../step_definitions/calculator_steps.rb | 2 +- examples/rspec_doubles/Rakefile | 2 +- examples/sinatra/Rakefile | 2 +- examples/sinatra/features/support/env.rb | 2 +- examples/tcl/Rakefile | 2 +- examples/tcl/features/support/env.rb | 2 +- examples/test_unit/Rakefile | 2 +- features/lib/step_definitions/junit_steps.rb | 2 +- features/lib/support/command_line.rb | 4 ++-- features/lib/support/fake_wire_server.rb | 2 +- gem_tasks/downloads.rb | 2 +- lib/autotest/discover.rb | 5 +++-- lib/cucumber.rb | 2 +- lib/cucumber/cli/configuration.rb | 2 +- lib/cucumber/cli/main.rb | 6 +++--- lib/cucumber/cli/options.rb | 2 +- lib/cucumber/deprecate.rb | 2 +- lib/cucumber/events.rb | 2 +- lib/cucumber/formatter/ansicolor.rb | 16 ++++++++-------- lib/cucumber/formatter/console.rb | 2 +- lib/cucumber/formatter/json.rb | 2 +- lib/cucumber/formatter/junit.rb | 4 ++-- lib/cucumber/formatter/pretty.rb | 2 +- lib/cucumber/formatter/unicode.rb | 8 ++++---- lib/cucumber/formatter/usage.rb | 6 +++--- lib/cucumber/gherkin/formatter/ansi_escapes.rb | 4 ++-- lib/cucumber/glue/invoke_in_world.rb | 2 +- lib/cucumber/glue/proto_world.rb | 6 ------ lib/cucumber/multiline_argument/data_table.rb | 6 +++--- lib/cucumber/platform.rb | 4 ++-- lib/cucumber/runtime/user_interface.rb | 8 ++++---- lib/simplecov_setup.rb | 2 +- scripts/update-changelog | 2 +- spec/cucumber/deprecate_spec.rb | 4 ++-- spec/cucumber/formatter/http_io_spec.rb | 2 ++ 113 files changed, 139 insertions(+), 142 deletions(-) diff --git a/Rakefile b/Rakefile index b3ec94d312..949a5d79e5 100644 --- a/Rakefile +++ b/Rakefile @@ -3,7 +3,7 @@ require 'bundler' Bundler::GemHelper.install_tasks -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/lib") Dir['gem_tasks/**/*.rake'].each { |rake| load rake } require 'rubocop/rake_task' diff --git a/examples/i18n/Rakefile b/examples/i18n/Rakefile index d73e063286..8b4a9c90c9 100644 --- a/examples/i18n/Rakefile +++ b/examples/i18n/Rakefile @@ -6,7 +6,7 @@ task :cucumber do lang = f[dir.length + 1..-1] message = examples_disabled?(lang) unless message.nil? - STDERR.puts(message) + $stderr.puts(message) next end diff --git a/examples/i18n/ar/Rakefile b/examples/i18n/ar/Rakefile index c6d57867f8..47e3afe93d 100644 --- a/examples/i18n/ar/Rakefile +++ b/examples/i18n/ar/Rakefile @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../../lib") require 'cucumber/rake/task' Cucumber::Rake::Task.new do |t| diff --git a/examples/i18n/ar/features/step_definitions/calculator_steps.rb b/examples/i18n/ar/features/step_definitions/calculator_steps.rb index 8a7041ffc6..48a7903018 100644 --- a/examples/i18n/ar/features/step_definitions/calculator_steps.rb +++ b/examples/i18n/ar/features/step_definitions/calculator_steps.rb @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib") require 'calculator' Before do diff --git a/examples/i18n/bg/Rakefile b/examples/i18n/bg/Rakefile index c6d57867f8..47e3afe93d 100644 --- a/examples/i18n/bg/Rakefile +++ b/examples/i18n/bg/Rakefile @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../../lib") require 'cucumber/rake/task' Cucumber::Rake::Task.new do |t| diff --git a/examples/i18n/bg/features/support/env.rb b/examples/i18n/bg/features/support/env.rb index 26467b505c..0f358a1e66 100644 --- a/examples/i18n/bg/features/support/env.rb +++ b/examples/i18n/bg/features/support/env.rb @@ -5,5 +5,5 @@ end require 'cucumber/formatter/unicode' -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib") require 'calculator' diff --git a/examples/i18n/ca/Rakefile b/examples/i18n/ca/Rakefile index c6d57867f8..47e3afe93d 100644 --- a/examples/i18n/ca/Rakefile +++ b/examples/i18n/ca/Rakefile @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../../lib") require 'cucumber/rake/task' Cucumber::Rake::Task.new do |t| diff --git a/examples/i18n/ca/features/step_definitions/calculator_steps.rb b/examples/i18n/ca/features/step_definitions/calculator_steps.rb index 68d8632de9..cdf39a4de9 100644 --- a/examples/i18n/ca/features/step_definitions/calculator_steps.rb +++ b/examples/i18n/ca/features/step_definitions/calculator_steps.rb @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib") require 'calculadora' Before do diff --git a/examples/i18n/cs/Rakefile b/examples/i18n/cs/Rakefile index c6d57867f8..47e3afe93d 100644 --- a/examples/i18n/cs/Rakefile +++ b/examples/i18n/cs/Rakefile @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../../lib") require 'cucumber/rake/task' Cucumber::Rake::Task.new do |t| diff --git a/examples/i18n/cs/features/step_definitions/calculator_steps.rb b/examples/i18n/cs/features/step_definitions/calculator_steps.rb index e17cddcae8..aef3c1d83f 100644 --- a/examples/i18n/cs/features/step_definitions/calculator_steps.rb +++ b/examples/i18n/cs/features/step_definitions/calculator_steps.rb @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib") require 'calculator' Before do diff --git a/examples/i18n/da/Rakefile b/examples/i18n/da/Rakefile index c6d57867f8..47e3afe93d 100644 --- a/examples/i18n/da/Rakefile +++ b/examples/i18n/da/Rakefile @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../../lib") require 'cucumber/rake/task' Cucumber::Rake::Task.new do |t| diff --git a/examples/i18n/da/features/step_definitions/lommeregner_steps.rb b/examples/i18n/da/features/step_definitions/lommeregner_steps.rb index bc76cce938..2de00fb1c6 100644 --- a/examples/i18n/da/features/step_definitions/lommeregner_steps.rb +++ b/examples/i18n/da/features/step_definitions/lommeregner_steps.rb @@ -5,7 +5,7 @@ end require 'cucumber/formatter/unicode' -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib") require 'lommeregner' Before do diff --git a/examples/i18n/de/Rakefile b/examples/i18n/de/Rakefile index c6d57867f8..47e3afe93d 100644 --- a/examples/i18n/de/Rakefile +++ b/examples/i18n/de/Rakefile @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../../lib") require 'cucumber/rake/task' Cucumber::Rake::Task.new do |t| diff --git a/examples/i18n/de/features/step_definitions/calculator_steps.rb b/examples/i18n/de/features/step_definitions/calculator_steps.rb index 6eede6147a..35e4a3cbc0 100644 --- a/examples/i18n/de/features/step_definitions/calculator_steps.rb +++ b/examples/i18n/de/features/step_definitions/calculator_steps.rb @@ -5,7 +5,7 @@ end require 'cucumber/formatter/unicode' -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib") require 'calculator' Before do diff --git a/examples/i18n/el/Rakefile b/examples/i18n/el/Rakefile index c6d57867f8..47e3afe93d 100644 --- a/examples/i18n/el/Rakefile +++ b/examples/i18n/el/Rakefile @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../../lib") require 'cucumber/rake/task' Cucumber::Rake::Task.new do |t| diff --git a/examples/i18n/el/features/step_definitions/calculator_steps.rb b/examples/i18n/el/features/step_definitions/calculator_steps.rb index 06f03f5d0d..2ad00c9060 100644 --- a/examples/i18n/el/features/step_definitions/calculator_steps.rb +++ b/examples/i18n/el/features/step_definitions/calculator_steps.rb @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib") require 'calculator' Before do diff --git a/examples/i18n/en-lol/Rakefile b/examples/i18n/en-lol/Rakefile index c701ead40d..a7c622f6af 100644 --- a/examples/i18n/en-lol/Rakefile +++ b/examples/i18n/en-lol/Rakefile @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../../lib") require 'cucumber/rake/task' Cucumber::Rake::Task.new diff --git a/examples/i18n/en-lol/features/support/env.rb b/examples/i18n/en-lol/features/support/env.rb index 2e3f587cb0..928b3784a5 100644 --- a/examples/i18n/en-lol/features/support/env.rb +++ b/examples/i18n/en-lol/features/support/env.rb @@ -5,6 +5,6 @@ end require 'cucumber/formatter/unicode' -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib") require 'basket' require 'belly' diff --git a/examples/i18n/en/Rakefile b/examples/i18n/en/Rakefile index c6d57867f8..47e3afe93d 100644 --- a/examples/i18n/en/Rakefile +++ b/examples/i18n/en/Rakefile @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../../lib") require 'cucumber/rake/task' Cucumber::Rake::Task.new do |t| diff --git a/examples/i18n/en/features/step_definitions/calculator_steps.rb b/examples/i18n/en/features/step_definitions/calculator_steps.rb index 1d5e3adb0d..8d9b400854 100644 --- a/examples/i18n/en/features/step_definitions/calculator_steps.rb +++ b/examples/i18n/en/features/step_definitions/calculator_steps.rb @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib") require 'calculator' Before do diff --git a/examples/i18n/eo/Rakefile b/examples/i18n/eo/Rakefile index c6d57867f8..47e3afe93d 100644 --- a/examples/i18n/eo/Rakefile +++ b/examples/i18n/eo/Rakefile @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../../lib") require 'cucumber/rake/task' Cucumber::Rake::Task.new do |t| diff --git a/examples/i18n/eo/features/step_definitions/calculator_steps.rb b/examples/i18n/eo/features/step_definitions/calculator_steps.rb index 0ec508d612..14c27f85c8 100644 --- a/examples/i18n/eo/features/step_definitions/calculator_steps.rb +++ b/examples/i18n/eo/features/step_definitions/calculator_steps.rb @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib") require 'calculator' Before do diff --git a/examples/i18n/es/Rakefile b/examples/i18n/es/Rakefile index c6d57867f8..47e3afe93d 100644 --- a/examples/i18n/es/Rakefile +++ b/examples/i18n/es/Rakefile @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../../lib") require 'cucumber/rake/task' Cucumber::Rake::Task.new do |t| diff --git a/examples/i18n/es/features/step_definitions/calculador_steps.rb b/examples/i18n/es/features/step_definitions/calculador_steps.rb index 120f38337b..8190c3be8e 100644 --- a/examples/i18n/es/features/step_definitions/calculador_steps.rb +++ b/examples/i18n/es/features/step_definitions/calculador_steps.rb @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib") require 'calculador' Before do diff --git a/examples/i18n/et/Rakefile b/examples/i18n/et/Rakefile index c6d57867f8..47e3afe93d 100644 --- a/examples/i18n/et/Rakefile +++ b/examples/i18n/et/Rakefile @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../../lib") require 'cucumber/rake/task' Cucumber::Rake::Task.new do |t| diff --git a/examples/i18n/et/features/step_definitions/kalkulaator_steps.rb b/examples/i18n/et/features/step_definitions/kalkulaator_steps.rb index a77e3e61be..7eefcd36de 100644 --- a/examples/i18n/et/features/step_definitions/kalkulaator_steps.rb +++ b/examples/i18n/et/features/step_definitions/kalkulaator_steps.rb @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib") require 'kalkulaator' Before do diff --git a/examples/i18n/fi/Rakefile b/examples/i18n/fi/Rakefile index c6d57867f8..47e3afe93d 100644 --- a/examples/i18n/fi/Rakefile +++ b/examples/i18n/fi/Rakefile @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../../lib") require 'cucumber/rake/task' Cucumber::Rake::Task.new do |t| diff --git a/examples/i18n/fi/features/step_definitions/laskin_steps.rb b/examples/i18n/fi/features/step_definitions/laskin_steps.rb index af20f2d32d..e1fe1bd738 100644 --- a/examples/i18n/fi/features/step_definitions/laskin_steps.rb +++ b/examples/i18n/fi/features/step_definitions/laskin_steps.rb @@ -5,7 +5,7 @@ end require 'cucumber/formatter/unicode' -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib") require 'laskin' Before do diff --git a/examples/i18n/fr/Rakefile b/examples/i18n/fr/Rakefile index 6558251347..6e54facad7 100644 --- a/examples/i18n/fr/Rakefile +++ b/examples/i18n/fr/Rakefile @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../../lib") require 'cucumber/rake/task' Cucumber::Rake::Task.new do |t| diff --git a/examples/i18n/fr/features/support/env.rb b/examples/i18n/fr/features/support/env.rb index e40d65e216..e7966fc655 100644 --- a/examples/i18n/fr/features/support/env.rb +++ b/examples/i18n/fr/features/support/env.rb @@ -5,5 +5,5 @@ end require 'cucumber/formatter/unicode' -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib") require 'calculatrice' diff --git a/examples/i18n/he/Rakefile b/examples/i18n/he/Rakefile index c6d57867f8..47e3afe93d 100644 --- a/examples/i18n/he/Rakefile +++ b/examples/i18n/he/Rakefile @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../../lib") require 'cucumber/rake/task' Cucumber::Rake::Task.new do |t| diff --git a/examples/i18n/he/features/step_definitions/calculator_steps.rb b/examples/i18n/he/features/step_definitions/calculator_steps.rb index 2b8af75c76..3a4fcc98a4 100644 --- a/examples/i18n/he/features/step_definitions/calculator_steps.rb +++ b/examples/i18n/he/features/step_definitions/calculator_steps.rb @@ -5,7 +5,7 @@ end require 'cucumber/formatter/unicode' -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib") require 'calculator' Before do diff --git a/examples/i18n/hi/Rakefile b/examples/i18n/hi/Rakefile index c6d57867f8..47e3afe93d 100644 --- a/examples/i18n/hi/Rakefile +++ b/examples/i18n/hi/Rakefile @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../../lib") require 'cucumber/rake/task' Cucumber::Rake::Task.new do |t| diff --git a/examples/i18n/hi/features/step_definitions/calculator_steps.rb b/examples/i18n/hi/features/step_definitions/calculator_steps.rb index 1bbcb1dc2a..8ccff78948 100644 --- a/examples/i18n/hi/features/step_definitions/calculator_steps.rb +++ b/examples/i18n/hi/features/step_definitions/calculator_steps.rb @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib") require 'calculator' Before do diff --git a/examples/i18n/ht/Rakefile b/examples/i18n/ht/Rakefile index c6d57867f8..47e3afe93d 100644 --- a/examples/i18n/ht/Rakefile +++ b/examples/i18n/ht/Rakefile @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../../lib") require 'cucumber/rake/task' Cucumber::Rake::Task.new do |t| diff --git a/examples/i18n/ht/features/step_definitions/kalkilatris_steps.rb b/examples/i18n/ht/features/step_definitions/kalkilatris_steps.rb index d2f1dd4b89..466f5ae043 100644 --- a/examples/i18n/ht/features/step_definitions/kalkilatris_steps.rb +++ b/examples/i18n/ht/features/step_definitions/kalkilatris_steps.rb @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib") require 'kalkilatris' Before do diff --git a/examples/i18n/hu/Rakefile b/examples/i18n/hu/Rakefile index c6d57867f8..47e3afe93d 100644 --- a/examples/i18n/hu/Rakefile +++ b/examples/i18n/hu/Rakefile @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../../lib") require 'cucumber/rake/task' Cucumber::Rake::Task.new do |t| diff --git a/examples/i18n/hu/features/step_definitions/calculator_steps.rb b/examples/i18n/hu/features/step_definitions/calculator_steps.rb index 681ac6c557..85460f08a0 100644 --- a/examples/i18n/hu/features/step_definitions/calculator_steps.rb +++ b/examples/i18n/hu/features/step_definitions/calculator_steps.rb @@ -5,7 +5,7 @@ end require 'cucumber/formatter/unicode' -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib") require 'calculator' Before do diff --git a/examples/i18n/id/Rakefile b/examples/i18n/id/Rakefile index c6d57867f8..47e3afe93d 100644 --- a/examples/i18n/id/Rakefile +++ b/examples/i18n/id/Rakefile @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../../lib") require 'cucumber/rake/task' Cucumber::Rake::Task.new do |t| diff --git a/examples/i18n/id/features/step_definitions/calculator_steps.rb b/examples/i18n/id/features/step_definitions/calculator_steps.rb index 37e122583d..5323ac7642 100644 --- a/examples/i18n/id/features/step_definitions/calculator_steps.rb +++ b/examples/i18n/id/features/step_definitions/calculator_steps.rb @@ -5,7 +5,7 @@ end require 'cucumber/formatter/unicode' -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib") require 'calculator' Before do diff --git a/examples/i18n/it/Rakefile b/examples/i18n/it/Rakefile index c6d57867f8..47e3afe93d 100644 --- a/examples/i18n/it/Rakefile +++ b/examples/i18n/it/Rakefile @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../../lib") require 'cucumber/rake/task' Cucumber::Rake::Task.new do |t| diff --git a/examples/i18n/it/features/step_definitions/calcolatrice_steps.rb b/examples/i18n/it/features/step_definitions/calcolatrice_steps.rb index d215775d7e..f0e73cf84c 100644 --- a/examples/i18n/it/features/step_definitions/calcolatrice_steps.rb +++ b/examples/i18n/it/features/step_definitions/calcolatrice_steps.rb @@ -5,7 +5,7 @@ end require 'cucumber/formatter/unicode' -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib") require 'calcolatrice' Before do diff --git a/examples/i18n/ja/Rakefile b/examples/i18n/ja/Rakefile index c6d57867f8..47e3afe93d 100644 --- a/examples/i18n/ja/Rakefile +++ b/examples/i18n/ja/Rakefile @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../../lib") require 'cucumber/rake/task' Cucumber::Rake::Task.new do |t| diff --git a/examples/i18n/ja/features/support/env.rb b/examples/i18n/ja/features/support/env.rb index 26467b505c..0f358a1e66 100644 --- a/examples/i18n/ja/features/support/env.rb +++ b/examples/i18n/ja/features/support/env.rb @@ -5,5 +5,5 @@ end require 'cucumber/formatter/unicode' -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib") require 'calculator' diff --git a/examples/i18n/ko/Rakefile b/examples/i18n/ko/Rakefile index c6d57867f8..47e3afe93d 100644 --- a/examples/i18n/ko/Rakefile +++ b/examples/i18n/ko/Rakefile @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../../lib") require 'cucumber/rake/task' Cucumber::Rake::Task.new do |t| diff --git a/examples/i18n/ko/features/step_definitions/calculator_steps.rb b/examples/i18n/ko/features/step_definitions/calculator_steps.rb index 3303024135..e3624f9826 100644 --- a/examples/i18n/ko/features/step_definitions/calculator_steps.rb +++ b/examples/i18n/ko/features/step_definitions/calculator_steps.rb @@ -5,7 +5,7 @@ end require 'cucumber/formatter/unicode' -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib") require 'calculator' Before do diff --git a/examples/i18n/lt/Rakefile b/examples/i18n/lt/Rakefile index c6d57867f8..47e3afe93d 100644 --- a/examples/i18n/lt/Rakefile +++ b/examples/i18n/lt/Rakefile @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../../lib") require 'cucumber/rake/task' Cucumber::Rake::Task.new do |t| diff --git a/examples/i18n/lt/features/step_definitions/calculator_steps.rb b/examples/i18n/lt/features/step_definitions/calculator_steps.rb index 2e2ed6712d..90ef2ec412 100644 --- a/examples/i18n/lt/features/step_definitions/calculator_steps.rb +++ b/examples/i18n/lt/features/step_definitions/calculator_steps.rb @@ -5,7 +5,7 @@ end require 'cucumber/formatter/unicode' -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib") require 'calculator' Before do diff --git a/examples/i18n/lv/Rakefile b/examples/i18n/lv/Rakefile index c6d57867f8..47e3afe93d 100644 --- a/examples/i18n/lv/Rakefile +++ b/examples/i18n/lv/Rakefile @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../../lib") require 'cucumber/rake/task' Cucumber::Rake::Task.new do |t| diff --git a/examples/i18n/lv/features/step_definitions/calculator_steps.rb b/examples/i18n/lv/features/step_definitions/calculator_steps.rb index 5c9761500b..c939fed10a 100644 --- a/examples/i18n/lv/features/step_definitions/calculator_steps.rb +++ b/examples/i18n/lv/features/step_definitions/calculator_steps.rb @@ -5,7 +5,7 @@ end require 'cucumber/formatter/unicode' -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib") require 'calculator' Before do diff --git a/examples/i18n/no/Rakefile b/examples/i18n/no/Rakefile index c6d57867f8..47e3afe93d 100644 --- a/examples/i18n/no/Rakefile +++ b/examples/i18n/no/Rakefile @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../../lib") require 'cucumber/rake/task' Cucumber::Rake::Task.new do |t| diff --git a/examples/i18n/no/features/support/env.rb b/examples/i18n/no/features/support/env.rb index a0b2d080cf..2587907241 100644 --- a/examples/i18n/no/features/support/env.rb +++ b/examples/i18n/no/features/support/env.rb @@ -6,5 +6,5 @@ require 'cucumber/formatter/unicode' -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib") require 'kalkulator' diff --git a/examples/i18n/pl/Rakefile b/examples/i18n/pl/Rakefile index c6d57867f8..47e3afe93d 100644 --- a/examples/i18n/pl/Rakefile +++ b/examples/i18n/pl/Rakefile @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../../lib") require 'cucumber/rake/task' Cucumber::Rake::Task.new do |t| diff --git a/examples/i18n/pl/features/step_definitions/calculator_steps.rb b/examples/i18n/pl/features/step_definitions/calculator_steps.rb index 4b9d43bdeb..5d06c4c36b 100644 --- a/examples/i18n/pl/features/step_definitions/calculator_steps.rb +++ b/examples/i18n/pl/features/step_definitions/calculator_steps.rb @@ -5,7 +5,7 @@ end require 'cucumber/formatter/unicode' -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib") require 'calculator' Before do diff --git a/examples/i18n/pl/features/support/env.rb b/examples/i18n/pl/features/support/env.rb index 26467b505c..0f358a1e66 100644 --- a/examples/i18n/pl/features/support/env.rb +++ b/examples/i18n/pl/features/support/env.rb @@ -5,5 +5,5 @@ end require 'cucumber/formatter/unicode' -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib") require 'calculator' diff --git a/examples/i18n/pt/Rakefile b/examples/i18n/pt/Rakefile index c6d57867f8..47e3afe93d 100644 --- a/examples/i18n/pt/Rakefile +++ b/examples/i18n/pt/Rakefile @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../../lib") require 'cucumber/rake/task' Cucumber::Rake::Task.new do |t| diff --git a/examples/i18n/pt/features/support/env.rb b/examples/i18n/pt/features/support/env.rb index 1ddde61f70..da56cfdc96 100644 --- a/examples/i18n/pt/features/support/env.rb +++ b/examples/i18n/pt/features/support/env.rb @@ -5,5 +5,5 @@ end require 'cucumber/formatter/unicode' -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib") require 'calculadora' diff --git a/examples/i18n/ro/Rakefile b/examples/i18n/ro/Rakefile index c6d57867f8..47e3afe93d 100644 --- a/examples/i18n/ro/Rakefile +++ b/examples/i18n/ro/Rakefile @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../../lib") require 'cucumber/rake/task' Cucumber::Rake::Task.new do |t| diff --git a/examples/i18n/ro/features/step_definitions/calculator_steps.rb b/examples/i18n/ro/features/step_definitions/calculator_steps.rb index 3257c4bc2a..76f4f823f2 100644 --- a/examples/i18n/ro/features/step_definitions/calculator_steps.rb +++ b/examples/i18n/ro/features/step_definitions/calculator_steps.rb @@ -5,7 +5,7 @@ end require 'cucumber/formatter/unicode' -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib") require 'calculator' Datfiind(/un calculator/) do diff --git a/examples/i18n/ru/Rakefile b/examples/i18n/ru/Rakefile index c6d57867f8..47e3afe93d 100644 --- a/examples/i18n/ru/Rakefile +++ b/examples/i18n/ru/Rakefile @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../../lib") require 'cucumber/rake/task' Cucumber::Rake::Task.new do |t| diff --git a/examples/i18n/ru/features/support/env.rb b/examples/i18n/ru/features/support/env.rb index 26467b505c..0f358a1e66 100644 --- a/examples/i18n/ru/features/support/env.rb +++ b/examples/i18n/ru/features/support/env.rb @@ -5,5 +5,5 @@ end require 'cucumber/formatter/unicode' -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib") require 'calculator' diff --git a/examples/i18n/sk/Rakefile b/examples/i18n/sk/Rakefile index c6d57867f8..47e3afe93d 100644 --- a/examples/i18n/sk/Rakefile +++ b/examples/i18n/sk/Rakefile @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../../lib") require 'cucumber/rake/task' Cucumber::Rake::Task.new do |t| diff --git a/examples/i18n/sk/features/step_definitions/calculator_steps.rb b/examples/i18n/sk/features/step_definitions/calculator_steps.rb index 3e8d20a847..a6acbfb18b 100644 --- a/examples/i18n/sk/features/step_definitions/calculator_steps.rb +++ b/examples/i18n/sk/features/step_definitions/calculator_steps.rb @@ -5,7 +5,7 @@ end require 'cucumber/formatter/unicode' -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib") require 'calculator' Before do diff --git a/examples/i18n/sr-Cyrl/Rakefile b/examples/i18n/sr-Cyrl/Rakefile index c6d57867f8..47e3afe93d 100644 --- a/examples/i18n/sr-Cyrl/Rakefile +++ b/examples/i18n/sr-Cyrl/Rakefile @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../../lib") require 'cucumber/rake/task' Cucumber::Rake::Task.new do |t| diff --git a/examples/i18n/sr-Cyrl/features/support/env.rb b/examples/i18n/sr-Cyrl/features/support/env.rb index d2b7a04502..7dd11e4dd7 100644 --- a/examples/i18n/sr-Cyrl/features/support/env.rb +++ b/examples/i18n/sr-Cyrl/features/support/env.rb @@ -1,2 +1,2 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib") require 'calculator' diff --git a/examples/i18n/sr-Latn/Rakefile b/examples/i18n/sr-Latn/Rakefile index c6d57867f8..47e3afe93d 100644 --- a/examples/i18n/sr-Latn/Rakefile +++ b/examples/i18n/sr-Latn/Rakefile @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../../lib") require 'cucumber/rake/task' Cucumber::Rake::Task.new do |t| diff --git a/examples/i18n/sr-Latn/features/step_definitions/calculator_steps.rb b/examples/i18n/sr-Latn/features/step_definitions/calculator_steps.rb index b4b7081434..a5830fec57 100644 --- a/examples/i18n/sr-Latn/features/step_definitions/calculator_steps.rb +++ b/examples/i18n/sr-Latn/features/step_definitions/calculator_steps.rb @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib") require 'calculator' Before do diff --git a/examples/i18n/sv/Rakefile b/examples/i18n/sv/Rakefile index c6d57867f8..47e3afe93d 100644 --- a/examples/i18n/sv/Rakefile +++ b/examples/i18n/sv/Rakefile @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../../lib") require 'cucumber/rake/task' Cucumber::Rake::Task.new do |t| diff --git a/examples/i18n/sv/features/step_definitions/kalkulator_steps.rb b/examples/i18n/sv/features/step_definitions/kalkulator_steps.rb index 9c83a54249..a78ab253d9 100644 --- a/examples/i18n/sv/features/step_definitions/kalkulator_steps.rb +++ b/examples/i18n/sv/features/step_definitions/kalkulator_steps.rb @@ -5,7 +5,7 @@ end require 'cucumber/formatter/unicode' -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib") require 'kalkulator' Before do diff --git a/examples/i18n/tr/Rakefile b/examples/i18n/tr/Rakefile index c6d57867f8..47e3afe93d 100644 --- a/examples/i18n/tr/Rakefile +++ b/examples/i18n/tr/Rakefile @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../../lib") require 'cucumber/rake/task' Cucumber::Rake::Task.new do |t| diff --git a/examples/i18n/tr/features/step_definitions/hesap_makinesi_adimlari.rb b/examples/i18n/tr/features/step_definitions/hesap_makinesi_adimlari.rb index a730f6ebc7..a964e18500 100644 --- a/examples/i18n/tr/features/step_definitions/hesap_makinesi_adimlari.rb +++ b/examples/i18n/tr/features/step_definitions/hesap_makinesi_adimlari.rb @@ -5,7 +5,7 @@ end require 'cucumber/formatter/unicode' -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib") require 'hesap_makinesi' Before do diff --git a/examples/i18n/uk/Rakefile b/examples/i18n/uk/Rakefile index c6d57867f8..47e3afe93d 100644 --- a/examples/i18n/uk/Rakefile +++ b/examples/i18n/uk/Rakefile @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../../lib") require 'cucumber/rake/task' Cucumber::Rake::Task.new do |t| diff --git a/examples/i18n/uk/features/support/env.rb b/examples/i18n/uk/features/support/env.rb index d2b7a04502..7dd11e4dd7 100644 --- a/examples/i18n/uk/features/support/env.rb +++ b/examples/i18n/uk/features/support/env.rb @@ -1,2 +1,2 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib") require 'calculator' diff --git a/examples/i18n/uz/Rakefile b/examples/i18n/uz/Rakefile index c6d57867f8..47e3afe93d 100644 --- a/examples/i18n/uz/Rakefile +++ b/examples/i18n/uz/Rakefile @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../../lib") require 'cucumber/rake/task' Cucumber::Rake::Task.new do |t| diff --git a/examples/i18n/uz/features/support/env.rb b/examples/i18n/uz/features/support/env.rb index d2b7a04502..7dd11e4dd7 100644 --- a/examples/i18n/uz/features/support/env.rb +++ b/examples/i18n/uz/features/support/env.rb @@ -1,2 +1,2 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib") require 'calculator' diff --git a/examples/i18n/zh-CN/Rakefile b/examples/i18n/zh-CN/Rakefile index c701ead40d..a7c622f6af 100644 --- a/examples/i18n/zh-CN/Rakefile +++ b/examples/i18n/zh-CN/Rakefile @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../../lib") require 'cucumber/rake/task' Cucumber::Rake::Task.new diff --git a/examples/i18n/zh-CN/features/step_definitions/calculator_steps.rb b/examples/i18n/zh-CN/features/step_definitions/calculator_steps.rb index ed8fb507ed..f7a43d5e14 100644 --- a/examples/i18n/zh-CN/features/step_definitions/calculator_steps.rb +++ b/examples/i18n/zh-CN/features/step_definitions/calculator_steps.rb @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib") require 'calculator' Before do diff --git a/examples/i18n/zh-TW/Rakefile b/examples/i18n/zh-TW/Rakefile index c701ead40d..a7c622f6af 100644 --- a/examples/i18n/zh-TW/Rakefile +++ b/examples/i18n/zh-TW/Rakefile @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../../lib") require 'cucumber/rake/task' Cucumber::Rake::Task.new diff --git a/examples/i18n/zh-TW/features/step_definitions/calculator_steps.rb b/examples/i18n/zh-TW/features/step_definitions/calculator_steps.rb index 62ff8edbaf..2f94478743 100644 --- a/examples/i18n/zh-TW/features/step_definitions/calculator_steps.rb +++ b/examples/i18n/zh-TW/features/step_definitions/calculator_steps.rb @@ -5,7 +5,7 @@ end require 'cucumber/formatter/unicode' -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib") require 'calculator' Before do diff --git a/examples/rspec_doubles/Rakefile b/examples/rspec_doubles/Rakefile index 67c8d86486..3e6d1999e7 100644 --- a/examples/rspec_doubles/Rakefile +++ b/examples/rspec_doubles/Rakefile @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib") require 'cucumber/rake/task' Cucumber::Rake::Task.new diff --git a/examples/sinatra/Rakefile b/examples/sinatra/Rakefile index b566aa115d..703361b376 100644 --- a/examples/sinatra/Rakefile +++ b/examples/sinatra/Rakefile @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib") require 'cucumber/rake/task' Cucumber::Rake::Task.new do |t| diff --git a/examples/sinatra/features/support/env.rb b/examples/sinatra/features/support/env.rb index 7ec6ed51a5..1d3659b408 100644 --- a/examples/sinatra/features/support/env.rb +++ b/examples/sinatra/features/support/env.rb @@ -1,7 +1,7 @@ # See http://wiki.github.com/cucumber/cucumber/sinatra # for more details about Sinatra with Cucumber -require File.dirname(__FILE__) + '/../../app' +require "#{File.dirname(__FILE__)}./../../app" require 'rack/test' require 'capybara/cucumber' diff --git a/examples/tcl/Rakefile b/examples/tcl/Rakefile index b566aa115d..703361b376 100644 --- a/examples/tcl/Rakefile +++ b/examples/tcl/Rakefile @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib") require 'cucumber/rake/task' Cucumber::Rake::Task.new do |t| diff --git a/examples/tcl/features/support/env.rb b/examples/tcl/features/support/env.rb index cab740dc8c..a913eb0b18 100644 --- a/examples/tcl/features/support/env.rb +++ b/examples/tcl/features/support/env.rb @@ -2,6 +2,6 @@ require 'tcl' Before do - file_name = File.dirname(__FILE__) + '/../../src/fib.tcl' + file_name = "#{File.dirname(__FILE__)}/../../src/fib.tcl" @fib = Tcl::Interp.load_from_file(file_name) end diff --git a/examples/test_unit/Rakefile b/examples/test_unit/Rakefile index b566aa115d..703361b376 100644 --- a/examples/test_unit/Rakefile +++ b/examples/test_unit/Rakefile @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib') +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib") require 'cucumber/rake/task' Cucumber::Rake::Task.new do |t| diff --git a/features/lib/step_definitions/junit_steps.rb b/features/lib/step_definitions/junit_steps.rb index 4d9af1c385..ac7f3b0f0f 100644 --- a/features/lib/step_definitions/junit_steps.rb +++ b/features/lib/step_definitions/junit_steps.rb @@ -1,5 +1,5 @@ Then('the junit output file {string} should contain:') do |actual_file, text| - actual = IO.read(File.expand_path('.') + '/' + actual_file) + actual = IO.read("#{File.expand_path('.')}/#{actual_file}") actual = remove_self_ref(replace_junit_time(actual)) expect(actual).to be_similar_output_than(text) diff --git a/features/lib/support/command_line.rb b/features/lib/support/command_line.rb index 211589767c..172a0b5ea1 100644 --- a/features/lib/support/command_line.rb +++ b/features/lib/support/command_line.rb @@ -41,8 +41,8 @@ def exit_status end def capture_stdout - capture_stream(STDOUT, @stdout) - capture_stream(STDERR, @stderr) + capture_stream($stdout, @stdout) + capture_stream($stderr, @stderr) yield end diff --git a/features/lib/support/fake_wire_server.rb b/features/lib/support/fake_wire_server.rb index 093c60caa2..1f7854a93a 100644 --- a/features/lib/support/fake_wire_server.rb +++ b/features/lib/support/fake_wire_server.rb @@ -81,7 +81,7 @@ def response_to(data) end def send_response(response) - @socket.puts response + "\n" + @socket.puts "#{response}\n" end def delay(data) diff --git a/gem_tasks/downloads.rb b/gem_tasks/downloads.rb index 2cfb263173..891e5783ba 100644 --- a/gem_tasks/downloads.rb +++ b/gem_tasks/downloads.rb @@ -3,7 +3,7 @@ require 'httparty' require 'json' -IO.read(File.dirname(__FILE__) + '/versions.txt').each_line do |version| +IO.read("#{File.dirname(__FILE__)}/versions.txt").each_line do |version| json = HTTParty.get("http://rubygems.org/api/v1/downloads/cucumber-#{version.strip}.json") puts JSON.parse(json.body)['version_downloads'] end diff --git a/lib/autotest/discover.rb b/lib/autotest/discover.rb index c71a287ab1..da088e2bb7 100644 --- a/lib/autotest/discover.rb +++ b/lib/autotest/discover.rb @@ -2,9 +2,10 @@ Autotest.add_discovery do if File.directory?('features') - if ENV['AUTOFEATURE'] =~ /true/i + case ENV['AUTOFEATURE'] + when /true/i 'cucumber' - elsif ENV['AUTOFEATURE'] =~ /false/i + when /false/i # noop else puts '(Not running features. To run features in autotest, set AUTOFEATURE=true.)' diff --git a/lib/cucumber.rb b/lib/cucumber.rb index 67d36a1d73..7c4258b252 100644 --- a/lib/cucumber.rb +++ b/lib/cucumber.rb @@ -14,7 +14,7 @@ class << self def logger return @log if @log - @log = Logger.new(STDOUT) + @log = Logger.new($stdout) @log.level = Logger::INFO @log end diff --git a/lib/cucumber/cli/configuration.rb b/lib/cucumber/cli/configuration.rb index 4fb901211f..493b52505c 100644 --- a/lib/cucumber/cli/configuration.rb +++ b/lib/cucumber/cli/configuration.rb @@ -17,7 +17,7 @@ class Configuration attr_reader :out_stream - def initialize(out_stream = STDOUT, error_stream = STDERR) + def initialize(out_stream = $stdout, error_stream = $stderr) @out_stream = out_stream @error_stream = error_stream @options = Options.new(@out_stream, @error_stream, default_profile: 'default') diff --git a/lib/cucumber/cli/main.rb b/lib/cucumber/cli/main.rb index 419243da3a..6e2d998d44 100644 --- a/lib/cucumber/cli/main.rb +++ b/lib/cucumber/cli/main.rb @@ -14,7 +14,7 @@ def execute(args) end end - def initialize(args, _ = nil, out = STDOUT, err = STDERR, kernel = Kernel) + def initialize(args, _ = nil, out = $stdout, err = $stderr, kernel = Kernel) @args = args @out = out @err = err @@ -41,7 +41,7 @@ def execute!(existing_runtime = nil) @err.puts("Couldn't open #{e.path}") exit_unable_to_finish rescue FeatureFolderNotFoundException => e - @err.puts(e.message + '. You can use `cucumber --init` to get started.') + @err.puts("#{e.message}. You can use `cucumber --init` to get started.") exit_unable_to_finish rescue ProfilesNotDefinedError, YmlLoadError, ProfileNotFound => e @err.puts(e.message) @@ -85,7 +85,7 @@ def trap_interrupt trap('INT') do exit_unable_to_finish! if Cucumber.wants_to_quit Cucumber.wants_to_quit = true - STDERR.puts "\nExiting... Interrupt again to exit immediately." + $stderr.puts "\nExiting... Interrupt again to exit immediately." exit_unable_to_finish end end diff --git a/lib/cucumber/cli/options.rb b/lib/cucumber/cli/options.rb index e996cfdc74..fd14ab170b 100644 --- a/lib/cucumber/cli/options.rb +++ b/lib/cucumber/cli/options.rb @@ -69,7 +69,7 @@ def self.parse(args, out_stream, error_stream, options = {}) new(out_stream, error_stream, options).parse!(args) end - def initialize(out_stream = STDOUT, error_stream = STDERR, options = {}) + def initialize(out_stream = $stdout, error_stream = $stderr, options = {}) @out_stream = out_stream @error_stream = error_stream diff --git a/lib/cucumber/deprecate.rb b/lib/cucumber/deprecate.rb index 39796d3b69..488f7b05d4 100644 --- a/lib/cucumber/deprecate.rb +++ b/lib/cucumber/deprecate.rb @@ -31,7 +31,7 @@ def self.deprecate(stream, option, message, remove_after_version) module ForUsers def self.call(message, method, remove_after_version) - STDERR.puts AnsiString.failure_message( + $stderr.puts AnsiString.failure_message( "\nWARNING: ##{method} is deprecated" \ " and will be removed after version #{remove_after_version}. #{message}.\n" \ "(Called from #{caller(3..3).first})" diff --git a/lib/cucumber/events.rb b/lib/cucumber/events.rb index 04cb4aa083..790cf17716 100644 --- a/lib/cucumber/events.rb +++ b/lib/cucumber/events.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -Dir[File.dirname(__FILE__) + '/events/*.rb'].map(&method(:require)) +Dir["#{File.dirname(__FILE__)}/events/*.rb"].map(&method(:require)) module Cucumber # Events tell you what's happening while Cucumber runs your features. diff --git a/lib/cucumber/formatter/ansicolor.rb b/lib/cucumber/formatter/ansicolor.rb index 8e6f60e184..6e6941fb29 100644 --- a/lib/cucumber/formatter/ansicolor.rb +++ b/lib/cucumber/formatter/ansicolor.rb @@ -3,7 +3,7 @@ require 'cucumber/platform' require 'cucumber/term/ansicolor' -Cucumber::Term::ANSIColor.coloring = false if !STDOUT.tty? && !ENV.key?('AUTOTEST') +Cucumber::Term::ANSIColor.coloring = false if !$stdout.tty? && !ENV.key?('AUTOTEST') module Cucumber module Formatter @@ -48,7 +48,7 @@ module ANSIColor include Cucumber::Term::ANSIColor ALIASES = Hash.new do |h, k| - h[Regexp.last_match(1)] + ',bold' if k.to_s =~ /(.*)_param/ + "#{h[Regexp.last_match(1)]},bold" if k.to_s =~ /(.*)_param/ end.merge( 'undefined' => 'yellow', 'pending' => 'yellow', @@ -83,11 +83,11 @@ module ANSIColor next if method_name =~ /.*_param/ code = <<-COLOR def #{method_name}(string=nil, &proc) - #{ALIASES[method_name].split(',').join('(') + '(string, &proc' + ')' * ALIASES[method_name].split(',').length} + #{"#{ALIASES[method_name].split(',').join('(')}(string, &proc#{')' * ALIASES[method_name].split(',').length}"} end # This resets the colour to the non-param colour def #{method_name}_param(string=nil, &proc) - #{ALIASES[method_name + '_param'].split(',').join('(') + '(string, &proc' + ')' * ALIASES[method_name + '_param'].split(',').length} + #{ALIASES[method_name].split(',').join(' + ')} + #{"#{ALIASES["#{method_name}_param"].split(',').join('(')}(string, &proc#{')' * ALIASES["#{method_name}_param"].split(',').length}"} + #{ALIASES[method_name].split(',').join(' + ')} end COLOR eval(code) # rubocop:disable Security/Eval @@ -110,10 +110,10 @@ def self.define_grey #:nodoc: rescue Exception => e # rubocop:disable Lint/RescueException # rubocop:disable Style/ClassEqualityComparison if e.class.name == 'TermInfo::TermInfoError' - STDERR.puts '*** WARNING ***' - STDERR.puts "You have the genki-ruby-terminfo gem installed, but you haven't set your TERM variable." - STDERR.puts 'Try setting it to TERM=xterm-256color to get grey colour in output.' - STDERR.puts "\n" + $stderr.puts '*** WARNING ***' + $stderr.puts "You have the genki-ruby-terminfo gem installed, but you haven't set your TERM variable." + $stderr.puts 'Try setting it to TERM=xterm-256color to get grey colour in output.' + $stderr.puts "\n" alias_method :grey, :white else define_real_grey diff --git a/lib/cucumber/formatter/console.rb b/lib/cucumber/formatter/console.rb index 8213227f8b..64145157bb 100644 --- a/lib/cucumber/formatter/console.rb +++ b/lib/cucumber/formatter/console.rb @@ -34,7 +34,7 @@ module Console def format_step(keyword, step_match, status, source_indent) comment = if source_indent - c = indent(('# ' + step_match.location.to_s), source_indent) + c = indent("# #{step_match.location}", source_indent) format_string(c, :comment) else '' diff --git a/lib/cucumber/formatter/json.rb b/lib/cucumber/formatter/json.rb index 8384a72d77..8d118f482e 100644 --- a/lib/cucumber/formatter/json.rb +++ b/lib/cucumber/formatter/json.rb @@ -133,7 +133,7 @@ def hooks_of_type(hook_step) when 'AfterStep hook' after_step_hooks else - raise 'Unknown hook type ' + hook_step.to_s + raise "Unknown hook type #{hook_step}" end end diff --git a/lib/cucumber/formatter/junit.rb b/lib/cucumber/formatter/junit.rb index 07899fc75f..d82eafd060 100644 --- a/lib/cucumber/formatter/junit.rb +++ b/lib/cucumber/formatter/junit.rb @@ -125,7 +125,7 @@ def create_output_string(test_case, scenario, result, row_name) else output += "Example row: #{row_name}\n" end - output + "\nMessage:\n" + "#{output}\nMessage:\n" end def build_testcase(result, scenario_designation, output) @@ -228,7 +228,7 @@ def scenario_outline(outline) end def examples_table_row(row) - @row_name = '| ' + row.cells.map(&:value).join(' | ') + ' |' + @row_name = "| #{row.cells.map(&:value).join(' | ')} |" @name_suffix = " (outline example : #{@row_name})" end end diff --git a/lib/cucumber/formatter/pretty.rb b/lib/cucumber/formatter/pretty.rb index 671c936b0d..5bf63442f1 100644 --- a/lib/cucumber/formatter/pretty.rb +++ b/lib/cucumber/formatter/pretty.rb @@ -443,7 +443,7 @@ def print_expanded_row_data(test_case) language = ::Gherkin::Dialect.for(language_code) scenario_keyword = language.scenario_keywords[0] row = scenario_source(test_case).row - expanded_name = '| ' + row.cells.map(&:value).join(' | ') + ' |' + expanded_name = "| #{row.cells.map(&:value).join(' | ')} |" @source_indent = calculate_source_indent_for_expanded_test_case(test_case, scenario_keyword, expanded_name) @io.puts print_keyword_name(scenario_keyword, expanded_name, 6, test_case.location) diff --git a/lib/cucumber/formatter/unicode.rb b/lib/cucumber/formatter/unicode.rb index fc1035bf2b..7f2442b6a6 100644 --- a/lib/cucumber/formatter/unicode.rb +++ b/lib/cucumber/formatter/unicode.rb @@ -17,7 +17,7 @@ end else Cucumber::CODEPAGE = 'cp1252'.freeze - STDERR.puts("WARNING: Couldn't detect your output codepage. Assuming it is 1252. You may have to chcp 1252 or SET CUCUMBER_OUTPUT_ENCODING=cp1252.") + $stderr.puts("WARNING: Couldn't detect your output codepage. Assuming it is 1252. You may have to chcp 1252 or SET CUCUMBER_OUTPUT_ENCODING=cp1252.") end module Cucumber @@ -28,7 +28,7 @@ def self.extended(output) def cucumber_preprocess_output(*out) out.map { |arg| arg.to_s.encode(Encoding.default_external) } rescue Encoding::UndefinedConversionError => e - STDERR.cucumber_puts("WARNING: #{e.message}") + $stderr.cucumber_puts("WARNING: #{e.message}") out end @@ -45,8 +45,8 @@ def puts(*out) end Kernel.extend(self) - STDOUT.extend(self) - STDERR.extend(self) + $stdout.extend(self) + $stderr.extend(self) end end end diff --git a/lib/cucumber/formatter/usage.rb b/lib/cucumber/formatter/usage.rb index 6c738d3226..8ea45618ab 100644 --- a/lib/cucumber/formatter/usage.rb +++ b/lib/cucumber/formatter/usage.rb @@ -78,7 +78,7 @@ def print_summary if @stepdef_to_match[stepdef_key].any? print_steps(stepdef_key) else - @io.puts(' ' + format_string('NOT MATCHED BY ANY STEPS', :failed)) + @io.puts(" #{format_string('NOT MATCHED BY ANY STEPS', :failed)}") end end @io.puts @@ -86,7 +86,7 @@ def print_summary end def print_step_definition(stepdef_key) - @io.print format_string(format('%.7f', duration: stepdef_key.mean_duration), :skipped) + ' ' unless config.dry_run? + @io.print "#{format_string(format('%.7f', duration: stepdef_key.mean_duration), :skipped)} " unless config.dry_run? @io.print format_string(stepdef_key.regexp_source, stepdef_key.status) if config.source? indent_amount = max_length - stepdef_key.regexp_source.unpack('U*').length @@ -99,7 +99,7 @@ def print_step_definition(stepdef_key) def print_steps(stepdef_key) @stepdef_to_match[stepdef_key].each do |step| @io.print ' ' - @io.print format_string(format('%.7f', duration: step[:duration]), :skipped) + ' ' unless config.dry_run? + @io.print "#{format_string(format('%.7f', duration: step[:duration]), :skipped)} " unless config.dry_run? @io.print format_step(step[:keyword], step[:step_match], step[:status], nil) if config.source? indent_amount = max_length - (step[:keyword].unpack('U*').length + step[:step_match].format_args.unpack('U*').length) diff --git a/lib/cucumber/gherkin/formatter/ansi_escapes.rb b/lib/cucumber/gherkin/formatter/ansi_escapes.rb index 3d9e60e87c..7843f24cea 100644 --- a/lib/cucumber/gherkin/formatter/ansi_escapes.rb +++ b/lib/cucumber/gherkin/formatter/ansi_escapes.rb @@ -54,7 +54,7 @@ module AnsiEscapes }.freeze ALIASES = Hash.new do |h, k| - h[Regexp.last_match(1)] + ',bold' if k.to_s =~ /(.*)_arg/ + "#{h[Regexp.last_match(1)]},bold" if k.to_s =~ /(.*)_arg/ end.merge( 'undefined' => 'yellow', 'pending' => 'yellow', @@ -74,7 +74,7 @@ module AnsiEscapes end end - ALIASES.keys.each do |key| + ALIASES.each_key do |key| define_method(key) do ALIASES[key].split(',').map { |color| COLORS[color] }.join('') end diff --git a/lib/cucumber/glue/invoke_in_world.rb b/lib/cucumber/glue/invoke_in_world.rb index a99217fefb..406ba5b9d3 100644 --- a/lib/cucumber/glue/invoke_in_world.rb +++ b/lib/cucumber/glue/invoke_in_world.rb @@ -27,7 +27,7 @@ def self.cucumber_instance_exec_in(world, check_arity, pseudo_method, *args, &bl if check_arity && !cucumber_compatible_arity?(args, block) world.instance_exec do ari = block.arity - ari = ari < 0 ? (ari.abs - 1).to_s + '+' : ari + ari = ari < 0 ? "#{ari.abs - 1}+" : ari s1 = ari == 1 ? '' : 's' s2 = args.length == 1 ? '' : 's' raise ArityMismatchError, "Your block takes #{ari} argument#{s1}, but the Regexp matched #{args.length} argument#{s2}." diff --git a/lib/cucumber/glue/proto_world.rb b/lib/cucumber/glue/proto_world.rb index b8050130a4..1a0bf697ae 100644 --- a/lib/cucumber/glue/proto_world.rb +++ b/lib/cucumber/glue/proto_world.rb @@ -38,9 +38,6 @@ def step(name, raw_multiline_arg = nil) # And I am logged in as "Susan" # } # @param [String] steps_text The Gherkin snippet to run - def steps(steps_text) - super - end # Parse Gherkin into a {Cucumber::Ast::Table} object. # @@ -117,9 +114,6 @@ def skip_this_scenario(message = 'Scenario skipped') end # Prints the list of modules that are included in the World - def inspect - super - end # see {#inspect} def to_s diff --git a/lib/cucumber/multiline_argument/data_table.rb b/lib/cucumber/multiline_argument/data_table.rb index f8461cc181..831d726f23 100644 --- a/lib/cucumber/multiline_argument/data_table.rb +++ b/lib/cucumber/multiline_argument/data_table.rb @@ -161,7 +161,7 @@ def hashes def symbolic_hashes @symbolic_hashes ||= hashes.map do |string_hash| - Hash[string_hash.map { |a, b| [symbolize_key(a), b] }] + string_hash.transform_keys { |a| symbolize_key(a) } end end @@ -425,7 +425,7 @@ def initialize(data_table, indentation, prefixes) def to_s leading_row = "\n" end_indentation = indentation - 2 - trailing_row = "\n" + (' ' * end_indentation) + trailing_row = "\n#{' ' * end_indentation}" table_rows = data_table.cell_matrix.map { |row| format_row(row) } leading_row + table_rows.join("\n") + trailing_row end @@ -433,7 +433,7 @@ def to_s private def format_row(row) - row_start = (' ' * indentation) + '| ' + row_start = "#{' ' * indentation}| " row_end = '|' cells = row.map.with_index do |cell, i| format_cell(cell, data_table.col_width(i)) diff --git a/lib/cucumber/platform.rb b/lib/cucumber/platform.rb index 0bfb8ef231..7dd1ca9526 100644 --- a/lib/cucumber/platform.rb +++ b/lib/cucumber/platform.rb @@ -8,8 +8,8 @@ module Cucumber unless defined?(Cucumber::VERSION) VERSION = File.read(File.expand_path('version', __dir__)).strip - BINARY = File.expand_path(File.dirname(__FILE__) + '/../../bin/cucumber') - LIBDIR = File.expand_path(File.dirname(__FILE__) + '/../../lib') + BINARY = File.expand_path("#{File.dirname(__FILE__)}/../../bin/cucumber") + LIBDIR = File.expand_path("#{File.dirname(__FILE__)}/../../lib") RAILS = defined?(Rails) RUBY_BINARY = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name']) RUBY = defined? RUBY_VERSION diff --git a/lib/cucumber/runtime/user_interface.rb b/lib/cucumber/runtime/user_interface.rb index 2084af1758..028776c196 100644 --- a/lib/cucumber/runtime/user_interface.rb +++ b/lib/cucumber/runtime/user_interface.rb @@ -21,8 +21,8 @@ module UserInterface # that makes a sound before invoking #ask. # def ask(question, timeout_seconds) - STDOUT.puts(question) - STDOUT.flush + $stdout.puts(question) + $stdout.flush puts(question) answer = if Cucumber::JRUBY @@ -48,7 +48,7 @@ def attach(src, media_type) def mri_gets(timeout_seconds) Timeout.timeout(timeout_seconds) do - STDIN.gets + $stdin.gets end rescue Timeout::Error nil @@ -57,7 +57,7 @@ def mri_gets(timeout_seconds) def jruby_gets(timeout_seconds) answer = nil t = java.lang.Thread.new do - answer = STDIN.gets + answer = $stdin.gets end t.start t.join(timeout_seconds * 1000) diff --git a/lib/simplecov_setup.rb b/lib/simplecov_setup.rb index 93ccf0ae53..51d4cc036d 100644 --- a/lib/simplecov_setup.rb +++ b/lib/simplecov_setup.rb @@ -7,7 +7,7 @@ require 'simplecov' - SimpleCov.root(File.expand_path(File.dirname(__FILE__) + '/..')) + SimpleCov.root(File.expand_path("#{File.dirname(__FILE__)}/..")) SimpleCov.start do add_filter 'iso-8859-1_steps.rb' add_filter '.-ruby-core/' diff --git a/scripts/update-changelog b/scripts/update-changelog index fed0c25b63..0d8b1cfbaf 100755 --- a/scripts/update-changelog +++ b/scripts/update-changelog @@ -33,7 +33,7 @@ end class Changelog def self.open(path, &block) - full_path = File.expand_path(File.dirname(__FILE__) + '/' + path + '/CHANGELOG.md') + full_path = File.expand_path("#{File.dirname(__FILE__)}/#{path}/CHANGELOG.md") log = new(File.read(full_path)) log.instance_exec(&block) File.write(full_path, log.body) diff --git a/spec/cucumber/deprecate_spec.rb b/spec/cucumber/deprecate_spec.rb index d2655823f6..679b0d381c 100644 --- a/spec/cucumber/deprecate_spec.rb +++ b/spec/cucumber/deprecate_spec.rb @@ -15,10 +15,10 @@ module Cucumber::Deprecate context 'for users' do it 'outputs a message to STDERR' do stub_const('Cucumber::Deprecate::STRATEGY', ForUsers) - allow(STDERR).to receive(:puts) + allow($stderr).to receive(:puts) Cucumber.deprecate('Use some_method instead', 'someMethod', '1.0.0') - expect(STDERR).to have_received(:puts).with( + expect($stderr).to have_received(:puts).with( a_string_including( 'WARNING: #someMethod is deprecated and will be removed after version 1.0.0. Use some_method instead.' ) diff --git a/spec/cucumber/formatter/http_io_spec.rb b/spec/cucumber/formatter/http_io_spec.rb index acd333dc2f..bd6173ca12 100644 --- a/spec/cucumber/formatter/http_io_spec.rb +++ b/spec/cucumber/formatter/http_io_spec.rb @@ -127,9 +127,11 @@ class DummyFormatter def initialize(config = nil); end + # rubocop:disable Lint/UselessMethodDefinition def ensure_io(path_or_url_or_io, error_stream) super end + # rubocop:enable Lint/UselessMethodDefinition end class DummyReporter From aa4c94bc84bbb0508ebfdeb970e7cc90a7204e07 Mon Sep 17 00:00:00 2001 From: aurelien-reeves Date: Thu, 5 Aug 2021 15:39:03 +0200 Subject: [PATCH 07/38] Apply manual updaates to fix rubocop offenses --- examples/i18n/bg/lib/calculator.rb | 2 + examples/i18n/ru/lib/calculator.rb | 2 + examples/i18n/uk/lib/calculator.rb | 2 + examples/i18n/uz/lib/calculator.rb | 2 + lib/cucumber/events/step_activated.rb | 2 + .../events/step_definition_registered.rb | 2 + lib/cucumber/formatter/console_issues.rb | 4 +- lib/cucumber/formatter/fanout.rb | 2 + .../formatter/ignore_missing_messages.rb | 2 + lib/cucumber/glue/invoke_in_world.rb | 5 +- lib/cucumber/multiline_argument/data_table.rb | 4 ++ lib/cucumber/rspec/disable_option_parser.rb | 3 + lib/cucumber/runtime.rb | 1 + spec/cucumber/cli/configuration_spec.rb | 8 +-- spec/cucumber/filters/gated_receiver_spec.rb | 6 -- spec/cucumber/formatter/http_io_spec.rb | 14 ++--- spec/cucumber/formatter/junit_spec.rb | 51 ++++++++-------- spec/cucumber/formatter/rerun_spec.rb | 20 +------ spec/cucumber/glue/registry_and_more_spec.rb | 48 +++------------ spec/cucumber/glue/step_definition_spec.rb | 11 +--- spec/cucumber/step_match_spec.rb | 16 ++--- spec/support/fake_objects.rb | 60 +++++++++++++++++++ 22 files changed, 146 insertions(+), 121 deletions(-) create mode 100644 spec/support/fake_objects.rb diff --git a/examples/i18n/bg/lib/calculator.rb b/examples/i18n/bg/lib/calculator.rb index c72265a328..3514ac16e9 100644 --- a/examples/i18n/bg/lib/calculator.rb +++ b/examples/i18n/bg/lib/calculator.rb @@ -11,9 +11,11 @@ def result @stack.last end + # rubocop:disable Lint/BinaryOperatorWithIdenticalOperands def + @stack.push @stack.pop + @stack.pop end + # rubocop:enable Lint/BinaryOperatorWithIdenticalOperands def / divisor = @stack.pop diff --git a/examples/i18n/ru/lib/calculator.rb b/examples/i18n/ru/lib/calculator.rb index c72265a328..3514ac16e9 100644 --- a/examples/i18n/ru/lib/calculator.rb +++ b/examples/i18n/ru/lib/calculator.rb @@ -11,9 +11,11 @@ def result @stack.last end + # rubocop:disable Lint/BinaryOperatorWithIdenticalOperands def + @stack.push @stack.pop + @stack.pop end + # rubocop:enable Lint/BinaryOperatorWithIdenticalOperands def / divisor = @stack.pop diff --git a/examples/i18n/uk/lib/calculator.rb b/examples/i18n/uk/lib/calculator.rb index c72265a328..3514ac16e9 100644 --- a/examples/i18n/uk/lib/calculator.rb +++ b/examples/i18n/uk/lib/calculator.rb @@ -11,9 +11,11 @@ def result @stack.last end + # rubocop:disable Lint/BinaryOperatorWithIdenticalOperands def + @stack.push @stack.pop + @stack.pop end + # rubocop:enable Lint/BinaryOperatorWithIdenticalOperands def / divisor = @stack.pop diff --git a/examples/i18n/uz/lib/calculator.rb b/examples/i18n/uz/lib/calculator.rb index c72265a328..3514ac16e9 100644 --- a/examples/i18n/uz/lib/calculator.rb +++ b/examples/i18n/uz/lib/calculator.rb @@ -11,9 +11,11 @@ def result @stack.last end + # rubocop:disable Lint/BinaryOperatorWithIdenticalOperands def + @stack.push @stack.pop + @stack.pop end + # rubocop:enable Lint/BinaryOperatorWithIdenticalOperands def / divisor = @stack.pop diff --git a/lib/cucumber/events/step_activated.rb b/lib/cucumber/events/step_activated.rb index 1ee0278807..c5fe83dfd6 100644 --- a/lib/cucumber/events/step_activated.rb +++ b/lib/cucumber/events/step_activated.rb @@ -20,6 +20,8 @@ class StepActivated < Core::Event.new(:test_step, :step_match) def initialize(test_step, step_match) @test_step = test_step @step_match = step_match + + super end end end diff --git a/lib/cucumber/events/step_definition_registered.rb b/lib/cucumber/events/step_definition_registered.rb index 2ecfba5ee3..f77473bc5d 100644 --- a/lib/cucumber/events/step_definition_registered.rb +++ b/lib/cucumber/events/step_definition_registered.rb @@ -14,6 +14,8 @@ class StepDefinitionRegistered < Core::Event.new(:step_definition) # _@private def initialize(step_definition) @step_definition = step_definition + + super end end end diff --git a/lib/cucumber/formatter/console_issues.rb b/lib/cucumber/formatter/console_issues.rb index 9d97131555..2dc3b789bf 100644 --- a/lib/cucumber/formatter/console_issues.rb +++ b/lib/cucumber/formatter/console_issues.rb @@ -54,7 +54,9 @@ def type_heading(type) def profiles_string return if @config.custom_profiles.empty? - @config.custom_profiles.map { |profile| "-p #{profile}" }.join(' ') + ' ' + profiles = @config.custom_profiles.map { |profile| "-p #{profile}" }.join(' ') + + "#{profiles} " end end end diff --git a/lib/cucumber/formatter/fanout.rb b/lib/cucumber/formatter/fanout.rb index 7cb3eb1e73..d7651562f5 100644 --- a/lib/cucumber/formatter/fanout.rb +++ b/lib/cucumber/formatter/fanout.rb @@ -20,9 +20,11 @@ def method_missing(message, *args) end end + # rubocop:disable Lint/MissingSuper def respond_to_missing?(name, include_private = false) recipients.any? { |recipient| recipient.respond_to?(name, include_private) } end + # rubocop:enable Lint/MissingSuper end end end diff --git a/lib/cucumber/formatter/ignore_missing_messages.rb b/lib/cucumber/formatter/ignore_missing_messages.rb index dcb8af87f6..eb75692872 100644 --- a/lib/cucumber/formatter/ignore_missing_messages.rb +++ b/lib/cucumber/formatter/ignore_missing_messages.rb @@ -11,9 +11,11 @@ def method_missing(message, *args) @receiver.respond_to?(message) ? @receiver.send(message, *args) : super end + # rubocop:disable Lint/MissingSuper def respond_to_missing?(name, include_private = false) @receiver.respond_to?(name, include_private) end + # rubocop:enable Lint/MissingSuper end end end diff --git a/lib/cucumber/glue/invoke_in_world.rb b/lib/cucumber/glue/invoke_in_world.rb index 406ba5b9d3..0da412c080 100644 --- a/lib/cucumber/glue/invoke_in_world.rb +++ b/lib/cucumber/glue/invoke_in_world.rb @@ -40,9 +40,8 @@ def self.cucumber_instance_exec_in(world, check_arity, pseudo_method, *args, &bl def self.cucumber_compatible_arity?(args, block) return true if block.arity == args.length - if block.arity < 0 - return true if args.length >= (block.arity.abs - 1) - end + return true if block.arity.negative? && args.length >= (block.arity.abs - 1) + false end diff --git a/lib/cucumber/multiline_argument/data_table.rb b/lib/cucumber/multiline_argument/data_table.rb index 831d726f23..93f0539c36 100644 --- a/lib/cucumber/multiline_argument/data_table.rb +++ b/lib/cucumber/multiline_argument/data_table.rb @@ -284,18 +284,22 @@ def map_headers(mappings = {}, &block) # end # end # + # rubocop:disable Style/OptionalBooleanParameter def map_column!(column_name, strict = true, &conversion_proc) # TODO: Remove this method for 2.0 @conversion_procs[column_name.to_s] = { strict: strict, proc: conversion_proc } self end + # rubocop:enable Style/OptionalBooleanParameter + # rubocop:disable Style/OptionalBooleanParameter # Returns a new Table with an additional column mapping. See #map_column! def map_column(column_name, strict = true, &conversion_proc) conversion_procs = @conversion_procs.dup conversion_procs[column_name.to_s] = { strict: strict, proc: conversion_proc } self.class.new(Core::Test::DataTable.new(raw), conversion_procs, @header_mappings.dup, @header_conversion_proc) end + # rubocop:enable Style/OptionalBooleanParameter # Compares +other_table+ to self. If +other_table+ contains columns # and/or rows that are not in self, new columns/rows are added at the diff --git a/lib/cucumber/rspec/disable_option_parser.rb b/lib/cucumber/rspec/disable_option_parser.rb index 8fe81a3654..fcf05b6a98 100644 --- a/lib/cucumber/rspec/disable_option_parser.rb +++ b/lib/cucumber/rspec/disable_option_parser.rb @@ -15,11 +15,14 @@ def NEUTERED_RSPEC.method_missing(_method, *_args) # rubocop:disable Style/Missi def self.method_added(method) return if @__neutering_rspec + @__neutering_rspec = true define_method(method) do |*_a| NEUTERED_RSPEC end @__neutering_rspec = false + + super end end end diff --git a/lib/cucumber/runtime.rb b/lib/cucumber/runtime.rb index 5f11a29e1d..54f474efef 100644 --- a/lib/cucumber/runtime.rb +++ b/lib/cucumber/runtime.rb @@ -34,6 +34,7 @@ class FileNotFoundException < FileException class FeatureFolderNotFoundException < RuntimeError def initialize(path) + super @path = path end diff --git a/spec/cucumber/cli/configuration_spec.rb b/spec/cucumber/cli/configuration_spec.rb index bc9d9a1991..c9a00a929b 100644 --- a/spec/cucumber/cli/configuration_spec.rb +++ b/spec/cucumber/cli/configuration_spec.rb @@ -5,11 +5,11 @@ module Cucumber module Cli - describe Configuration do - module ExposesOptions - attr_reader :options - end + module ExposesOptions + attr_reader :options + end + describe Configuration do def given_cucumber_yml_defined_as(hash_or_string) allow(File).to receive(:exist?) { true } diff --git a/spec/cucumber/filters/gated_receiver_spec.rb b/spec/cucumber/filters/gated_receiver_spec.rb index 6d1e45175e..f101d665d0 100644 --- a/spec/cucumber/filters/gated_receiver_spec.rb +++ b/spec/cucumber/filters/gated_receiver_spec.rb @@ -12,9 +12,6 @@ it 'does not immediately describe the test case to the receiver' do test_cases.each do |test_case| expect(test_case).to_not receive(:describe_to).with(receiver) - end - - test_cases.each do |test_case| gated_receiver.test_case(test_case) end end @@ -24,9 +21,6 @@ before do test_cases.each do |test_case| gated_receiver.test_case(test_case) - end - - test_cases.each do |test_case| allow(test_case).to receive(:describe_to).with(receiver) end diff --git a/spec/cucumber/formatter/http_io_spec.rb b/spec/cucumber/formatter/http_io_spec.rb index bd6173ca12..29eb617fcc 100644 --- a/spec/cucumber/formatter/http_io_spec.rb +++ b/spec/cucumber/formatter/http_io_spec.rb @@ -6,15 +6,15 @@ require 'spec_helper' require 'cucumber/formatter/io' -RSpec.shared_context 'an HTTP server accepting file requests' do - module WEBrick - module HTTPServlet - class ProcHandler < AbstractServlet - alias do_PUT do_GET # Webrick #mount_proc only works with GET,HEAD,POST,OPTIONS by default - end +module WEBrick + module HTTPServlet + class ProcHandler < AbstractServlet + alias do_PUT do_GET # Webrick #mount_proc only works with GET,HEAD,POST,OPTIONS by default end end +end +RSpec.shared_context 'an HTTP server accepting file requests' do let(:putreport_returned_location) { URI('/s3').to_s } let(:success_banner) do @@ -288,7 +288,7 @@ def report(banner); end io.close @received_body_io.rewind received_body = @received_body_io.read - expect(received_body).to eq(sent_body + sent_body) + expect(received_body).to eq("#{sent_body}#{sent_body}") end it 'only sends body once' do diff --git a/spec/cucumber/formatter/junit_spec.rb b/spec/cucumber/formatter/junit_spec.rb index 30f4f18b91..355450df74 100644 --- a/spec/cucumber/formatter/junit_spec.rb +++ b/spec/cucumber/formatter/junit_spec.rb @@ -2,42 +2,41 @@ require 'spec_helper' require 'cucumber/formatter/spec_helper' - require 'cucumber/formatter/junit' require 'nokogiri' module Cucumber module Formatter - describe Junit do - extend SpecHelperDsl - include SpecHelper - - class TestDoubleJunitFormatter < Junit - attr_reader :written_files + class TestDoubleJunitFormatter < ::Cucumber::Formatter::Junit + attr_reader :written_files - def initialize(config) - super - config.on_event :test_step_started, &method(:on_test_step_started) - end + def initialize(config) + super + config.on_event :test_step_started, &method(:on_test_step_started) + end - def on_test_step_started(_event) - Interceptor::Pipe.unwrap! :stdout - @fake_io = $stdout = StringIO.new - $stdout.sync = true - @interceptedout = Interceptor::Pipe.wrap(:stdout) - end + def on_test_step_started(_event) + Interceptor::Pipe.unwrap! :stdout + @fake_io = $stdout = StringIO.new + $stdout.sync = true + @interceptedout = Interceptor::Pipe.wrap(:stdout) + end - def on_test_step_finished(event) - super - $stdout = STDOUT - @fake_io.close - end + def on_test_step_finished(event) + super + $stdout = STDOUT + @fake_io.close + end - def write_file(feature_filename, data) - @written_files ||= {} - @written_files[feature_filename] = data - end + def write_file(feature_filename, data) + @written_files ||= {} + @written_files[feature_filename] = data end + end + + describe Junit do + extend SpecHelperDsl + include SpecHelper context 'With --junit,fileattribute=true option' do before(:each) do diff --git a/spec/cucumber/formatter/rerun_spec.rb b/spec/cucumber/formatter/rerun_spec.rb index 7c357c1b9c..af1a03ad99 100644 --- a/spec/cucumber/formatter/rerun_spec.rb +++ b/spec/cucumber/formatter/rerun_spec.rb @@ -3,9 +3,9 @@ require 'cucumber/formatter/rerun' require 'cucumber/core' require 'cucumber/core/gherkin/writer' -require 'cucumber/core/filter' require 'support/standard_step_actions' require 'cucumber/configuration' +require 'support/fake_objects' module Cucumber module Formatter @@ -95,20 +95,6 @@ module Formatter end context 'with only a flaky scenarios' do - class FlakyStepActions < Cucumber::Core::Filter.new - def test_case(test_case) - failing_test_steps = test_case.test_steps.map do |step| - step.with_action { raise Failure } - end - passing_test_steps = test_case.test_steps.map do |step| - step.with_action {} - end - - test_case.with_steps(failing_test_steps).describe_to(receiver) - test_case.with_steps(passing_test_steps).describe_to(receiver) - end - end - context 'with option --no-strict-flaky' do it 'prints nothing' do gherkin = gherkin('foo.feature') do @@ -120,7 +106,7 @@ def test_case(test_case) end Rerun.new(config) - execute [gherkin], [FlakyStepActions.new], config.event_bus + execute [gherkin], [FakeObjects::FlakyStepActions.new], config.event_bus config.event_bus.test_run_finished expect(io.string).to eq '' @@ -139,7 +125,7 @@ def test_case(test_case) end Rerun.new(config) - execute [foo], [FlakyStepActions.new], config.event_bus + execute [foo], [FakeObjects::FlakyStepActions.new], config.event_bus config.event_bus.test_run_finished expect(io.string).to eq 'foo.feature:3' diff --git a/spec/cucumber/glue/registry_and_more_spec.rb b/spec/cucumber/glue/registry_and_more_spec.rb index 4124e06d9b..a2aaf378a0 100644 --- a/spec/cucumber/glue/registry_and_more_spec.rb +++ b/spec/cucumber/glue/registry_and_more_spec.rb @@ -2,6 +2,7 @@ require 'spec_helper' require 'cucumber/glue/registry_and_more' +require 'support/fake_objects' module Cucumber module Glue @@ -148,17 +149,8 @@ def a_file_called(name) end end - module ModuleOne - end - - module ModuleTwo - end - - class ClassOne - end - it 'implicitlys extend world with modules' do - dsl.World(ModuleOne, ModuleTwo) + dsl.World(FakeObjects::ModuleOne, FakeObjects::ModuleTwo) registry.begin_scenario(double('scenario').as_null_object) class << registry.current_world extend RSpec::Matchers @@ -187,32 +179,8 @@ class << registry.current_world end describe 'Handling namespaced World' do - module ModuleOne - def method_one - 1 - end - end - - module ModuleMinusOne - def method_one - -1 - end - end - - module ModuleTwo - def method_two - 2 - end - end - - module ModuleThree - def method_three - 3 - end - end - it 'extends the world with namespaces' do - dsl.World(ModuleOne, module_two: ModuleTwo, module_three: ModuleThree) + dsl.World(FakeObjects::ModuleOne, module_two: FakeObjects::ModuleTwo, module_three: FakeObjects::ModuleThree) registry.begin_scenario(double('scenario').as_null_object) class << registry.current_world extend RSpec::Matchers @@ -229,7 +197,7 @@ class << registry.current_world end it 'allows to inspect the included modules' do - dsl.World(ModuleOne, module_two: ModuleTwo, module_three: ModuleThree) + dsl.World(FakeObjects::ModuleOne, module_two: FakeObjects::ModuleTwo, module_three: FakeObjects::ModuleThree) registry.begin_scenario(double('scenario').as_null_object) class << registry.current_world extend RSpec::Matchers @@ -240,8 +208,8 @@ class << registry.current_world end it 'merges methods when assigning different modules to the same namespace' do - dsl.World(namespace: ModuleOne) - dsl.World(namespace: ModuleTwo) + dsl.World(namespace: FakeObjects::ModuleOne) + dsl.World(namespace: FakeObjects::ModuleTwo) registry.begin_scenario(double('scenario').as_null_object) class << registry.current_world extend RSpec::Matchers @@ -251,8 +219,8 @@ class << registry.current_world end it 'resolves conflicts when assigning different modules to the same namespace' do - dsl.World(namespace: ModuleOne) - dsl.World(namespace: ModuleMinusOne) + dsl.World(namespace: FakeObjects::ModuleOne) + dsl.World(namespace: FakeObjects::ModuleMinusOne) registry.begin_scenario(double('scenario').as_null_object) class << registry.current_world extend RSpec::Matchers diff --git a/spec/cucumber/glue/step_definition_spec.rb b/spec/cucumber/glue/step_definition_spec.rb index 65b42a39cf..f9cee4e778 100644 --- a/spec/cucumber/glue/step_definition_spec.rb +++ b/spec/cucumber/glue/step_definition_spec.rb @@ -3,6 +3,7 @@ # rubocop:disable Style/ClassVars require 'spec_helper' require 'cucumber/glue/registry_and_more' +require 'support/fake_objects' module Cucumber module Glue @@ -165,21 +166,13 @@ def step_match(text) end context 'with ParameterType' do - class Actor - attr_accessor :name - - def initialize(name) - @name = name - end - end - before(:each) do @actor = nil dsl.ParameterType( name: 'actor', regexp: /[A-Z]{1}[a-z]+/, - transformer: ->(name) { @actor = Actor.new(name) } + transformer: ->(name) { @actor = FakeObjects::Actor.new(name) } ) end diff --git a/spec/cucumber/step_match_spec.rb b/spec/cucumber/step_match_spec.rb index 301c8a0979..b1f9c398c0 100644 --- a/spec/cucumber/step_match_spec.rb +++ b/spec/cucumber/step_match_spec.rb @@ -6,7 +6,7 @@ module Cucumber describe StepMatch do - WORD = '[[:word:]]'.freeze + let(:word) { '[[:word:]]' } before do @registry = Glue::RegistryAndMore.new(nil, Configuration.new) @@ -28,13 +28,13 @@ def step_match(regexp, name) end it 'formats one group when we use Unicode' do - m = step_match(/I (#{WORD}+) ok/, 'I æøåÆØÅæøåÆØÅæøåÆØÅæøåÆØÅ ok') + m = step_match(/I (#{word}+) ok/, 'I æøåÆØÅæøåÆØÅæøåÆØÅæøåÆØÅ ok') expect(m.format_args('%s')).to eq 'I æøåÆØÅæøåÆØÅæøåÆØÅæøåÆØÅ ok' end it 'formats several groups when we use Unicode' do - m = step_match(/I (#{WORD}+) (#{WORD}+) (#{WORD}+) this (#{WORD}+)/, 'I ate æøåÆØÅæøåÆØÅæøåÆØÅæøåÆØÅ egg this morning') + m = step_match(/I (#{word}+) (#{word}+) (#{word}+) this (#{word}+)/, 'I ate æøåÆØÅæøåÆØÅæøåÆØÅæøåÆØÅ egg this morning') expect(m.format_args('%s')).to eq 'I ate æøåÆØÅæøåÆØÅæøåÆØÅæøåÆØÅ egg this morning' end @@ -42,31 +42,31 @@ def step_match(regexp, name) it 'deals with Unicode both inside and outside arguments' do expect('Jæ vø ålsker døtte løndet').to match(/Jæ (.+) ålsker (.+) løndet/) - m = step_match(/Jæ (#{WORD}+) ålsker (#{WORD}+) løndet/, 'Jæ vø ålsker døtte løndet') + m = step_match(/Jæ (#{word}+) ålsker (#{word}+) løndet/, 'Jæ vø ålsker døtte løndet') expect(m.format_args('%s')).to eq 'Jæ ålsker døtte løndet' end it 'formats groups with format string' do - m = step_match(/I (#{WORD}+) (\d+) (#{WORD}+) this (#{WORD}+)/, 'I ate 1 egg this morning') + m = step_match(/I (#{word}+) (\d+) (#{word}+) this (#{word}+)/, 'I ate 1 egg this morning') expect(m.format_args('%s')).to eq 'I ate 1 egg this morning' end it 'formats groups with format string when there are dupes' do - m = step_match(/I (#{WORD}+) (\d+) (#{WORD}+) this (#{WORD}+)/, 'I bob 1 bo this bobs') + m = step_match(/I (#{word}+) (\d+) (#{word}+) this (#{word}+)/, 'I bob 1 bo this bobs') expect(m.format_args('%s')).to eq 'I bob 1 bo this bobs' end it 'formats groups with block' do - m = step_match(/I (#{WORD}+) (\d+) (#{WORD}+) this (#{WORD}+)/, 'I ate 1 egg this morning') + m = step_match(/I (#{word}+) (\d+) (#{word}+) this (#{word}+)/, 'I ate 1 egg this morning') expect(m.format_args(&->(msg) { "#{msg}" })).to eq 'I ate 1 egg this morning' end it 'formats groups with proc object' do - m = step_match(/I (#{WORD}+) (\d+) (#{WORD}+) this (#{WORD}+)/, 'I ate 1 egg this morning') + m = step_match(/I (#{word}+) (\d+) (#{word}+) this (#{word}+)/, 'I ate 1 egg this morning') expect(m.format_args(->(msg) { "#{msg}" })).to eq 'I ate 1 egg this morning' end diff --git a/spec/support/fake_objects.rb b/spec/support/fake_objects.rb new file mode 100644 index 0000000000..6660668331 --- /dev/null +++ b/spec/support/fake_objects.rb @@ -0,0 +1,60 @@ +# frozen_string_literal: true + +require 'cucumber/core/filter' + +# The following fake objects was previously declared within `describe` scope. +# Declaring into scope did not isolate them. +# +# Moving those into a dedicated support file explitely state that those are available +# globaly as soon as they are required once. + +module FakeObjects + module ModuleOne + def method_one + 1 + end + end + + module ModuleMinusOne + def method_one + -1 + end + end + + module ModuleTwo + def method_two + 2 + end + end + + module ModuleThree + def method_three + 3 + end + end + + class ClassOne + end + + class Actor + attr_accessor :name + + def initialize(name) + @name = name + end + end + + class FlakyStepActions < ::Cucumber::Core::Filter.new + def test_case(test_case) + failing_test_steps = test_case.test_steps.map do |step| + step.with_action { raise Failure } + end + passing_test_steps = test_case.test_steps.map do |step| + step.with_action {} + end + + test_case.with_steps(failing_test_steps).describe_to(receiver) + test_case.with_steps(passing_test_steps).describe_to(receiver) + end + end +end From 0e2d9a538573724e94976aa8a9b5f1867b753815 Mon Sep 17 00:00:00 2001 From: aurelien-reeves Date: Fri, 6 Aug 2021 10:54:55 +0200 Subject: [PATCH 08/38] Refactor calculator example to prevent disabling rubocop --- examples/i18n/bg/lib/calculator.rb | 9 +++++---- examples/i18n/ru/lib/calculator.rb | 9 +++++---- examples/i18n/uk/lib/calculator.rb | 9 +++++---- examples/i18n/uz/lib/calculator.rb | 9 +++++---- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/examples/i18n/bg/lib/calculator.rb b/examples/i18n/bg/lib/calculator.rb index 3514ac16e9..bdec9113e7 100644 --- a/examples/i18n/bg/lib/calculator.rb +++ b/examples/i18n/bg/lib/calculator.rb @@ -11,16 +11,17 @@ def result @stack.last end - # rubocop:disable Lint/BinaryOperatorWithIdenticalOperands def + - @stack.push @stack.pop + @stack.pop + number_1 = @stack.pop + number_2 = @stack.pop + + @stack.push number_1 + number_2 end - # rubocop:enable Lint/BinaryOperatorWithIdenticalOperands def / divisor = @stack.pop dividend = @stack.pop - # Hm, @stack.pop(2) doesn't work + @stack.push dividend / divisor end end diff --git a/examples/i18n/ru/lib/calculator.rb b/examples/i18n/ru/lib/calculator.rb index 3514ac16e9..bdec9113e7 100644 --- a/examples/i18n/ru/lib/calculator.rb +++ b/examples/i18n/ru/lib/calculator.rb @@ -11,16 +11,17 @@ def result @stack.last end - # rubocop:disable Lint/BinaryOperatorWithIdenticalOperands def + - @stack.push @stack.pop + @stack.pop + number_1 = @stack.pop + number_2 = @stack.pop + + @stack.push number_1 + number_2 end - # rubocop:enable Lint/BinaryOperatorWithIdenticalOperands def / divisor = @stack.pop dividend = @stack.pop - # Hm, @stack.pop(2) doesn't work + @stack.push dividend / divisor end end diff --git a/examples/i18n/uk/lib/calculator.rb b/examples/i18n/uk/lib/calculator.rb index 3514ac16e9..bdec9113e7 100644 --- a/examples/i18n/uk/lib/calculator.rb +++ b/examples/i18n/uk/lib/calculator.rb @@ -11,16 +11,17 @@ def result @stack.last end - # rubocop:disable Lint/BinaryOperatorWithIdenticalOperands def + - @stack.push @stack.pop + @stack.pop + number_1 = @stack.pop + number_2 = @stack.pop + + @stack.push number_1 + number_2 end - # rubocop:enable Lint/BinaryOperatorWithIdenticalOperands def / divisor = @stack.pop dividend = @stack.pop - # Hm, @stack.pop(2) doesn't work + @stack.push dividend / divisor end end diff --git a/examples/i18n/uz/lib/calculator.rb b/examples/i18n/uz/lib/calculator.rb index 3514ac16e9..bdec9113e7 100644 --- a/examples/i18n/uz/lib/calculator.rb +++ b/examples/i18n/uz/lib/calculator.rb @@ -11,16 +11,17 @@ def result @stack.last end - # rubocop:disable Lint/BinaryOperatorWithIdenticalOperands def + - @stack.push @stack.pop + @stack.pop + number_1 = @stack.pop + number_2 = @stack.pop + + @stack.push number_1 + number_2 end - # rubocop:enable Lint/BinaryOperatorWithIdenticalOperands def / divisor = @stack.pop dividend = @stack.pop - # Hm, @stack.pop(2) doesn't work + @stack.push dividend / divisor end end From ac4ffb909d7c45da61794d70c2633bc3c449141b Mon Sep 17 00:00:00 2001 From: aurelien-reeves Date: Fri, 6 Aug 2021 11:11:21 +0200 Subject: [PATCH 09/38] Do not fail fast workflow --- .github/workflows/cucumber-ruby.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cucumber-ruby.yml b/.github/workflows/cucumber-ruby.yml index 56375cf90d..b9154d7f54 100644 --- a/.github/workflows/cucumber-ruby.yml +++ b/.github/workflows/cucumber-ruby.yml @@ -20,6 +20,7 @@ on: jobs: test: strategy: + fail-fast: false matrix: os: [ubuntu-latest, macos-latest, windows-latest] # Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0' From 922ae1b022041db2e9fa3fb8f142556f9e6c1d37 Mon Sep 17 00:00:00 2001 From: aurelien-reeves Date: Fri, 6 Aug 2021 11:23:47 +0200 Subject: [PATCH 10/38] Fix jruby CI job --- examples/sinatra/features/support/env.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/sinatra/features/support/env.rb b/examples/sinatra/features/support/env.rb index 1d3659b408..e52a7a5615 100644 --- a/examples/sinatra/features/support/env.rb +++ b/examples/sinatra/features/support/env.rb @@ -1,7 +1,7 @@ # See http://wiki.github.com/cucumber/cucumber/sinatra # for more details about Sinatra with Cucumber -require "#{File.dirname(__FILE__)}./../../app" +require "#{File.dirname(__FILE__)}/../../app" require 'rack/test' require 'capybara/cucumber' From 9203b24fe082e56e904a32479e1c664fed8b212e Mon Sep 17 00:00:00 2001 From: aurelien-reeves Date: Fri, 6 Aug 2021 11:43:22 +0200 Subject: [PATCH 11/38] Add ruby 2.3 to CI --- .github/workflows/cucumber-ruby.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cucumber-ruby.yml b/.github/workflows/cucumber-ruby.yml index b9154d7f54..3d87cf0879 100644 --- a/.github/workflows/cucumber-ruby.yml +++ b/.github/workflows/cucumber-ruby.yml @@ -24,7 +24,7 @@ jobs: matrix: os: [ubuntu-latest, macos-latest, windows-latest] # Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0' - ruby: [2.5, 2.6, 2.7, '3.0'] + ruby: [2.3, 2.5, 2.6, 2.7, '3.0'] include: - os: ubuntu-latest ruby: jruby From d5104897b6823ee35dd8068dda5a449bd42fc7a5 Mon Sep 17 00:00:00 2001 From: aurelien-reeves Date: Fri, 6 Aug 2021 11:44:11 +0200 Subject: [PATCH 12/38] Revert "Add ruby 2.3 to CI" This reverts commit 9203b24fe082e56e904a32479e1c664fed8b212e. --- .github/workflows/cucumber-ruby.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cucumber-ruby.yml b/.github/workflows/cucumber-ruby.yml index 3d87cf0879..b9154d7f54 100644 --- a/.github/workflows/cucumber-ruby.yml +++ b/.github/workflows/cucumber-ruby.yml @@ -24,7 +24,7 @@ jobs: matrix: os: [ubuntu-latest, macos-latest, windows-latest] # Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0' - ruby: [2.3, 2.5, 2.6, 2.7, '3.0'] + ruby: [2.5, 2.6, 2.7, '3.0'] include: - os: ubuntu-latest ruby: jruby From 0180d560d618df638994b4cd6cdfc42eb9952c59 Mon Sep 17 00:00:00 2001 From: aurelien-reeves Date: Wed, 25 Aug 2021 11:58:04 +0200 Subject: [PATCH 13/38] Upgrade rubocop to 1.1.0 --- Gemfile | 2 +- lib/cucumber/cli/configuration.rb | 2 ++ lib/cucumber/formatter/errors.rb | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index b2716f96e9..55af4e1f02 100644 --- a/Gemfile +++ b/Gemfile @@ -21,5 +21,5 @@ gem 'cucumber-gherkin', path: ENV['GHERKIN_RUBY'] if ENV['GHERKIN_RUBY'] gem 'cucumber-html-formatter', path: ENV['CUCUMBER_HTML_FORMATTER_RUBY'] if ENV['CUCUMBER_HTML_FORMATTER_RUBY'] gem 'cucumber-messages', path: ENV['CUCUMBER_MESSAGES_RUBY'] if ENV['CUCUMBER_MESSAGES_RUBY'] -gem 'rubocop', '~> 1.0', '= 1.0.0' +gem 'rubocop', '~> 1.1', '= 1.1.0' gem 'rubocop-packaging', '~> 0.3', '= 0.5.1' diff --git a/lib/cucumber/cli/configuration.rb b/lib/cucumber/cli/configuration.rb index 493b52505c..6800429d31 100644 --- a/lib/cucumber/cli/configuration.rb +++ b/lib/cucumber/cli/configuration.rb @@ -9,7 +9,9 @@ module Cucumber module Cli class YmlLoadError < StandardError; end + class ProfilesNotDefinedError < YmlLoadError; end + class ProfileNotFound < StandardError; end class Configuration diff --git a/lib/cucumber/formatter/errors.rb b/lib/cucumber/formatter/errors.rb index 7549548a57..4ee51991ab 100644 --- a/lib/cucumber/formatter/errors.rb +++ b/lib/cucumber/formatter/errors.rb @@ -1,6 +1,7 @@ module Cucumber module Formatter class TestCaseUnknownError < StandardError; end + class TestStepUnknownError < StandardError; end end end From 640a345dd2e6b0ba1cf68677033b88d9d055ef45 Mon Sep 17 00:00:00 2001 From: aurelien-reeves Date: Wed, 27 Oct 2021 09:17:55 +0200 Subject: [PATCH 14/38] Remove disabling of rubocop/redundant begin We actually do not support ruby 2.3 anymore --- features/lib/support/command_line.rb | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/features/lib/support/command_line.rb b/features/lib/support/command_line.rb index 172a0b5ea1..d2f8de9e05 100644 --- a/features/lib/support/command_line.rb +++ b/features/lib/support/command_line.rb @@ -48,14 +48,9 @@ def capture_stdout end def destroy_mocks - # rubocop:disable Style/RedundantBegin - # TODO: remove the begin/end block when we drop 2.3 uport and CI job. - begin - ::RSpec::Mocks.verify - ensure - ::RSpec::Mocks.teardown - end - # rubocop:enable Style/RedundantBegin + ::RSpec::Mocks.verify + ensure + ::RSpec::Mocks.teardown end private From eaecf99beeffeb2614a9918e89e854bceb09278a Mon Sep 17 00:00:00 2001 From: aurelien-reeves Date: Wed, 27 Oct 2021 14:22:44 +0200 Subject: [PATCH 15/38] Fix broken tests after merging main --- spec/cucumber/glue/registry_and_more_spec.rb | 4 ++-- spec/cucumber/runtime_spec.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/cucumber/glue/registry_and_more_spec.rb b/spec/cucumber/glue/registry_and_more_spec.rb index 4f1d9525d1..d963c258fa 100644 --- a/spec/cucumber/glue/registry_and_more_spec.rb +++ b/spec/cucumber/glue/registry_and_more_spec.rb @@ -258,13 +258,13 @@ class << registry.current_world it 'shows a deprecation warning for after_configuration hooks' do stub_const('Cucumber::Deprecate::STRATEGY', Cucumber::Deprecate::ForUsers) - allow(STDERR).to receive(:puts) + allow($stdout).to receive(:puts) dsl.AfterConfiguration() {} registry.after_configuration(nil) - expect(STDERR).to have_received(:puts).with( + expect($stdout).to have_received(:puts).with( a_string_including([ 'WARNING: # AfterConfiguration hook is deprecated and will be removed after version 8.0.0.', 'See https://github.com/cucumber/cucumber-ruby/blob/main/UPGRADING.md#upgrading-to-710 for more info.' diff --git a/spec/cucumber/runtime_spec.rb b/spec/cucumber/runtime_spec.rb index 286d256e91..d8cdf3f0bd 100644 --- a/spec/cucumber/runtime_spec.rb +++ b/spec/cucumber/runtime_spec.rb @@ -24,7 +24,7 @@ module Cucumber describe '#install_wire_plugin' do it 'informs the user it is deprecated' do stub_const('Cucumber::Deprecate::STRATEGY', Cucumber::Deprecate::ForUsers) - allow(STDERR).to receive(:puts) + allow($stdout).to receive(:puts) allow_any_instance_of(Configuration).to receive(:all_files_to_load).and_return(['file.wire']) begin @@ -33,7 +33,7 @@ module Cucumber # this is actually expected end - expect(STDERR).to have_received(:puts).with( + expect($stdout).to have_received(:puts).with( a_string_including([ 'WARNING: # built-in usage of the wire protocol is deprecated and will be removed after version 8.0.0.', 'See https://github.com/cucumber/cucumber-ruby/blob/main/UPGRADING.md#upgrading-to-710 for more info.' From f0ee77dbf47e8ee8cc08ccf7807a9c1107a0fe7d Mon Sep 17 00:00:00 2001 From: aurelien-reeves Date: Wed, 27 Oct 2021 14:23:57 +0200 Subject: [PATCH 16/38] Remove inline rubocop magic comment --- lib/autotest/cucumber_mixin.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/autotest/cucumber_mixin.rb b/lib/autotest/cucumber_mixin.rb index a3069bbb04..fe62193df1 100644 --- a/lib/autotest/cucumber_mixin.rb +++ b/lib/autotest/cucumber_mixin.rb @@ -24,7 +24,7 @@ def run add_sigint_handler loop do # ^c handler - get_to_green + wait_for_green if tainted rerun_all_tests rerun_all_features if all_good @@ -47,7 +47,7 @@ def all_features_good features_to_run == '' end - def get_to_green # rubocop:disable Naming/AccessorMethodName + def wait_for_green loop do super run_features From d92d7122315f852e4b27820d533a5b02d5b99ec4 Mon Sep 17 00:00:00 2001 From: aurelien-reeves Date: Wed, 27 Oct 2021 14:40:44 +0200 Subject: [PATCH 17/38] Fix rubocop Style/RegexpLiteral offenses --- .rubocop.yml | 5 +---- lib/cucumber/configuration.rb | 2 +- spec/cucumber/project_initializer_spec.rb | 12 ++++++------ 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 786a7ceba9..bee272f029 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -150,9 +150,6 @@ Style/StderrPuts: Enabled: false # Slashes are by far the most used form of regex values in the project. -# Rubocop doesn't handle all cases well (currently), so this cop has been -# disabled in some cases. +# But when a '/' is found in the regexp, usage of %r{} is required Style/RegexpLiteral: EnforcedStyle: slashes - Exclude: - - 'spec/cucumber/project_initializer_spec.rb' diff --git a/lib/cucumber/configuration.rb b/lib/cucumber/configuration.rb index 32b6c91de1..cae5e46ef6 100644 --- a/lib/cucumber/configuration.rb +++ b/lib/cucumber/configuration.rb @@ -189,7 +189,7 @@ def support_to_load def all_files_to_load files = require_dirs.map do |path| path = path.tr('\\', '/') # In case we're on windows. Globs don't work with backslashes. - path = path.gsub(/\/$/, '') # Strip trailing slash. # rubocop:disable Style/RegexpLiteral + path = path.gsub(%r{/$}, '') # Strip trailing slash. File.directory?(path) ? Dir["#{path}/**/*"] : path end.flatten.uniq remove_excluded_files_from(files) diff --git a/spec/cucumber/project_initializer_spec.rb b/spec/cucumber/project_initializer_spec.rb index 8e7992b780..621c9155c6 100644 --- a/spec/cucumber/project_initializer_spec.rb +++ b/spec/cucumber/project_initializer_spec.rb @@ -30,17 +30,17 @@ module Cucumber end it 'should create step_definitions directory' do - expect(command_line_config).to receive(:puts).with(/^\s+create\s+features\/step_definitions$/) + expect(command_line_config).to receive(:puts).with(%r{^\s+create\s+features/step_definitions$}) command_line_config.run end it 'should create support directory' do - expect(command_line_config).to receive(:puts).with(/^\s+create\s+features\/support$/) + expect(command_line_config).to receive(:puts).with(%r{^\s+create\s+features/support$}) command_line_config.run end it 'should create env.rb directory' do - expect(command_line_config).to receive(:puts).with(/^\s+create\s+features\/support\/env.rb$/) + expect(command_line_config).to receive(:puts).with(%r{^\s+create\s+features/support/env.rb$}) command_line_config.run end end @@ -68,17 +68,17 @@ module Cucumber end it 'should not create step_definitions directory' do - expect(command_line_config).to receive(:puts).with(/^\s+exist\s+features\/step_definitions$/) + expect(command_line_config).to receive(:puts).with(%r{^\s+exist\s+features/step_definitions$}) command_line_config.run end it 'should not create support directory' do - expect(command_line_config).to receive(:puts).with(/^\s+exist\s+features\/support$/) + expect(command_line_config).to receive(:puts).with(%r{^\s+exist\s+features/support$}) command_line_config.run end it 'should not create env.rb directory' do - expect(command_line_config).to receive(:puts).with(/^\s+exist\s+features\/support\/env.rb$/) + expect(command_line_config).to receive(:puts).with(%r{^\s+exist\s+features/support/env.rb$}) command_line_config.run end end From c8ee7fbe6a8b1dec244022c12fba8188f494d67b Mon Sep 17 00:00:00 2001 From: aurelien-reeves Date: Wed, 27 Oct 2021 15:38:01 +0200 Subject: [PATCH 18/38] Remove a few rubocop magic comments --- lib/cucumber/formatter/backtrace_filter.rb | 2 +- lib/cucumber/formatter/fanout.rb | 4 +--- lib/cucumber/formatter/ignore_missing_messages.rb | 4 +--- lib/cucumber/formatter/junit.rb | 2 +- lib/cucumber/multiline_argument/data_table.rb | 4 ++-- spec/cucumber/formatter/http_io_spec.rb | 10 ++++------ spec/cucumber/glue/registry_and_more_spec.rb | 6 +++--- 7 files changed, 13 insertions(+), 19 deletions(-) diff --git a/lib/cucumber/formatter/backtrace_filter.rb b/lib/cucumber/formatter/backtrace_filter.rb index 13dc492aa6..57194ce6d7 100644 --- a/lib/cucumber/formatter/backtrace_filter.rb +++ b/lib/cucumber/formatter/backtrace_filter.rb @@ -33,7 +33,7 @@ def initialize(exception) def exception return @exception if ::Cucumber.use_full_backtrace - pwd_pattern = /#{::Regexp.escape(::Dir.pwd)}\//m # rubocop:disable Style/RegexpLiteral + pwd_pattern = %r{#{::Regexp.escape(::Dir.pwd)}/}m backtrace = @exception.backtrace.map { |line| line.gsub(pwd_pattern, './') } filtered = (backtrace || []).reject do |line| diff --git a/lib/cucumber/formatter/fanout.rb b/lib/cucumber/formatter/fanout.rb index d7651562f5..3c907ca5d2 100644 --- a/lib/cucumber/formatter/fanout.rb +++ b/lib/cucumber/formatter/fanout.rb @@ -20,11 +20,9 @@ def method_missing(message, *args) end end - # rubocop:disable Lint/MissingSuper def respond_to_missing?(name, include_private = false) - recipients.any? { |recipient| recipient.respond_to?(name, include_private) } + recipients.any? { |recipient| recipient.respond_to?(name, include_private) } || super(name, include_private) end - # rubocop:enable Lint/MissingSuper end end end diff --git a/lib/cucumber/formatter/ignore_missing_messages.rb b/lib/cucumber/formatter/ignore_missing_messages.rb index eb75692872..ca2bd6befe 100644 --- a/lib/cucumber/formatter/ignore_missing_messages.rb +++ b/lib/cucumber/formatter/ignore_missing_messages.rb @@ -11,11 +11,9 @@ def method_missing(message, *args) @receiver.respond_to?(message) ? @receiver.send(message, *args) : super end - # rubocop:disable Lint/MissingSuper def respond_to_missing?(name, include_private = false) - @receiver.respond_to?(name, include_private) + @receiver.respond_to?(name, include_private) || super(name, include_private) end - # rubocop:enable Lint/MissingSuper end end end diff --git a/lib/cucumber/formatter/junit.rb b/lib/cucumber/formatter/junit.rb index d82eafd060..7fbef5b01f 100644 --- a/lib/cucumber/formatter/junit.rb +++ b/lib/cucumber/formatter/junit.rb @@ -191,7 +191,7 @@ def feature_result_filename(feature_file) end def basename(feature_file) - File.basename(feature_file.gsub(/[\\\/]/, '-'), '.feature') # rubocop:disable Style/RegexpLiteral + File.basename(feature_file.gsub(%r{[\\/]}, '-'), '.feature') end def write_file(feature_filename, data) diff --git a/lib/cucumber/multiline_argument/data_table.rb b/lib/cucumber/multiline_argument/data_table.rb index 93f0539c36..730f4eb0a2 100644 --- a/lib/cucumber/multiline_argument/data_table.rb +++ b/lib/cucumber/multiline_argument/data_table.rb @@ -284,7 +284,7 @@ def map_headers(mappings = {}, &block) # end # end # - # rubocop:disable Style/OptionalBooleanParameter + # rubocop:disable Style/OptionalBooleanParameter # the optional boolean parameter is kept for retrocompatibility def map_column!(column_name, strict = true, &conversion_proc) # TODO: Remove this method for 2.0 @conversion_procs[column_name.to_s] = { strict: strict, proc: conversion_proc } @@ -292,8 +292,8 @@ def map_column!(column_name, strict = true, &conversion_proc) end # rubocop:enable Style/OptionalBooleanParameter - # rubocop:disable Style/OptionalBooleanParameter # Returns a new Table with an additional column mapping. See #map_column! + # rubocop:disable Style/OptionalBooleanParameter # the optional boolean parameter is kept for retrocompatibility def map_column(column_name, strict = true, &conversion_proc) conversion_procs = @conversion_procs.dup conversion_procs[column_name.to_s] = { strict: strict, proc: conversion_proc } diff --git a/spec/cucumber/formatter/http_io_spec.rb b/spec/cucumber/formatter/http_io_spec.rb index 29eb617fcc..c58aeac664 100644 --- a/spec/cucumber/formatter/http_io_spec.rb +++ b/spec/cucumber/formatter/http_io_spec.rb @@ -127,11 +127,9 @@ class DummyFormatter def initialize(config = nil); end - # rubocop:disable Lint/UselessMethodDefinition - def ensure_io(path_or_url_or_io, error_stream) - super + def io(path_or_url_or_io, error_stream) + ensure_io(path_or_url_or_io, error_stream) end - # rubocop:enable Lint/UselessMethodDefinition end class DummyReporter @@ -144,14 +142,14 @@ def report(banner); end context 'created by Io#ensure_io' do it 'returns a IOHTTPBuffer' do url = start_server - io = DummyFormatter.new.ensure_io("#{url}/s3 -X PUT", nil) + io = DummyFormatter.new.io("#{url}/s3 -X PUT", nil) expect(io).to be_a(Cucumber::Formatter::IOHTTPBuffer) io.close # Close during the test so the request is done while server still runs end it 'uses CurlOptionParser to pass correct options to IOHTTPBuffer' do url = start_server - io = DummyFormatter.new.ensure_io("#{url}/s3 -X GET -H 'Content-Type: text/json'", nil) + io = DummyFormatter.new.io("#{url}/s3 -X GET -H 'Content-Type: text/json'", nil) expect(io.uri).to eq(URI("#{url}/s3")) expect(io.method).to eq('GET') diff --git a/spec/cucumber/glue/registry_and_more_spec.rb b/spec/cucumber/glue/registry_and_more_spec.rb index d963c258fa..daceadb14a 100644 --- a/spec/cucumber/glue/registry_and_more_spec.rb +++ b/spec/cucumber/glue/registry_and_more_spec.rb @@ -145,7 +145,7 @@ def a_file_called(name) rescue Glue::NilWorld => e expect(e.message).to eq 'World procs should never return nil' expect(e.backtrace.length).to eq 1 - expect(e.backtrace[0]).to match(/spec\/cucumber\/glue\/registry_and_more_spec\.rb:\d+:in `World'/) # rubocop:disable Style/RegexpLiteral + expect(e.backtrace[0]).to match(%r{spec/cucumber/glue/registry_and_more_spec\.rb:\d+:in `World'}) end end @@ -172,9 +172,9 @@ class << registry.current_world or http://wiki.github.com/cucumber/cucumber/a-whole-new-world. ) - dsl.World { Hash.new } # rubocop:disable Style/EmptyLiteral + dsl.World { {} } - expect(-> { dsl.World { Array.new } }).to raise_error(Glue::MultipleWorld, /#{expected_error}/) # rubocop:disable Style/EmptyLiteral + expect(-> { dsl.World { [] } }).to raise_error(Glue::MultipleWorld, /#{expected_error}/) end end From a453bcc588b9c9d06f0776a1c726aff13f1dcc96 Mon Sep 17 00:00:00 2001 From: aurelien-reeves Date: Wed, 3 Nov 2021 10:47:26 +0100 Subject: [PATCH 19/38] Bump rubotop to 1.4 --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 55af4e1f02..a847a7aa2f 100644 --- a/Gemfile +++ b/Gemfile @@ -21,5 +21,5 @@ gem 'cucumber-gherkin', path: ENV['GHERKIN_RUBY'] if ENV['GHERKIN_RUBY'] gem 'cucumber-html-formatter', path: ENV['CUCUMBER_HTML_FORMATTER_RUBY'] if ENV['CUCUMBER_HTML_FORMATTER_RUBY'] gem 'cucumber-messages', path: ENV['CUCUMBER_MESSAGES_RUBY'] if ENV['CUCUMBER_MESSAGES_RUBY'] -gem 'rubocop', '~> 1.1', '= 1.1.0' +gem 'rubocop', '~> 1.4', '= 1.4.2' gem 'rubocop-packaging', '~> 0.3', '= 0.5.1' From 81007561f0616fbd3b6bb3829f44d5b4c445ab0b Mon Sep 17 00:00:00 2001 From: aurelien-reeves Date: Wed, 3 Nov 2021 10:48:38 +0100 Subject: [PATCH 20/38] Fix Cucumber::Undefined Style/RaiseArgs error --- lib/cucumber/errors.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cucumber/errors.rb b/lib/cucumber/errors.rb index 1d2e3120bb..98ff565e36 100644 --- a/lib/cucumber/errors.rb +++ b/lib/cucumber/errors.rb @@ -9,7 +9,7 @@ def self.from(result, step_name) return result.with_message(with_prefix(result.message)) if result.is_a?(self) begin - raise new(with_prefix(step_name)) # rubocop:disable Style/RaiseArgs + raise self, with_prefix(step_name) rescue StandardError => e e end From 06ab3e409139dec2c6bf0f93448308ecc6c8a4f3 Mon Sep 17 00:00:00 2001 From: aurelien-reeves Date: Wed, 3 Nov 2021 11:06:38 +0100 Subject: [PATCH 21/38] Bump rubocop to 1.10.0 --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index a847a7aa2f..ab7d724d33 100644 --- a/Gemfile +++ b/Gemfile @@ -21,5 +21,5 @@ gem 'cucumber-gherkin', path: ENV['GHERKIN_RUBY'] if ENV['GHERKIN_RUBY'] gem 'cucumber-html-formatter', path: ENV['CUCUMBER_HTML_FORMATTER_RUBY'] if ENV['CUCUMBER_HTML_FORMATTER_RUBY'] gem 'cucumber-messages', path: ENV['CUCUMBER_MESSAGES_RUBY'] if ENV['CUCUMBER_MESSAGES_RUBY'] -gem 'rubocop', '~> 1.4', '= 1.4.2' +gem 'rubocop', '~> 1.10', '= 1.10.0' gem 'rubocop-packaging', '~> 0.3', '= 0.5.1' From a41017f5455f696c56049af9958dd8f780df5691 Mon Sep 17 00:00:00 2001 From: aurelien-reeves Date: Wed, 3 Nov 2021 11:07:25 +0100 Subject: [PATCH 22/38] Fix offense with regexp --- lib/cucumber/formatter/console.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/cucumber/formatter/console.rb b/lib/cucumber/formatter/console.rb index 64145157bb..51e0bb38e5 100644 --- a/lib/cucumber/formatter/console.rb +++ b/lib/cucumber/formatter/console.rb @@ -109,7 +109,10 @@ def exception_message_string(e, indent_amount) # http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/10655 def linebreaks(msg, max) return msg unless max && max > 0 - msg.gsub(/.{1,#{max}}(?:\s|\Z)/) { ($& + 5.chr).gsub(/\n\005/, "\n").gsub(/\005/, "\n") }.rstrip + + msg.gsub(/.{1,#{max}}(?:\s|\Z)/) do + (Regexp.last_match(0) + 5.chr).gsub(/\n\005/, "\n").gsub(/\005/, "\n") + end.rstrip end def collect_snippet_data(test_step, ast_lookup) From 201fbb321ec062403c841912c631e30b544a2e16 Mon Sep 17 00:00:00 2001 From: aurelien-reeves Date: Wed, 3 Nov 2021 11:07:55 +0100 Subject: [PATCH 23/38] Disable Metrics/ParameterLists with Cucumber::Cli::Main#initialize --- lib/cucumber/cli/main.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/cucumber/cli/main.rb b/lib/cucumber/cli/main.rb index 6e2d998d44..be59d029c6 100644 --- a/lib/cucumber/cli/main.rb +++ b/lib/cucumber/cli/main.rb @@ -14,7 +14,12 @@ def execute(args) end end - def initialize(args, _ = nil, out = $stdout, err = $stderr, kernel = Kernel) + # The second argument is there for retrocompatibility + # Removing it will require a breaking change + # But it is actually responsible for a rubycop offense: too many optional parameters + # As we don't want to deactivate that cop globally, we disable it just for the + # following. + def initialize(args, _ = nil, out = $stdout, err = $stderr, kernel = Kernel) # rubocop:disable Metrics/ParameterLists @args = args @out = out @err = err From 8d5e4bcada7887b1813be765b126d564954378f4 Mon Sep 17 00:00:00 2001 From: aurelien-reeves Date: Wed, 3 Nov 2021 11:09:14 +0100 Subject: [PATCH 24/38] Bump rubocop to 1.18.4 --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index ab7d724d33..3c6ae5662e 100644 --- a/Gemfile +++ b/Gemfile @@ -21,5 +21,5 @@ gem 'cucumber-gherkin', path: ENV['GHERKIN_RUBY'] if ENV['GHERKIN_RUBY'] gem 'cucumber-html-formatter', path: ENV['CUCUMBER_HTML_FORMATTER_RUBY'] if ENV['CUCUMBER_HTML_FORMATTER_RUBY'] gem 'cucumber-messages', path: ENV['CUCUMBER_MESSAGES_RUBY'] if ENV['CUCUMBER_MESSAGES_RUBY'] -gem 'rubocop', '~> 1.10', '= 1.10.0' +gem 'rubocop', '~> 1.18', '= 1.18.4' gem 'rubocop-packaging', '~> 0.3', '= 0.5.1' From 98974678d5b862eb482c91fe11ad52c974804bd7 Mon Sep 17 00:00:00 2001 From: aurelien-reeves Date: Wed, 3 Nov 2021 14:20:32 +0100 Subject: [PATCH 25/38] Bump rubocop to 1.19.1 --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 3c6ae5662e..d68e828226 100644 --- a/Gemfile +++ b/Gemfile @@ -21,5 +21,5 @@ gem 'cucumber-gherkin', path: ENV['GHERKIN_RUBY'] if ENV['GHERKIN_RUBY'] gem 'cucumber-html-formatter', path: ENV['CUCUMBER_HTML_FORMATTER_RUBY'] if ENV['CUCUMBER_HTML_FORMATTER_RUBY'] gem 'cucumber-messages', path: ENV['CUCUMBER_MESSAGES_RUBY'] if ENV['CUCUMBER_MESSAGES_RUBY'] -gem 'rubocop', '~> 1.18', '= 1.18.4' +gem 'rubocop', '~> 1.19', '= 1.19.1' gem 'rubocop-packaging', '~> 0.3', '= 0.5.1' From 31d68479b661a2426a1cc0b0a5b030691fae5373 Mon Sep 17 00:00:00 2001 From: aurelien-reeves Date: Wed, 3 Nov 2021 14:20:44 +0100 Subject: [PATCH 26/38] Fix offenses --- lib/cucumber/constantize.rb | 2 +- lib/cucumber/file_specs.rb | 2 +- lib/cucumber/formatter/ansicolor.rb | 4 +- lib/cucumber/glue/registry_and_more.rb | 2 +- lib/cucumber/multiline_argument/data_table.rb | 54 +++++++++---------- .../data_table/diff_matrices.rb | 2 +- lib/cucumber/rake/task.rb | 14 ++--- lib/cucumber/rspec/disable_option_parser.rb | 6 +-- lib/cucumber/runtime.rb | 12 ++--- lib/cucumber/step_match.rb | 6 +-- lib/cucumber/step_match_search.rb | 4 +- 11 files changed, 54 insertions(+), 54 deletions(-) diff --git a/lib/cucumber/constantize.rb b/lib/cucumber/constantize.rb index e5c3710cf5..dadc77e8b4 100644 --- a/lib/cucumber/constantize.rb +++ b/lib/cucumber/constantize.rb @@ -2,7 +2,7 @@ require 'cucumber/platform' module Cucumber - module Constantize #:nodoc: + module Constantize # :nodoc: def constantize(camel_cased_word) try = 0 begin diff --git a/lib/cucumber/file_specs.rb b/lib/cucumber/file_specs.rb index ab17d2cf2c..ff89602819 100644 --- a/lib/cucumber/file_specs.rb +++ b/lib/cucumber/file_specs.rb @@ -5,7 +5,7 @@ module Cucumber class FileSpecs - FILE_COLON_LINE_PATTERN = /^([\w\W]*?)(?::([\d:]+))?$/ #:nodoc: + FILE_COLON_LINE_PATTERN = /^([\w\W]*?)(?::([\d:]+))?$/ # :nodoc: def initialize(file_specs) Cucumber.logger.debug("Features:\n") diff --git a/lib/cucumber/formatter/ansicolor.rb b/lib/cucumber/formatter/ansicolor.rb index 6e6941fb29..6faa959d41 100644 --- a/lib/cucumber/formatter/ansicolor.rb +++ b/lib/cucumber/formatter/ansicolor.rb @@ -93,7 +93,7 @@ def #{method_name}_param(string=nil, &proc) eval(code) # rubocop:disable Security/Eval end - def self.define_grey #:nodoc: + def self.define_grey # :nodoc: gem 'genki-ruby-terminfo' require 'terminfo' case TermInfo.default_object.tigetnum('colors') @@ -121,7 +121,7 @@ def self.define_grey #:nodoc: # rubocop:enable Style/ClassEqualityComparison end - def self.define_real_grey #:nodoc: + def self.define_real_grey # :nodoc: define_method :grey do |string| ::Cucumber::Term::ANSIColor.coloring? ? "\e[90m#{string}\e[0m" : string end diff --git a/lib/cucumber/glue/registry_and_more.rb b/lib/cucumber/glue/registry_and_more.rb index 136ebb608c..5e0b5c41b5 100644 --- a/lib/cucumber/glue/registry_and_more.rb +++ b/lib/cucumber/glue/registry_and_more.rb @@ -170,7 +170,7 @@ def clear_hooks @hooks = nil end - def hooks_for(phase, scenario) #:nodoc: + def hooks_for(phase, scenario) # :nodoc: hooks[phase.to_sym].select { |hook| scenario.accept_hook?(hook) } end diff --git a/lib/cucumber/multiline_argument/data_table.rb b/lib/cucumber/multiline_argument/data_table.rb index 730f4eb0a2..f28bf988b1 100644 --- a/lib/cucumber/multiline_argument/data_table.rb +++ b/lib/cucumber/multiline_argument/data_table.rb @@ -27,7 +27,7 @@ module MultilineArgument # This will store [['a', 'b'], ['c', 'd']] in the data variable. # class DataTable - def self.default_arg_name #:nodoc: + def self.default_arg_name # :nodoc: 'table' end @@ -199,7 +199,7 @@ def raw end end - def column_names #:nodoc: + def column_names # :nodoc: @column_names ||= cell_matrix[0].map(&:value) end @@ -209,7 +209,7 @@ def rows end end - def each_cells_row(&proc) #:nodoc: + def each_cells_row(&proc) # :nodoc: cells_rows.each(&proc) end @@ -361,7 +361,7 @@ def to_hash cells_rows.map { |cells| cells.map(&:value) } end - def cells_to_hash(cells) #:nodoc: + def cells_to_hash(cells) # :nodoc: hash = Hash.new do |hash_inner, key| hash_inner[key.to_s] if key.is_a?(Symbol) end @@ -371,51 +371,51 @@ def cells_to_hash(cells) #:nodoc: hash end - def index(cells) #:nodoc: + def index(cells) # :nodoc: cells_rows.index(cells) end - def verify_column(column_name) #:nodoc: + def verify_column(column_name) # :nodoc: raise %(The column named "#{column_name}" does not exist) unless raw[0].include?(column_name) end - def verify_table_width(width) #:nodoc: + def verify_table_width(width) # :nodoc: raise %(The table must have exactly #{width} columns) unless raw[0].size == width end # TODO: remove the below function if it's not actually being used. # Nothing else in this repo calls it. - def text?(text) #:nodoc: + def text?(text) # :nodoc: raw.flatten.compact.detect { |cell_value| cell_value.index(text) } end - def cells_rows #:nodoc: + def cells_rows # :nodoc: @rows ||= cell_matrix.map do |cell_row| # rubocop:disable Naming/MemoizedInstanceVariableName Cells.new(self, cell_row) end end - def headers #:nodoc: + def headers # :nodoc: raw.first end - def header_cell(col) #:nodoc: + def header_cell(col) # :nodoc: cells_rows[0][col] end attr_reader :cell_matrix - def col_width(col) #:nodoc: + def col_width(col) # :nodoc: columns[col].__send__(:width) end - def to_s(options = {}) #:nodoc: + def to_s(options = {}) # :nodoc: indentation = options.key?(:indent) ? options[:indent] : 2 prefixes = options.key?(:prefixes) ? options[:prefixes] : TO_S_PREFIXES DataTablePrinter.new(self, indentation, prefixes).to_s end - class DataTablePrinter #:nodoc: + class DataTablePrinter # :nodoc: include Cucumber::Gherkin::Formatter::Escaping attr_reader :data_table, :indentation, :prefixes private :data_table, :indentation, :prefixes @@ -454,7 +454,7 @@ def format_cell(cell, col_width) end end - def columns #:nodoc: + def columns # :nodoc: @columns ||= cell_matrix.transpose.map do |cell_row| Cells.new(self, cell_row) end @@ -477,7 +477,7 @@ def build_hashes cells_rows[1..-1].map(&:to_hash) end - def create_cell_matrix(ast_table) #:nodoc: + def create_cell_matrix(ast_table) # :nodoc: ast_table.raw.map do |raw_row| line = begin raw_row.line @@ -490,7 +490,7 @@ def create_cell_matrix(ast_table) #:nodoc: end end - def convert_columns! #:nodoc: + def convert_columns! # :nodoc: @conversion_procs.each do |column_name, conversion_proc| verify_column(column_name) if conversion_proc[:strict] end @@ -504,7 +504,7 @@ def convert_columns! #:nodoc: end end - def convert_headers! #:nodoc: + def convert_headers! # :nodoc: header_cells = cell_matrix[0] if @header_conversion_proc @@ -521,11 +521,11 @@ def convert_headers! #:nodoc: end end - def clear_cache! #:nodoc: + def clear_cache! # :nodoc: @hashes = @rows_hash = @column_names = @rows = @columns = nil end - def ensure_table(table_or_array) #:nodoc: + def ensure_table(table_or_array) # :nodoc: return table_or_array if DataTable == table_or_array.class DataTable.from(table_or_array) end @@ -535,7 +535,7 @@ def symbolize_key(key) end # Represents a row of cells or columns of cells - class Cells #:nodoc: + class Cells # :nodoc: include Enumerable include Cucumber::Gherkin::Formatter::Escaping @@ -555,15 +555,15 @@ def accept(visitor) end # For testing only - def to_sexp #:nodoc: + def to_sexp # :nodoc: [:row, line, *@cells.map(&:to_sexp)] end - def to_hash #:nodoc: + def to_hash # :nodoc: @to_hash ||= @table.cells_to_hash(self) end - def value(n) #:nodoc: + def value(n) # :nodoc: self[n].value end @@ -594,7 +594,7 @@ def width end end - class Cell #:nodoc: + class Cell # :nodoc: attr_reader :line, :table attr_accessor :status, :value @@ -621,12 +621,12 @@ def hash end # For testing only - def to_sexp #:nodoc: + def to_sexp # :nodoc: [:cell, @value] end end - class SurplusCell < Cell #:nodoc: + class SurplusCell < Cell # :nodoc: def status :comment end diff --git a/lib/cucumber/multiline_argument/data_table/diff_matrices.rb b/lib/cucumber/multiline_argument/data_table/diff_matrices.rb index ba69f554cd..3c2c911529 100644 --- a/lib/cucumber/multiline_argument/data_table/diff_matrices.rb +++ b/lib/cucumber/multiline_argument/data_table/diff_matrices.rb @@ -1,7 +1,7 @@ module Cucumber module MultilineArgument class DataTable - class DiffMatrices #:nodoc: + class DiffMatrices # :nodoc: attr_accessor :cell_matrix, :other_table_cell_matrix, :options def initialize(cell_matrix, other_table_cell_matrix, options) diff --git a/lib/cucumber/rake/task.rb b/lib/cucumber/rake/task.rb index eb4124039d..16f142f305 100644 --- a/lib/cucumber/rake/task.rb +++ b/lib/cucumber/rake/task.rb @@ -30,7 +30,7 @@ class Task include Cucumber::Gherkin::Formatter::AnsiEscapes include ::Rake::DSL if defined?(::Rake::DSL) - class InProcessCucumberRunner #:nodoc: + class InProcessCucumberRunner # :nodoc: include ::Rake::DSL if defined?(::Rake::DSL) attr_reader :args @@ -51,7 +51,7 @@ def run end end - class ForkedCucumberRunner #:nodoc: + class ForkedCucumberRunner # :nodoc: include ::Rake::DSL if defined?(::Rake::DSL) def initialize(libs, cucumber_bin, cucumber_opts, bundler, feature_files) @@ -111,7 +111,7 @@ def run # It's recommended to pass an Array, but if it's a String it will be #split by ' '. attr_reader :cucumber_opts - def cucumber_opts=(opts) #:nodoc: + def cucumber_opts=(opts) # :nodoc: @cucumber_opts = String == opts.class ? opts.split(' ') : opts end @@ -146,24 +146,24 @@ def initialize(task_name = 'cucumber', desc = 'Run Cucumber features') define_task end - def define_task #:nodoc: + def define_task # :nodoc: desc @desc task @task_name do runner.run end end - def runner(_task_args = nil) #:nodoc: + def runner(_task_args = nil) # :nodoc: cucumber_opts = [(ENV['CUCUMBER_OPTS'] ? ENV['CUCUMBER_OPTS'].split(/\s+/) : nil) || cucumber_opts_with_profile] return ForkedCucumberRunner.new(libs, binary, cucumber_opts, bundler, feature_files) if fork InProcessCucumberRunner.new(libs, cucumber_opts, feature_files) end - def cucumber_opts_with_profile #:nodoc: + def cucumber_opts_with_profile # :nodoc: Array(cucumber_opts).concat(Array(@profile).flat_map { |p| ['--profile', p] }) end - def feature_files #:nodoc: + def feature_files # :nodoc: make_command_line_safe(FileList[ENV['FEATURE'] || []]) end diff --git a/lib/cucumber/rspec/disable_option_parser.rb b/lib/cucumber/rspec/disable_option_parser.rb index fcf05b6a98..b109cae26e 100644 --- a/lib/cucumber/rspec/disable_option_parser.rb +++ b/lib/cucumber/rspec/disable_option_parser.rb @@ -2,12 +2,12 @@ require 'optparse' -module Spec #:nodoc: - module Runner #:nodoc: +module Spec # :nodoc: + module Runner # :nodoc: # Neuters RSpec's option parser. # (RSpec's option parser tries to parse ARGV, which # will fail when running cucumber) - class OptionParser < ::OptionParser #:nodoc: + class OptionParser < ::OptionParser # :nodoc: NEUTERED_RSPEC = Object.new def NEUTERED_RSPEC.method_missing(_method, *_args) # rubocop:disable Style/MissingRespondToMissing self || super diff --git a/lib/cucumber/runtime.rb b/lib/cucumber/runtime.rb index aaa87ced5e..8d3268c9d2 100644 --- a/lib/cucumber/runtime.rb +++ b/lib/cucumber/runtime.rb @@ -115,19 +115,19 @@ def doc_string(string_without_triple_quotes, content_type = '', _line_offset = 0 private - def fire_after_configuration_hook #:nodoc: + def fire_after_configuration_hook # :nodoc: @support_code.fire_hook(:after_configuration, @configuration) end - def fire_install_plugin_hook #:nodoc: + def fire_install_plugin_hook # :nodoc: @support_code.fire_hook(:install_plugin, @configuration, registry_wrapper) end - def fire_before_all_hook #:nodoc: + def fire_before_all_hook # :nodoc: @support_code.fire_hook(:before_all) end - def fire_after_all_hook #:nodoc: + def fire_after_all_hook # :nodoc: @support_code.fire_hook(:after_all) end @@ -149,8 +149,8 @@ def filespecs end class NormalisedEncodingFile - COMMENT_OR_EMPTY_LINE_PATTERN = /^\s*#|^\s*$/ #:nodoc: - ENCODING_PATTERN = /^\s*#\s*encoding\s*:\s*([^\s]+)/ #:nodoc: + COMMENT_OR_EMPTY_LINE_PATTERN = /^\s*#|^\s*$/ # :nodoc: + ENCODING_PATTERN = /^\s*#\s*encoding\s*:\s*([^\s]+)/ # :nodoc: def self.read(path) new(path).read diff --git a/lib/cucumber/step_match.rb b/lib/cucumber/step_match.rb index 1df453ca85..ae1c282568 100644 --- a/lib/cucumber/step_match.rb +++ b/lib/cucumber/step_match.rb @@ -4,7 +4,7 @@ module Cucumber # Represents the match found between a Test Step and its activation - class StepMatch #:nodoc: + class StepMatch # :nodoc: attr_reader :step_definition, :step_arguments def initialize(step_definition, step_name, step_arguments) @@ -90,7 +90,7 @@ def replace_arguments(string, step_arguments, format) s end - def inspect #:nodoc: + def inspect # :nodoc: "#<#{self.class}: #{location}>" end end @@ -101,7 +101,7 @@ def activate(test_step) end end - class NoStepMatch #:nodoc: + class NoStepMatch # :nodoc: attr_reader :step_definition, :name def initialize(step, name) diff --git a/lib/cucumber/step_match_search.rb b/lib/cucumber/step_match_search.rb index b5249663b5..e3f4c791c4 100644 --- a/lib/cucumber/step_match_search.rb +++ b/lib/cucumber/step_match_search.rb @@ -35,7 +35,7 @@ def call(step_name) private - def best_matches(_step_name, step_matches) #:nodoc: + def best_matches(_step_name, step_matches) # :nodoc: no_groups = step_matches.select { |step_match| step_match.args.empty? } max_arg_length = step_matches.map { |step_match| step_match.args.length }.max top_groups = step_matches.select { |step_match| step_match.args.length == max_arg_length } @@ -54,7 +54,7 @@ def best_matches(_step_name, step_matches) #:nodoc: require 'delegate' class CachesStepMatch < SimpleDelegator - def call(step_name) #:nodoc: + def call(step_name) # :nodoc: @match_cache ||= {} matches = @match_cache[step_name] From 07a33770bd28753b317b83452c8f571b09b002ee Mon Sep 17 00:00:00 2001 From: aurelien-reeves Date: Wed, 3 Nov 2021 14:22:09 +0100 Subject: [PATCH 27/38] Bump rubocop to v1.22.3 --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index d68e828226..2845735aee 100644 --- a/Gemfile +++ b/Gemfile @@ -21,5 +21,5 @@ gem 'cucumber-gherkin', path: ENV['GHERKIN_RUBY'] if ENV['GHERKIN_RUBY'] gem 'cucumber-html-formatter', path: ENV['CUCUMBER_HTML_FORMATTER_RUBY'] if ENV['CUCUMBER_HTML_FORMATTER_RUBY'] gem 'cucumber-messages', path: ENV['CUCUMBER_MESSAGES_RUBY'] if ENV['CUCUMBER_MESSAGES_RUBY'] -gem 'rubocop', '~> 1.19', '= 1.19.1' +gem 'rubocop', '~> 1.22', '= 1.22.3' gem 'rubocop-packaging', '~> 0.3', '= 0.5.1' From 67d4baefd4bdcf891894676f7b88198942db6d83 Mon Sep 17 00:00:00 2001 From: aurelien-reeves Date: Thu, 4 Nov 2021 10:40:22 +0100 Subject: [PATCH 28/38] Remove exclusion of Bundler/DuplicatedGem --- .rubocop.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index bee272f029..72776c469b 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -23,13 +23,6 @@ AllCops: - 'temp_app/**/*' - 'cck/features/**/*' -# Reviewed: we need to specify 'cucumber-core' and 'cucumber-wire' twice -# to be able to build using git on CI, but also using local repos locally. -Bundler/DuplicatedGem: - Exclude: - - 'Gemfile' - - 'cck/Gemfile' - # Disabling for appveyor Layout/EndOfLine: Enabled: false From 80fe5497ab1cbd06428ee7a8e371ee51f1a80ab7 Mon Sep 17 00:00:00 2001 From: aurelien-reeves Date: Thu, 4 Nov 2021 10:41:31 +0100 Subject: [PATCH 29/38] Enable Layout/EndOfLine: we don't use Appveyor anymore --- .rubocop.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 72776c469b..0b3162eb20 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -23,10 +23,6 @@ AllCops: - 'temp_app/**/*' - 'cck/features/**/*' -# Disabling for appveyor -Layout/EndOfLine: - Enabled: false - # Disabling this cop until the minimum Ruby version is >= 2.3 as squiggly # heredocs '<<~' were introduced then. The files below are the current ones # with offenses From d8b4c16c39dedcaf533fb65449d2bdca60fb5cf3 Mon Sep 17 00:00:00 2001 From: aurelien-reeves Date: Thu, 4 Nov 2021 10:45:01 +0100 Subject: [PATCH 30/38] Enable Layout/EmptyLineAfterGuardClause --- .rubocop_todo.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 7535ea7b52..12164da3b9 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -6,11 +6,6 @@ # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 99 -# Cop supports --auto-correct. -Layout/EmptyLineAfterGuardClause: - Enabled: false - # Offense count: 38 # Cop supports --auto-correct. # Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. From 4c3abc57845cf9a4f9e3942cc43bce9c6466f331 Mon Sep 17 00:00:00 2001 From: aurelien-reeves Date: Thu, 4 Nov 2021 10:45:15 +0100 Subject: [PATCH 31/38] Autocorrect Layout/EmptyLineAfterGuardClause --- examples/i18n/Rakefile | 2 ++ features/lib/support/json.rb | 3 +++ features/lib/support/output.rb | 1 + gem_tasks/examples.rake | 1 + lib/autotest/cucumber_mixin.rb | 3 +++ lib/cucumber.rb | 1 + lib/cucumber/cli/configuration.rb | 1 + lib/cucumber/cli/main.rb | 1 + lib/cucumber/cli/options.rb | 6 ++++++ lib/cucumber/configuration.rb | 1 + lib/cucumber/deprecate.rb | 1 + lib/cucumber/file_specs.rb | 1 + lib/cucumber/filters/activate_steps.rb | 1 + lib/cucumber/formatter/ansicolor.rb | 1 + lib/cucumber/formatter/ast_lookup.rb | 1 + lib/cucumber/formatter/console.rb | 4 ++++ lib/cucumber/formatter/console_issues.rb | 3 +++ lib/cucumber/formatter/http_io.rb | 5 +++++ lib/cucumber/formatter/io.rb | 2 ++ lib/cucumber/formatter/json.rb | 2 ++ lib/cucumber/formatter/junit.rb | 2 ++ lib/cucumber/formatter/pretty.rb | 12 ++++++++++++ lib/cucumber/formatter/progress.rb | 1 + lib/cucumber/formatter/query/hook_by_test_step.rb | 1 + .../query/test_case_started_by_test_case.rb | 2 ++ lib/cucumber/formatter/rerun.rb | 2 ++ lib/cucumber/formatter/summary.rb | 1 + lib/cucumber/gherkin/data_table_parser.rb | 1 + lib/cucumber/glue/hook.rb | 1 + lib/cucumber/glue/invoke_in_world.rb | 1 + lib/cucumber/glue/registry_and_more.rb | 2 ++ lib/cucumber/glue/step_definition.rb | 5 +++++ lib/cucumber/hooks.rb | 1 + lib/cucumber/multiline_argument/data_table.rb | 5 +++++ .../multiline_argument/data_table/diff_matrices.rb | 1 + lib/cucumber/rake/task.rb | 2 ++ lib/cucumber/running_test_case.rb | 1 + lib/cucumber/runtime.rb | 3 +++ lib/cucumber/runtime/support_code.rb | 3 +++ lib/cucumber/runtime/user_interface.rb | 1 + lib/cucumber/step_match.rb | 2 ++ lib/cucumber/step_match_search.rb | 1 + lib/cucumber/term/ansicolor.rb | 1 + lib/cucumber/term/banner.rb | 1 + scripts/update-changelog | 1 + spec/cucumber/formatter/json_spec.rb | 2 ++ spec/cucumber/formatter/spec_helper.rb | 1 + 47 files changed, 98 insertions(+) diff --git a/examples/i18n/Rakefile b/examples/i18n/Rakefile index 8b4a9c90c9..7622a57d8e 100644 --- a/examples/i18n/Rakefile +++ b/examples/i18n/Rakefile @@ -3,6 +3,7 @@ task :cucumber do dir = File.dirname(__FILE__) Dir["#{dir}/*"].sort.each do |f| next unless File.directory?(f) + lang = f[dir.length + 1..-1] message = examples_disabled?(lang) unless message.nil? @@ -26,6 +27,7 @@ end def jruby_disabled_examples?(lang) return unless RUBY_PLATFORM == 'java' + %w[ru uk uz].include?(lang) end diff --git a/features/lib/support/json.rb b/features/lib/support/json.rb index cc0b071004..0f46af75cb 100644 --- a/features/lib/support/json.rb +++ b/features/lib/support/json.rb @@ -8,9 +8,11 @@ def normalise_json(json) scenario['steps']&.each do |_step| %w[steps before after].each do |type| next unless scenario[type] + scenario[type].each do |step_or_hook| normalise_json_step_or_hook(step_or_hook) next unless step_or_hook['after'] + step_or_hook['after'].each do |hook| normalise_json_step_or_hook(hook) end @@ -30,6 +32,7 @@ def normalise_json_step_or_hook(step_or_hook) end return unless step_or_hook['result'] && step_or_hook['result']['duration'] + expect(step_or_hook['result']['duration']).to be >= 0 step_or_hook['result']['duration'] = 1 end diff --git a/features/lib/support/output.rb b/features/lib/support/output.rb index f0e57c90e5..8b4b9e1b83 100644 --- a/features/lib/support/output.rb +++ b/features/lib/support/output.rb @@ -3,6 +3,7 @@ def clean_output(output) output.split("\n").map do |line| next if line.include?(CUCUMBER_FEATURES_PATH) + line .gsub(/\e\[([;\d]+)?m/, '') # Drop colors .gsub(/^.*cucumber_process\.rb.*$\n/, '') diff --git a/gem_tasks/examples.rake b/gem_tasks/examples.rake index c7202e0c30..1b1792b213 100644 --- a/gem_tasks/examples.rake +++ b/gem_tasks/examples.rake @@ -8,6 +8,7 @@ task :examples do puts "Running #{example_dir}" Dir.chdir(example_dir) do raise "No Rakefile in #{Dir.pwd}" unless File.file?('Rakefile') + sh 'rake cucumber' end end diff --git a/lib/autotest/cucumber_mixin.rb b/lib/autotest/cucumber_mixin.rb index fe62193df1..9ab45e05d6 100644 --- a/lib/autotest/cucumber_mixin.rb +++ b/lib/autotest/cucumber_mixin.rb @@ -37,6 +37,7 @@ def run reset_features rescue Interrupt break if wants_to_quit + reset reset_features end @@ -70,6 +71,7 @@ def run_features Tempfile.open('autotest-cucumber') do |dirty_features_file| cmd = make_cucumber_cmd(features_to_run, dirty_features_file.path) break if cmd.empty? + old_sync = $stdout.sync $stdout.sync = true self.results = [] @@ -81,6 +83,7 @@ def run_features print(c) line << c next unless c == "\n" + results << line.join line.clear end diff --git a/lib/cucumber.rb b/lib/cucumber.rb index 7c4258b252..aa8644e957 100644 --- a/lib/cucumber.rb +++ b/lib/cucumber.rb @@ -14,6 +14,7 @@ class << self def logger return @log if @log + @log = Logger.new($stdout) @log.level = Logger::INFO @log diff --git a/lib/cucumber/cli/configuration.rb b/lib/cucumber/cli/configuration.rb index 6800429d31..8567cdee5a 100644 --- a/lib/cucumber/cli/configuration.rb +++ b/lib/cucumber/cli/configuration.rb @@ -30,6 +30,7 @@ def parse!(args) @options.parse!(args) arrange_formats raise("You can't use both --strict and --wip") if strict.strict? && wip? + set_environment_variables end diff --git a/lib/cucumber/cli/main.rb b/lib/cucumber/cli/main.rb index be59d029c6..a3613cfce9 100644 --- a/lib/cucumber/cli/main.rb +++ b/lib/cucumber/cli/main.rb @@ -97,6 +97,7 @@ def trap_interrupt def runtime(existing_runtime) return Runtime.new(configuration) unless existing_runtime + existing_runtime.configure(configuration) existing_runtime end diff --git a/lib/cucumber/cli/options.rb b/lib/cucumber/cli/options.rb index fd14ab170b..161de23c7f 100644 --- a/lib/cucumber/cli/options.rb +++ b/lib/cucumber/cli/options.rb @@ -180,6 +180,7 @@ def filters def check_formatter_stream_conflicts streams = @options[:formats].uniq.map { |(_, _, stream)| stream } return if streams == streams.uniq + raise 'All but one formatter must use --out, only one can print to each stream (or STDOUT)' end @@ -203,6 +204,7 @@ def process_publish_options def truthy_string?(str) return false if str.nil? + str !~ /^(false|no|0)$/i end @@ -367,6 +369,7 @@ def banner def require_files(v) @options[:require] << v return unless Cucumber::JRUBY && File.directory?(v) + require 'java' $CLASSPATH << v end @@ -385,6 +388,7 @@ def language(lang) require 'gherkin/dialect' return indicate_invalid_language_and_exit(lang) unless ::Gherkin::DIALECTS.key?(lang) + list_keywords_and_exit(lang) end @@ -403,6 +407,7 @@ def add_option(option, value) def add_tag(value) raise("Found tags option '#{value}'. '~@tag' is no longer supported, use 'not @tag' instead.") if value.include?('~') raise("Found tags option '#{value}'. '@tag1,@tag2' is no longer supported, use '@tag or @tag2' instead.") if value.include?(',') + @options[:tag_expressions] << value.gsub(/(@\w+)(:\d+)?/, '\1') add_tag_limits(value) end @@ -415,6 +420,7 @@ def add_tag_limits(value) def add_tag_limit(tag_limits, tag_name, limit) raise "Inconsistent tag limits for #{tag_name}: #{tag_limits[tag_name]} and #{limit}" if tag_limits[tag_name] && tag_limits[tag_name] != limit + tag_limits[tag_name] = limit end diff --git a/lib/cucumber/configuration.rb b/lib/cucumber/configuration.rb index cae5e46ef6..864c26ecf3 100644 --- a/lib/cucumber/configuration.rb +++ b/lib/cucumber/configuration.rb @@ -283,6 +283,7 @@ def default_features_paths def with_default_features_path(paths) return default_features_paths if paths.empty? + paths end diff --git a/lib/cucumber/deprecate.rb b/lib/cucumber/deprecate.rb index 488f7b05d4..4514190c88 100644 --- a/lib/cucumber/deprecate.rb +++ b/lib/cucumber/deprecate.rb @@ -20,6 +20,7 @@ def failure_message(message) class CliOption def self.deprecate(stream, option, message, remove_after_version) return if stream.nil? + stream.puts( AnsiString.failure_message( "\nWARNING: #{option} is deprecated" \ diff --git a/lib/cucumber/file_specs.rb b/lib/cucumber/file_specs.rb index ff89602819..8949f56ecd 100644 --- a/lib/cucumber/file_specs.rb +++ b/lib/cucumber/file_specs.rb @@ -32,6 +32,7 @@ def initialize(spec) def locations return [Core::Test::Location.new(@file)] if @lines.empty? + @lines.map { |line| Core::Test::Location.new(@file, line) } end end diff --git a/lib/cucumber/filters/activate_steps.rb b/lib/cucumber/filters/activate_steps.rb index 55ca30b180..16010e0398 100644 --- a/lib/cucumber/filters/activate_steps.rb +++ b/lib/cucumber/filters/activate_steps.rb @@ -52,6 +52,7 @@ def result end configuration.notify :step_activated, test_step, match return SkippingStepMatch.new if configuration.dry_run? + match end diff --git a/lib/cucumber/formatter/ansicolor.rb b/lib/cucumber/formatter/ansicolor.rb index 6faa959d41..2878c9b002 100644 --- a/lib/cucumber/formatter/ansicolor.rb +++ b/lib/cucumber/formatter/ansicolor.rb @@ -81,6 +81,7 @@ module ANSIColor # end ALIASES.each_key do |method_name| next if method_name =~ /.*_param/ + code = <<-COLOR def #{method_name}(string=nil, &proc) #{"#{ALIASES[method_name].split(',').join('(')}(string, &proc#{')' * ALIASES[method_name].split(',').length}"} diff --git a/lib/cucumber/formatter/ast_lookup.rb b/lib/cucumber/formatter/ast_lookup.rb index e24ca2410d..4a99622858 100644 --- a/lib/cucumber/formatter/ast_lookup.rb +++ b/lib/cucumber/formatter/ast_lookup.rb @@ -45,6 +45,7 @@ def snippet_step_keyword(test_step) break end break if node.previous_node.nil? + node = node.previous_node end keyword = dialect.given_keywords.reject { |kw| kw == '* ' }[0] if keyword.nil? diff --git a/lib/cucumber/formatter/console.rb b/lib/cucumber/formatter/console.rb index 51e0bb38e5..aa38979f49 100644 --- a/lib/cucumber/formatter/console.rb +++ b/lib/cucumber/formatter/console.rb @@ -153,6 +153,7 @@ def do_print_snippets(snippet_text_proc) def print_passing_wip(config, passed_test_cases, ast_lookup) return unless config.wip? + messages = passed_test_cases.map do |test_case| scenario_source = ast_lookup.scenario_source(test_case) keyword = scenario_source.type == :Scenario ? scenario_source.scenario.keyword : scenario_source.scenario_outline.keyword @@ -173,6 +174,7 @@ def do_print_passing_wip(passed_messages) def attach(src, media_type) return unless media_type == 'text/x.cucumber.log+plain' return unless @io + @io.puts @io.puts(format_string(src, :tag)) @io.flush @@ -180,6 +182,7 @@ def attach(src, media_type) def print_profile_information return if @options[:skip_profile_information] || @options[:profiles].nil? || @options[:profiles].empty? + do_print_profile_information(@options[:profiles]) end @@ -227,6 +230,7 @@ def format_for(*keys) key = keys.join('_').to_sym fmt = FORMATS[key] raise "No format for #{key.inspect}: #{FORMATS.inspect}" if fmt.nil? + fmt end diff --git a/lib/cucumber/formatter/console_issues.rb b/lib/cucumber/formatter/console_issues.rb index 2dc3b789bf..99ca3f1b89 100644 --- a/lib/cucumber/formatter/console_issues.rb +++ b/lib/cucumber/formatter/console_issues.rb @@ -23,6 +23,7 @@ def initialize(config, ast_lookup = AstLookup.new(config)) def to_s return if @issues.empty? + result = Core::Test::Result::TYPES.map { |type| scenario_listing(type, @issues[type]) } result.flatten.join("\n") end @@ -35,6 +36,7 @@ def any? def scenario_listing(type, test_cases) return [] if test_cases.empty? + [format_string("#{type_heading(type)} Scenarios:", type)] + test_cases.map do |test_case| scenario_source = @ast_lookup.scenario_source(test_case) keyword = scenario_source.type == :Scenario ? scenario_source.scenario.keyword : scenario_source.scenario_outline.keyword @@ -54,6 +56,7 @@ def type_heading(type) def profiles_string return if @config.custom_profiles.empty? + profiles = @config.custom_profiles.map { |profile| "-p #{profile}" }.join(' ') "#{profiles} " diff --git a/lib/cucumber/formatter/http_io.rb b/lib/cucumber/formatter/http_io.rb index 7866fd2153..89ce493a9e 100644 --- a/lib/cucumber/formatter/http_io.rb +++ b/lib/cucumber/formatter/http_io.rb @@ -35,6 +35,7 @@ def self.parse(options) headers = headers.merge(parse_header(header_arg)) else raise StandardError, "#{options} was not a valid curl command. Can't set url to #{arg} it is already set to #{url}" if url + url = arg end end @@ -49,12 +50,14 @@ def self.parse(options) def self.remove_arg_for(args, arg) return args.shift unless args.empty? + raise StandardError, "Missing argument for #{arg}" end def self.parse_header(header_arg) parts = header_arg.split(':', 2) raise StandardError, "#{header_arg} was not a valid header" unless parts.length == 2 + { parts[0].strip => parts[1].strip } end end @@ -76,6 +79,7 @@ def close @reporter.report(response.body) @write_io.close return if response.is_a?(Net::HTTPSuccess) || response.is_a?(Net::HTTPRedirection) + raise StandardError, "request to #{uri} failed with status #{response.code}" end @@ -98,6 +102,7 @@ def send_content(uri, method, headers, attempt = 10) http = build_client(uri, @https_verify_mode) raise StandardError, "request to #{uri} failed (too many redirections)" if attempt <= 0 + req = build_request( uri, method, diff --git a/lib/cucumber/formatter/io.rb b/lib/cucumber/formatter/io.rb index 87ee299088..f93ea0f746 100644 --- a/lib/cucumber/formatter/io.rb +++ b/lib/cucumber/formatter/io.rb @@ -64,12 +64,14 @@ def ensure_file(path, name) raise "You *must* specify --out FILE for the #{name} formatter" unless String == path.class raise "I can't write #{name} to a directory - it has to be a file" if File.directory?(path) raise "I can't write #{name} to a file in the non-existing directory #{File.dirname(path)}" unless File.directory?(File.dirname(path)) + ensure_io(path, nil) end def ensure_dir(path, name) raise "You *must* specify --out DIR for the #{name} formatter" unless String == path.class raise "I can't write #{name} reports to a file - it has to be a directory" if File.file?(path) + FileUtils.mkdir_p(path) unless File.directory?(path) File.absolute_path path end diff --git a/lib/cucumber/formatter/json.rb b/lib/cucumber/formatter/json.rb index 8d118f482e..fa13f14d94 100644 --- a/lib/cucumber/formatter/json.rb +++ b/lib/cucumber/formatter/json.rb @@ -68,6 +68,7 @@ def on_test_step_finished(event) test_step, result = *event.attributes result = result.with_filtered_backtrace(Cucumber::Formatter::BacktraceFilter) return if internal_hook?(test_step) + add_match_and_result(test_step, result) @any_step_failed = true if result.failed? end @@ -259,6 +260,7 @@ def feature(feature, uri) line: feature.location.line } return if feature.tags.empty? + @feature_hash[:tags] = create_tags_array_from_hash_array(feature.tags) end diff --git a/lib/cucumber/formatter/junit.rb b/lib/cucumber/formatter/junit.rb index 7fbef5b01f..f71f619bc6 100644 --- a/lib/cucumber/formatter/junit.rb +++ b/lib/cucumber/formatter/junit.rb @@ -84,6 +84,7 @@ def start_feature(test_case) uri = test_case.location.file feature = @ast_lookup.gherkin_document(uri).feature raise UnNamedFeatureError, uri if feature.name.empty? + @current_feature_data = @features_data[uri] @current_feature_data[:uri] = uri unless @current_feature_data[:uri] @current_feature_data[:feature] = feature unless @current_feature_data[:feature] @@ -111,6 +112,7 @@ def create_output_string(test_case, scenario, result, row_name) keyword = scenario_source.type == :Scenario ? scenario_source.scenario.keyword : scenario_source.scenario_outline.keyword output = "#{keyword}: #{scenario}\n\n" return output if result.ok?(@config.strict) + if scenario_source.type == :Scenario if @failing_test_step if @failing_test_step.hook? diff --git a/lib/cucumber/formatter/pretty.rb b/lib/cucumber/formatter/pretty.rb index 5bf63442f1..9b74374acb 100644 --- a/lib/cucumber/formatter/pretty.rb +++ b/lib/cucumber/formatter/pretty.rb @@ -103,16 +103,19 @@ def on_test_case_started(event) def on_test_step_started(event) return if event.test_step.hook? + print_step_header(current_test_case) if first_step_after_printing_background_steps?(event.test_step) end def on_test_step_finished(event) collect_snippet_data(event.test_step, @ast_lookup) if event.result.undefined? return if in_scenario_outline && !options[:expand] + exception_to_be_printed = find_exception_to_be_printed(event.result) print_step_data(event.test_step, event.result) if print_step_data?(event, exception_to_be_printed) print_step_output return unless exception_to_be_printed + print_exception(exception_to_be_printed, event.result.to_sym, 6) @exceptions << exception_to_be_printed end @@ -125,6 +128,7 @@ def on_test_case_finished(event) else exception_to_be_printed = find_exception_to_be_printed(event.result) return unless exception_to_be_printed + print_exception(exception_to_be_printed, event.result.to_sym, 6) @exceptions << exception_to_be_printed end @@ -138,6 +142,7 @@ def on_test_run_finished(_event) def attach(src, media_type) return unless media_type == 'text/x.cucumber.log+plain' + @test_step_output.push src end @@ -145,9 +150,11 @@ def attach(src, media_type) def find_exception_to_be_printed(result) return nil if result.ok?(options[:strict]) + result = result.with_filtered_backtrace(Cucumber::Formatter::BacktraceFilter) exception = result.failed? ? result.exception : result return nil if @exceptions.include?(exception) + exception end @@ -194,6 +201,7 @@ def same_feature_as_previous_test_case?(location) def feature_has_background? feature_children = gherkin_document.feature.children return false if feature_children.empty? + !feature_children.first.background.nil? end @@ -237,6 +245,7 @@ def from_scenario_outline?(test_case) def first_step_after_printing_background_steps?(test_step) return false unless print_background_steps return false unless test_step.location.lines.max >= current_test_case.location.lines.max + @print_background_steps = false true end @@ -260,6 +269,7 @@ def print_language_comment(feature_line) def print_comments(up_to_line, indent_amount) comments = gherkin_document.comments return if comments.empty? || comments.length <= @next_comment_to_be_printed + comments[@next_comment_to_be_printed..-1].each do |comment| if comment.location.line <= up_to_line @io.puts(indent(format_string(comment.text.strip, :comment), indent_amount)) @@ -292,6 +302,7 @@ def print_keyword_name(keyword, name, indent_amount, location = nil) def print_description(description) return unless description + description.split("\n").each do |line| @io.puts(line) end @@ -396,6 +407,7 @@ def print_outline_data(scenario_outline) # rubocop:disable Metrics/AbcSize end @io.puts next if options[:no_multiline] + print_doc_string(step.doc_string.content, :skipped, 6) unless step.doc_string.nil? print_data_table(step.data_table, :skipped, 6) unless step.data_table.nil? end diff --git a/lib/cucumber/formatter/progress.rb b/lib/cucumber/formatter/progress.rb index 7b306782da..16e17245d2 100644 --- a/lib/cucumber/formatter/progress.rb +++ b/lib/cucumber/formatter/progress.rb @@ -58,6 +58,7 @@ def on_test_step_finished(event) progress(result.to_sym) if !test_step.hook? || result.failed? return if test_step.hook? + collect_snippet_data(test_step, @ast_lookup) if result.undefined? @pending_step_matches << @matches[test_step.to_s] if result.pending? @failed_results << result if result.failed? diff --git a/lib/cucumber/formatter/query/hook_by_test_step.rb b/lib/cucumber/formatter/query/hook_by_test_step.rb index a5bc5cfc20..e36c6ea4f6 100644 --- a/lib/cucumber/formatter/query/hook_by_test_step.rb +++ b/lib/cucumber/formatter/query/hook_by_test_step.rb @@ -13,6 +13,7 @@ def initialize(config) def hook_id(test_step) return @hook_id_by_test_step_id[test_step.id] if @hook_id_by_test_step_id.key?(test_step.id) + raise TestStepUnknownError, "No hook found for #{test_step.id} }. Known: #{@hook_id_by_test_step_id.keys}" end diff --git a/lib/cucumber/formatter/query/test_case_started_by_test_case.rb b/lib/cucumber/formatter/query/test_case_started_by_test_case.rb index 836b2b4b5a..9604cac5e8 100644 --- a/lib/cucumber/formatter/query/test_case_started_by_test_case.rb +++ b/lib/cucumber/formatter/query/test_case_started_by_test_case.rb @@ -15,11 +15,13 @@ def initialize(config) def attempt_by_test_case(test_case) raise TestCaseUnknownError, "No test case found for #{test_case.id} }. Known: #{@attempts_by_test_case_id.keys}" unless @attempts_by_test_case_id.key?(test_case.id) + @attempts_by_test_case_id[test_case.id] end def test_case_started_id_by_test_case(test_case) raise TestCaseUnknownError, "No test case found for #{test_case.id} }. Known: #{@test_case_started_id_by_test_case_id.keys}" unless @test_case_started_id_by_test_case_id.key?(test_case.id) + @test_case_started_id_by_test_case_id[test_case.id] end diff --git a/lib/cucumber/formatter/rerun.rb b/lib/cucumber/formatter/rerun.rb index 8db387b7ba..7a22e6ff51 100644 --- a/lib/cucumber/formatter/rerun.rb +++ b/lib/cucumber/formatter/rerun.rb @@ -15,6 +15,7 @@ def initialize(config) test_case, result = *event.attributes if @config.strict.strict?(:flaky) next if result.ok?(@config.strict) + add_to_failures(test_case) else unless @latest_failed_test_case.nil? @@ -31,6 +32,7 @@ def initialize(config) config.on_event :test_run_finished do add_to_failures(@latest_failed_test_case) unless @latest_failed_test_case.nil? next if @failures.empty? + @io.print file_failures.join("\n") end end diff --git a/lib/cucumber/formatter/summary.rb b/lib/cucumber/formatter/summary.rb index b430982323..3202fb6406 100644 --- a/lib/cucumber/formatter/summary.rb +++ b/lib/cucumber/formatter/summary.rb @@ -47,6 +47,7 @@ def gherkin_document(uri) def print_feature(test_case) uri = test_case.location.file return if @current_feature_uri == uri + feature_name = gherkin_document(uri).feature.name @io.puts unless @current_feature_uri.nil? @io.puts feature_name diff --git a/lib/cucumber/gherkin/data_table_parser.rb b/lib/cucumber/gherkin/data_table_parser.rb index 5e6a12657d..7a6d3e164f 100644 --- a/lib/cucumber/gherkin/data_table_parser.rb +++ b/lib/cucumber/gherkin/data_table_parser.rb @@ -19,6 +19,7 @@ def parse(text) end return if gherkin_document.nil? + gherkin_document[:feature][:children][0][:scenario][:steps][0][:data_table][:rows].each do |row| @builder.row(row[:cells].map { |cell| cell[:value] }) end diff --git a/lib/cucumber/glue/hook.rb b/lib/cucumber/glue/hook.rb index b6c55846a3..6f8ed94750 100644 --- a/lib/cucumber/glue/hook.rb +++ b/lib/cucumber/glue/hook.rb @@ -58,6 +58,7 @@ def fail_for_old_style_tag_expressions(tag_expressions) 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 diff --git a/lib/cucumber/glue/invoke_in_world.rb b/lib/cucumber/glue/invoke_in_world.rb index 0da412c080..6982d9edf2 100644 --- a/lib/cucumber/glue/invoke_in_world.rb +++ b/lib/cucumber/glue/invoke_in_world.rb @@ -12,6 +12,7 @@ def self.replace_instance_exec_invocation_line!(backtrace, instance_exec_invocat instance_exec_pos = backtrace.index(instance_exec_invocation_line) return unless instance_exec_pos + replacement_line = instance_exec_pos + INSTANCE_EXEC_OFFSET backtrace[replacement_line].gsub!(/`.*'/, "`#{pseudo_method}'") if pseudo_method diff --git a/lib/cucumber/glue/registry_and_more.rb b/lib/cucumber/glue/registry_and_more.rb index 5e0b5c41b5..ea98d14f05 100644 --- a/lib/cucumber/glue/registry_and_more.rb +++ b/lib/cucumber/glue/registry_and_more.rb @@ -100,6 +100,7 @@ def register_rb_step_definition(string_or_regexp, proc_or_sym, options) def build_rb_world_factory(world_modules, namespaced_world_modules, proc) if proc raise MultipleWorld.new(@world_proc, proc) if @world_proc + @world_proc = proc end @world_modules ||= [] @@ -189,6 +190,7 @@ def invoked_step_definition(regexp_source, file_colon_line) 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 diff --git a/lib/cucumber/glue/step_definition.rb b/lib/cucumber/glue/step_definition.rb index 31e8391cfd..6f0bf54430 100644 --- a/lib/cucumber/glue/step_definition.rb +++ b/lib/cucumber/glue/step_definition.rb @@ -25,6 +25,7 @@ def message class << self def new(id, registry, string_or_regexp, proc_or_sym, options) raise MissingProc if proc_or_sym.nil? + super id, registry, registry.create_expression(string_or_regexp), create_proc(proc_or_sym, options) end @@ -33,6 +34,7 @@ def new(id, registry, string_or_regexp, proc_or_sym, options) def create_proc(proc_or_sym, options) return proc_or_sym if proc_or_sym.is_a?(Proc) raise ArgumentError unless proc_or_sym.is_a?(Symbol) + message = proc_or_sym target_proc = parse_target_proc_from(options) patch_location_onto lambda { |*args| @@ -49,6 +51,7 @@ def patch_location_onto(block) def parse_target_proc_from(options) return -> { self } unless options.key?(:on) + target = options[:on] case target when Proc @@ -65,6 +68,7 @@ def parse_target_proc_from(options) def initialize(id, registry, expression, proc) raise 'No regexp' if expression.is_a?(Regexp) + @id = id @registry = registry @expression = expression @@ -92,6 +96,7 @@ def to_envelope def expression_type return Cucumber::Messages::StepDefinitionPatternType::CUCUMBER_EXPRESSION if expression.is_a?(CucumberExpressions::CucumberExpression) + Cucumber::Messages::StepDefinitionPatternType::REGULAR_EXPRESSION end diff --git a/lib/cucumber/hooks.rb b/lib/cucumber/hooks.rb index 9527fc3a8d..72e1039135 100644 --- a/lib/cucumber/hooks.rb +++ b/lib/cucumber/hooks.rb @@ -19,6 +19,7 @@ def after_hook(id, location, &block) def after_step_hook(id, test_step, location, &block) raise ArgumentError if test_step.hook? + build_hook_step(id, location, block, AfterStepHook, Core::Test::Action) end diff --git a/lib/cucumber/multiline_argument/data_table.rb b/lib/cucumber/multiline_argument/data_table.rb index f28bf988b1..ef2d7551e4 100644 --- a/lib/cucumber/multiline_argument/data_table.rb +++ b/lib/cucumber/multiline_argument/data_table.rb @@ -83,6 +83,7 @@ def eof; end # @param header_conversion_proc [Proc] see map_headers! def initialize(data, conversion_procs = NULL_CONVERSIONS.dup, header_mappings = {}, header_conversion_proc = nil) raise ArgumentError, 'data must be a Core::Test::DataTable' unless data.is_a? Core::Test::DataTable + ast_table = data # Verify that it's square ast_table.transpose @@ -179,6 +180,7 @@ def symbolic_hashes # def rows_hash return @rows_hash if @rows_hash + verify_table_width(2) @rows_hash = transpose.hashes[0] end @@ -516,6 +518,7 @@ def convert_headers! # :nodoc: mapped_cells = header_cells.reject { |cell| cell.value.match(pre).nil? } raise "No headers matched #{pre.inspect}" if mapped_cells.empty? raise "#{mapped_cells.length} headers matched #{pre.inspect}: #{mapped_cells.map(&:value).inspect}" if mapped_cells.length > 1 + mapped_cells[0].value = post @conversion_procs[post] = @conversion_procs.delete(pre) if @conversion_procs.key?(pre) end @@ -527,6 +530,7 @@ def clear_cache! # :nodoc: def ensure_table(table_or_array) # :nodoc: return table_or_array if DataTable == table_or_array.class + DataTable.from(table_or_array) end @@ -548,6 +552,7 @@ def initialize(table, cells) def accept(visitor) return if Cucumber.wants_to_quit + each do |cell| visitor.visit_table_cell(cell) end diff --git a/lib/cucumber/multiline_argument/data_table/diff_matrices.rb b/lib/cucumber/multiline_argument/data_table/diff_matrices.rb index 3c2c911529..14a65fb905 100644 --- a/lib/cucumber/multiline_argument/data_table/diff_matrices.rb +++ b/lib/cucumber/multiline_argument/data_table/diff_matrices.rb @@ -113,6 +113,7 @@ def fill_in_missing_values row_index = row_indices.index(i) row = cell_matrix[row_index] if row_index next unless row + (original_width..padded_width).each do |col_index| surplus_cell = other_row[col_index] row[col_index].value = surplus_cell.value if row[col_index] diff --git a/lib/cucumber/rake/task.rb b/lib/cucumber/rake/task.rb index 16f142f305..09fc8019c8 100644 --- a/lib/cucumber/rake/task.rb +++ b/lib/cucumber/rake/task.rb @@ -37,6 +37,7 @@ class InProcessCucumberRunner # :nodoc: def initialize(libs, cucumber_opts, feature_files) raise 'libs must be an Array when running in-process' unless Array == libs.class + libs.reverse_each { |lib| $LOAD_PATH.unshift(lib) } @args = ( cucumber_opts + @@ -156,6 +157,7 @@ def define_task # :nodoc: def runner(_task_args = nil) # :nodoc: cucumber_opts = [(ENV['CUCUMBER_OPTS'] ? ENV['CUCUMBER_OPTS'].split(/\s+/) : nil) || cucumber_opts_with_profile] return ForkedCucumberRunner.new(libs, binary, cucumber_opts, bundler, feature_files) if fork + InProcessCucumberRunner.new(libs, cucumber_opts, feature_files) end diff --git a/lib/cucumber/running_test_case.rb b/lib/cucumber/running_test_case.rb index d618ee6a5f..4c05e755fb 100644 --- a/lib/cucumber/running_test_case.rb +++ b/lib/cucumber/running_test_case.rb @@ -33,6 +33,7 @@ def accept_hook?(hook) def exception return unless @result.failed? + @result.exception end diff --git a/lib/cucumber/runtime.rb b/lib/cucumber/runtime.rb index 8d3268c9d2..f74c30ce4b 100644 --- a/lib/cucumber/runtime.rb +++ b/lib/cucumber/runtime.rb @@ -190,6 +190,7 @@ def set_encoding def report return @report if @report + reports = [summary_report] + formatters reports << fail_fast_report if @configuration.fail_fast? reports << publish_banner_printer unless @configuration.publish_quiet? @@ -218,10 +219,12 @@ def formatters def create_formatter(factory, formatter_options, path_or_io) if accept_options?(factory) return factory.new(@configuration, formatter_options) if path_or_io.nil? + factory.new(@configuration.with_options(out_stream: path_or_io), formatter_options) else return factory.new(@configuration) if path_or_io.nil? + factory.new(@configuration.with_options(out_stream: path_or_io)) end end diff --git a/lib/cucumber/runtime/support_code.rb b/lib/cucumber/runtime/support_code.rb index 20842b8cc7..25a767757d 100644 --- a/lib/cucumber/runtime/support_code.rb +++ b/lib/cucumber/runtime/support_code.rb @@ -72,6 +72,7 @@ def invoke_dynamic_steps(steps_text, iso_code, _location) def invoke_dynamic_step(step_name, multiline_argument, _location = nil) matches = step_matches(step_name) raise UndefinedDynamicStep, step_name if matches.empty? + matches.first.invoke(multiline_argument) end @@ -109,6 +110,7 @@ def find_after_step_hooks(test_case) def apply_before_hooks(test_case) return test_case if test_case.test_steps.empty? + scenario = RunningTestCase.new(test_case) hooks = registry.hooks_for(:before, scenario) BeforeHooks.new(@configuration.id_generator, hooks, scenario, @configuration.event_bus).apply_to(test_case) @@ -116,6 +118,7 @@ def apply_before_hooks(test_case) def apply_after_hooks(test_case) return test_case if test_case.test_steps.empty? + scenario = RunningTestCase.new(test_case) hooks = registry.hooks_for(:after, scenario) AfterHooks.new(@configuration.id_generator, hooks, scenario, @configuration.event_bus).apply_to(test_case) diff --git a/lib/cucumber/runtime/user_interface.rb b/lib/cucumber/runtime/user_interface.rb index 028776c196..ab78e0d24d 100644 --- a/lib/cucumber/runtime/user_interface.rb +++ b/lib/cucumber/runtime/user_interface.rb @@ -32,6 +32,7 @@ def ask(question, timeout_seconds) end raise("Waited for input for #{timeout_seconds} seconds, then timed out.") unless answer + puts(answer) answer end diff --git a/lib/cucumber/step_match.rb b/lib/cucumber/step_match.rb index ae1c282568..223d0f9328 100644 --- a/lib/cucumber/step_match.rb +++ b/lib/cucumber/step_match.rb @@ -9,6 +9,7 @@ class StepMatch # :nodoc: def initialize(step_definition, step_name, step_arguments) raise "step_arguments can't be nil (but it can be an empty array)" if step_arguments.nil? + @step_definition = step_definition @name_to_match = step_name @step_arguments = step_arguments @@ -115,6 +116,7 @@ def format_args(*_args) def location raise "No location for #{@step}" unless @step.location + @step.location end diff --git a/lib/cucumber/step_match_search.rb b/lib/cucumber/step_match_search.rb index e3f4c791c4..edf729f824 100644 --- a/lib/cucumber/step_match_search.rb +++ b/lib/cucumber/step_match_search.rb @@ -20,6 +20,7 @@ def initialize(search, configuration) def call(step_name) result = @search.call(step_name) raise Cucumber::Ambiguous.new(step_name, result, @configuration.guess?) if result.length > 1 + result end end diff --git a/lib/cucumber/term/ansicolor.rb b/lib/cucumber/term/ansicolor.rb index 588e19ec58..4006c10b98 100644 --- a/lib/cucumber/term/ansicolor.rb +++ b/lib/cucumber/term/ansicolor.rb @@ -82,6 +82,7 @@ def #{c}(string = nil) def self.included(klass) return unless klass == String + ATTRIBUTES.delete(:clear) ATTRIBUTE_NAMES.delete(:clear) end diff --git a/lib/cucumber/term/banner.rb b/lib/cucumber/term/banner.rb index 8907f6eb92..a968ed0400 100644 --- a/lib/cucumber/term/banner.rb +++ b/lib/cucumber/term/banner.rb @@ -30,6 +30,7 @@ def display_line(line) def display_span(span) return apply_modifiers(span.shift, span) if span.is_a?(Array) + span end diff --git a/scripts/update-changelog b/scripts/update-changelog index 0d8b1cfbaf..2d731d3059 100755 --- a/scripts/update-changelog +++ b/scripts/update-changelog @@ -48,6 +48,7 @@ class Changelog def insert(label, entry) section_index = lines.index { |line| line.strip == heading_for(label) } raise("Unable to find matching heading in CHANGELOG.md for '#{label}' (#{heading_for(label)})") unless section_index + lines.insert(section_index + 2, "* #{entry}\n") end diff --git a/spec/cucumber/formatter/json_spec.rb b/spec/cucumber/formatter/json_spec.rb index f8fb5f5aff..8c1f4ca6a7 100644 --- a/spec/cucumber/formatter/json_spec.rb +++ b/spec/cucumber/formatter/json_spec.rb @@ -772,9 +772,11 @@ def normalise_json(json) elements.each do |scenario| %w[steps before after around].each do |type| next unless scenario[type] + scenario[type].each do |step_or_hook| normalise_json_step_or_hook(step_or_hook) next unless step_or_hook['after'] + step_or_hook['after'].each do |hook| normalise_json_step_or_hook(hook) end diff --git a/spec/cucumber/formatter/spec_helper.rb b/spec/cucumber/formatter/spec_helper.rb index 152242b8e0..7acaeda15c 100644 --- a/spec/cucumber/formatter/spec_helper.rb +++ b/spec/cucumber/formatter/spec_helper.rb @@ -69,6 +69,7 @@ def define_steps step_defs = self.class.step_defs return unless step_defs + dsl = Object.new dsl.extend Glue::Dsl dsl.instance_exec &step_defs From 0376aa45704d8b1971f7960ffe04c64f29a0e827 Mon Sep 17 00:00:00 2001 From: aurelien-reeves Date: Thu, 4 Nov 2021 10:58:24 +0100 Subject: [PATCH 32/38] Enforce LF with Layout/EndOfLine --- .rubocop.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.rubocop.yml b/.rubocop.yml index 0b3162eb20..3fd4f6d1d4 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -23,6 +23,9 @@ AllCops: - 'temp_app/**/*' - 'cck/features/**/*' +Layout/EndOfLine: + EnforcedStyle: lf + # Disabling this cop until the minimum Ruby version is >= 2.3 as squiggly # heredocs '<<~' were introduced then. The files below are the current ones # with offenses From 9b6dac63e12204387d01524395f7afd30e220ecc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Reeves?= Date: Thu, 4 Nov 2021 11:19:30 +0100 Subject: [PATCH 33/38] Update spec/support/fake_objects.rb Co-authored-by: Luke Hill <20105237+luke-hill@users.noreply.github.com> --- spec/support/fake_objects.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/support/fake_objects.rb b/spec/support/fake_objects.rb index 6660668331..05d986615b 100644 --- a/spec/support/fake_objects.rb +++ b/spec/support/fake_objects.rb @@ -5,7 +5,7 @@ # The following fake objects was previously declared within `describe` scope. # Declaring into scope did not isolate them. # -# Moving those into a dedicated support file explitely state that those are available +# Moving these into a dedicated support file explicitly states that these are available globally as soon as they are required once. # globaly as soon as they are required once. module FakeObjects From 3f6d27f8d104a7955d892f04a9f4010a7b53f44f Mon Sep 17 00:00:00 2001 From: aurelien-reeves Date: Thu, 4 Nov 2021 11:24:09 +0100 Subject: [PATCH 34/38] Fix typo in comments --- spec/support/fake_objects.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/support/fake_objects.rb b/spec/support/fake_objects.rb index 05d986615b..b10652793a 100644 --- a/spec/support/fake_objects.rb +++ b/spec/support/fake_objects.rb @@ -6,7 +6,6 @@ # Declaring into scope did not isolate them. # # Moving these into a dedicated support file explicitly states that these are available globally as soon as they are required once. -# globaly as soon as they are required once. module FakeObjects module ModuleOne From 28e7b843075107de1135bd54bec2da0c10ae201b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Reeves?= Date: Thu, 4 Nov 2021 14:53:07 +0100 Subject: [PATCH 35/38] Update lib/cucumber/glue/step_definition.rb Co-authored-by: Luke Hill <20105237+luke-hill@users.noreply.github.com> --- lib/cucumber/glue/step_definition.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/cucumber/glue/step_definition.rb b/lib/cucumber/glue/step_definition.rb index 6f0bf54430..94077c9afa 100644 --- a/lib/cucumber/glue/step_definition.rb +++ b/lib/cucumber/glue/step_definition.rb @@ -128,7 +128,6 @@ def ==(other) # @api private def arguments_from(step_name) @expression.match(step_name) - # @registry.invoked_step_definition(regexp_source, location) if args end # @api private From 5575e942890af558f25c61a200f872594348829e Mon Sep 17 00:00:00 2001 From: aurelien-reeves Date: Thu, 4 Nov 2021 14:58:56 +0100 Subject: [PATCH 36/38] Move some call to 'super' to bottom of methods --- lib/cucumber/runtime.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/cucumber/runtime.rb b/lib/cucumber/runtime.rb index f74c30ce4b..7b9eb3a6ba 100644 --- a/lib/cucumber/runtime.rb +++ b/lib/cucumber/runtime.rb @@ -26,8 +26,8 @@ class FileException < RuntimeError attr_reader :path def initialize(original_exception, path) - super(original_exception) @path = path + super(original_exception) end end @@ -36,8 +36,8 @@ class FileNotFoundException < FileException class FeatureFolderNotFoundException < RuntimeError def initialize(path) - super @path = path + super end def message From c6c22fa8b85de560c89c02c0eaab1d586a83cf37 Mon Sep 17 00:00:00 2001 From: aurelien-reeves Date: Wed, 17 Nov 2021 11:18:02 +0100 Subject: [PATCH 37/38] Remove useless code The initializer of Core::Event already generates sub-classes with attribute readers. Refs. https://github.com/cucumber/cucumber-ruby-core/blob/main/lib/cucumber/core/event.rb --- lib/cucumber/events/step_activated.rb | 8 -------- lib/cucumber/events/step_definition_registered.rb | 7 ------- 2 files changed, 15 deletions(-) diff --git a/lib/cucumber/events/step_activated.rb b/lib/cucumber/events/step_activated.rb index c5fe83dfd6..e9a26ce4eb 100644 --- a/lib/cucumber/events/step_activated.rb +++ b/lib/cucumber/events/step_activated.rb @@ -15,14 +15,6 @@ class StepActivated < Core::Event.new(:test_step, :step_match) # # @return [Cucumber::StepMatch] attr_reader :step_match - - # @private - def initialize(test_step, step_match) - @test_step = test_step - @step_match = step_match - - super - end end end end diff --git a/lib/cucumber/events/step_definition_registered.rb b/lib/cucumber/events/step_definition_registered.rb index f77473bc5d..4770b889c8 100644 --- a/lib/cucumber/events/step_definition_registered.rb +++ b/lib/cucumber/events/step_definition_registered.rb @@ -10,13 +10,6 @@ class StepDefinitionRegistered < Core::Event.new(:step_definition) # # @return [RbSupport::RbStepDefinition] attr_reader :step_definition - - # _@private - def initialize(step_definition) - @step_definition = step_definition - - super - end end end end From 28f0d3b91e3c713762fd8cf5dc9627d82126a7ce Mon Sep 17 00:00:00 2001 From: aurelien-reeves Date: Wed, 17 Nov 2021 11:41:15 +0100 Subject: [PATCH 38/38] Restore ProtoWorld 'useless' methods for documentation purpose --- .rubocop.yml | 6 ++++++ lib/cucumber/glue/proto_world.rb | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/.rubocop.yml b/.rubocop.yml index 3fd4f6d1d4..8b3133ea90 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -51,6 +51,12 @@ Layout/TrailingWhitespace: Lint/AmbiguousOperator: Enabled: false +# We exclude proto_world for documentation (rdoc) purpose +Lint/UselessMethodDefinition: + Enabled: true + Exclude: + - 'lib/cucumber/glue/proto_world.rb' + Metrics/AbcSize: Max: 45 diff --git a/lib/cucumber/glue/proto_world.rb b/lib/cucumber/glue/proto_world.rb index 1a0bf697ae..b8050130a4 100644 --- a/lib/cucumber/glue/proto_world.rb +++ b/lib/cucumber/glue/proto_world.rb @@ -38,6 +38,9 @@ def step(name, raw_multiline_arg = nil) # And I am logged in as "Susan" # } # @param [String] steps_text The Gherkin snippet to run + def steps(steps_text) + super + end # Parse Gherkin into a {Cucumber::Ast::Table} object. # @@ -114,6 +117,9 @@ def skip_this_scenario(message = 'Scenario skipped') end # Prints the list of modules that are included in the World + def inspect + super + end # see {#inspect} def to_s