diff --git a/.github/workflows/release-rubygem.yml b/.github/workflows/release-rubygem.yml index b12f9bff..0314b2b2 100644 --- a/.github/workflows/release-rubygem.yml +++ b/.github/workflows/release-rubygem.yml @@ -13,7 +13,7 @@ jobs: - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: - ruby-version: '3.0.2' + ruby-version: '3.2' bundler-cache: true - uses: cucumber/action-publish-rubygem@v1.0.0 with: diff --git a/.github/workflows/test-ruby.yml b/.github/workflows/test-ruby.yml index c32ab395..eafea738 100644 --- a/.github/workflows/test-ruby.yml +++ b/.github/workflows/test-ruby.yml @@ -18,20 +18,17 @@ jobs: matrix: os: - ubuntu-latest - ruby: ["2.6", "2.7", "3.0", "3.1"] + ruby: ['2.6', '2.7', '3.0', '3.1', '3.2'] include: - os: macos-latest - ruby: "3.1" + ruby: '3.2' steps: - uses: actions/checkout@v4 - - - name: Set up Ruby - uses: ruby/setup-ruby@v1 + - uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} bundler-cache: true working-directory: ruby - - run: bundle exec rake working-directory: ruby diff --git a/CHANGELOG.md b/CHANGELOG.md index 192b0572..8000a84c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Added - Added C++ implementation ([#152](https://github.com/cucumber/messages/pull/152)) +### Changed +- [Ruby] Updated minimum Ruby version to 2.5 - ([#177](https://github.com/cucumber/messages/pull/177) [luke-hill](https://github.com/luke-hill)) + ## [22.0.0] - 2023-04-06 ### Added - Added source reference to parameter type ([#45](https://github.com/cucumber/messages/pull/145)) diff --git a/ruby/.rubocop.yml b/ruby/.rubocop.yml new file mode 100644 index 00000000..4e944341 --- /dev/null +++ b/ruby/.rubocop.yml @@ -0,0 +1,21 @@ +inherit_from: .rubocop_todo.yml + +require: + - rubocop-rspec + +AllCops: + TargetRubyVersion: 2.5 + NewCops: enable + +Layout/LineLength: + Max: 200 + +Style/Documentation: + Enabled: false + +Style/RegexpLiteral: + EnforcedStyle: slashes + AllowInnerSlashes: true + +RSpec/MessageSpies: + EnforcedStyle: receive diff --git a/ruby/.rubocop_todo.yml b/ruby/.rubocop_todo.yml new file mode 100644 index 00000000..cee0cf2c --- /dev/null +++ b/ruby/.rubocop_todo.yml @@ -0,0 +1,397 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2023-10-27 15:09:45 UTC using RuboCop version 1.28.2. +# The point is for the user to remove these configuration records +# one by one as the offenses are removed from the code base. +# Note that changes in the inspected code, or installation of new +# versions of RuboCop, may require this file to be generated again. + +# Initial iteration: 22 files inspected, 816 offenses detected, 678 offenses auto-correctable + +# Offense count: 1 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: Include. +# Include: **/*.gemspec +Gemspec/RequireMFA: + Exclude: + - 'cucumber-messages.gemspec' + +# Offense count: 29 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: AllowBorderComment, AllowMarginComment. +Layout/EmptyComment: + Exclude: + - 'lib/cucumber/messages.dtos.rb' + +# Offense count: 1 +# This cop supports safe auto-correction (--auto-correct). +Layout/EmptyLineAfterGuardClause: + Exclude: + - 'lib/cucumber/messages/ndjson_to_message_enumerator.rb' + +# Offense count: 1 +# This cop supports safe auto-correction (--auto-correct). +Layout/EmptyLineAfterMagicComment: + Exclude: + - 'Gemfile' + +# Offense count: 55 +# This cop supports safe auto-correction (--auto-correct). +Layout/EmptyLines: + Exclude: + - 'lib/cucumber/messages.dtos.rb' + +# Offense count: 110 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only +Layout/EmptyLinesAroundClassBody: + Exclude: + - 'lib/cucumber/messages.deserializers.rb' + - 'lib/cucumber/messages.dtos.rb' + +# Offense count: 6 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines +Layout/EmptyLinesAroundModuleBody: + Exclude: + - 'lib/cucumber/messages.deserializers.rb' + - 'lib/cucumber/messages.dtos.rb' + - 'lib/cucumber/messages/message/deserialization.rb' + - 'lib/cucumber/messages/message/serialization.rb' + - 'lib/cucumber/messages/message/utils.rb' + +# Offense count: 2 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment. +Layout/ExtraSpacing: + Exclude: + - 'cucumber-messages.gemspec' + +# Offense count: 4 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: IndentationWidth. +# SupportedStyles: special_inside_parentheses, consistent, align_brackets +Layout/FirstArrayElementIndentation: + EnforcedStyle: consistent + +# Offense count: 4 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. +# SupportedHashRocketStyles: key, separator, table +# SupportedColonStyles: key, separator, table +# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit +Layout/HashAlignment: + Exclude: + - 'cucumber-messages.gemspec' + +# Offense count: 4 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, IgnoredPatterns. +# URISchemes: http, https +Layout/LineLength: + Max: 338 + +# Offense count: 2 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator. +# SupportedStylesForExponentOperator: space, no_space +Layout/SpaceAroundOperators: + Exclude: + - 'cucumber-messages.gemspec' + +# Offense count: 2 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets. +# SupportedStyles: space, no_space, compact +# SupportedStylesForEmptyBrackets: space, no_space +Layout/SpaceInsideArrayLiteralBrackets: + Exclude: + - 'lib/cucumber/messages/message/serialization.rb' + +# Offense count: 3 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. +# SupportedStyles: space, no_space, compact +# SupportedStylesForEmptyBraces: space, no_space +Layout/SpaceInsideHashLiteralBraces: + Exclude: + - 'spec/cucumber/messages/message/serialization_spec.rb' + +# Offense count: 4 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: final_newline, final_blank_line +Layout/TrailingEmptyLines: + Exclude: + - 'lib/cucumber/messages.dtos.rb' + - 'spec/cucumber/messages/id_generator_spec.rb' + - 'spec/cucumber/messages/message/dummy_messages.rb' + - 'spec/cucumber/messages/version_spec.rb' + +# Offense count: 45 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: AllowInHeredoc. +Layout/TrailingWhitespace: + Exclude: + - 'lib/cucumber/messages.dtos.rb' + +# Offense count: 1 +# This cop supports safe auto-correction (--auto-correct). +Lint/AmbiguousOperatorPrecedence: + Exclude: + - 'lib/cucumber/messages/time_conversion.rb' + +# Offense count: 1 +Lint/IneffectiveAccessModifier: + Exclude: + - 'spec/cucumber/messages/message/dummy_messages.rb' + +# Offense count: 57 +Lint/MissingSuper: + Exclude: + - 'lib/cucumber/messages.dtos.rb' + - 'spec/cucumber/messages/message/dummy_messages.rb' + +# Offense count: 1 +# This cop supports unsafe auto-correction (--auto-correct-all). +Lint/NonDeterministicRequireOrder: + Exclude: + - 'Rakefile' + +# Offense count: 1 +# This cop supports safe auto-correction (--auto-correct). +Lint/ToJSON: + Exclude: + - 'lib/cucumber/messages/message/serialization.rb' + +# Offense count: 1 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: ContextCreatingMethods, MethodCreatingMethods. +Lint/UselessAccessModifier: + Exclude: + - 'spec/cucumber/messages/message/dummy_messages.rb' + +# Offense count: 1 +Lint/UselessAssignment: + Exclude: + - 'lib/cucumber/messages/ndjson_to_message_enumerator.rb' + +# Offense count: 2 +# Configuration parameters: IgnoredMethods, CountRepeatedAttributes. +Metrics/AbcSize: + Max: 37 + +# Offense count: 3 +# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods. +# IgnoredMethods: refine +Metrics/BlockLength: + Max: 68 + +# Offense count: 1 +# Configuration parameters: IgnoredMethods. +Metrics/CyclomaticComplexity: + Max: 8 + +# Offense count: 7 +# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods. +Metrics/MethodLength: + Max: 20 + +# Offense count: 11 +# Configuration parameters: CountKeywordArgs, MaxOptionalParameters. +Metrics/ParameterLists: + Max: 17 + +# Offense count: 1 +# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames. +# AllowedNames: at, by, db, id, in, io, ip, of, on, os, pp, to +Naming/MethodParameterName: + Exclude: + - 'lib/cucumber/messages.dtos.rb' + +# Offense count: 2 +# This cop supports safe auto-correction (--auto-correct). +RSpec/ContextMethod: + Exclude: + - 'spec/cucumber/messages/id_generator_spec.rb' + +# Offense count: 4 +# Configuration parameters: Prefixes. +# Prefixes: when, with, without +RSpec/ContextWording: + Exclude: + - 'spec/cucumber/messages/id_generator_spec.rb' + - 'spec/cucumber/messages/message/serialization_spec.rb' + +# Offense count: 3 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: SkipBlocks, EnforcedStyle. +# SupportedStyles: described_class, explicit +RSpec/DescribedClass: + Exclude: + - 'spec/cucumber/messages/id_generator_spec.rb' + - 'spec/cucumber/messages/time_conversion_spec.rb' + +# Offense count: 2 +# Configuration parameters: CountAsOne. +RSpec/ExampleLength: + Max: 6 + +# Offense count: 1 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: CustomTransform, IgnoredWords. +RSpec/ExampleWording: + Exclude: + - 'spec/cucumber/messages/version_spec.rb' + +# Offense count: 1 +# Configuration parameters: . +# SupportedStyles: have_received, receive +RSpec/MessageSpies: + EnforcedStyle: have_received + +# Offense count: 1 +RSpec/MultipleDescribes: + Exclude: + - 'spec/cucumber/messages/id_generator_spec.rb' + +# Offense count: 4 +RSpec/MultipleExpectations: + Max: 3 + +# Offense count: 34 +# Configuration parameters: IgnoreSharedExamples. +RSpec/NamedSubject: + Exclude: + - 'spec/cucumber/messages/id_generator_spec.rb' + - 'spec/cucumber/messages/message/deserialization_spec.rb' + - 'spec/cucumber/messages/message/serialization_spec.rb' + - 'spec/cucumber/messages/message/utils_spec.rb' + - 'spec/cucumber/messages/version_spec.rb' + +# Offense count: 3 +RSpec/NestedGroups: + Max: 4 + +# Offense count: 202 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: separated, grouped +Style/AccessorGrouping: + Exclude: + - 'lib/cucumber/messages.dtos.rb' + +# Offense count: 7 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: nested, compact +Style/ClassAndModuleChildren: + Exclude: + - 'lib/cucumber/messages.dtos.rb' + - 'spec/cucumber/messages/message/dummy_messages.rb' + +# Offense count: 1 +# This cop supports unsafe auto-correction (--auto-correct-all). +Style/CollectionCompact: + Exclude: + - 'lib/cucumber/messages/message/serialization.rb' + +# Offense count: 1 +# This cop supports safe auto-correction (--auto-correct). +Style/ColonMethodCall: + Exclude: + - 'spec/cucumber/messages/acceptance_spec.rb' + +# Offense count: 1 +# This cop supports safe auto-correction (--auto-correct). +Style/ExpandPathArguments: + Exclude: + - 'Rakefile' + +# Offense count: 21 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: always, always_true, never +Style/FrozenStringLiteralComment: + Enabled: false + +# Offense count: 23 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: literals, strict +Style/MutableConstant: + Exclude: + - 'lib/cucumber/messages.dtos.rb' + - 'spec/cucumber/messages/message/dummy_messages.rb' + +# Offense count: 1 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: Strict, AllowedNumbers. +Style/NumericLiterals: + MinDigits: 11 + +# Offense count: 2 +# This cop supports safe auto-correction (--auto-correct). +Style/PerlBackrefs: + Exclude: + - 'lib/cucumber/messages/message/utils.rb' + +# Offense count: 4 +# This cop supports safe auto-correction (--auto-correct). +Style/RedundantRegexpEscape: + Exclude: + - 'spec/cucumber/messages/id_generator_spec.rb' + +# Offense count: 57 +# This cop supports safe auto-correction (--auto-correct). +Style/RedundantSelf: + Exclude: + - 'lib/cucumber/messages.deserializers.rb' + - 'lib/cucumber/messages/message/serialization.rb' + +# Offense count: 1 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: implicit, explicit +Style/RescueStandardError: + Exclude: + - 'lib/cucumber/messages/ndjson_to_message_enumerator.rb' + +# Offense count: 1 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: RequireEnglish. +# SupportedStyles: use_perl_names, use_english_names, use_builtin_english_names +Style/SpecialGlobalVars: + EnforcedStyle: use_perl_names + +# Offense count: 22 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. +# SupportedStyles: single_quotes, double_quotes +Style/StringLiterals: + Exclude: + - 'Rakefile' + - 'cucumber-messages.gemspec' + - 'lib/cucumber/messages.rb' + - 'lib/cucumber/messages/message/utils.rb' + - 'spec/cucumber/messages/id_generator_spec.rb' + - 'spec/cucumber/messages/message/deserialization_spec.rb' + - 'spec/cucumber/messages/ndjson_serialization_spec.rb' + +# Offense count: 55 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: EnforcedStyleForMultiline. +# SupportedStylesForMultiline: comma, consistent_comma, no_comma +Style/TrailingCommaInArguments: + Exclude: + - 'lib/cucumber/messages.deserializers.rb' + +# Offense count: 1 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: EnforcedStyleForMultiline. +# SupportedStylesForMultiline: comma, consistent_comma, no_comma +Style/TrailingCommaInHashLiteral: + Exclude: + - 'cucumber-messages.gemspec' diff --git a/ruby/README.md b/ruby/README.md index 1697c08b..a97bb8c0 100644 --- a/ruby/README.md +++ b/ruby/README.md @@ -1,2 +1,3 @@ # Cucumber Messages for Ruby (JSON schema) +See main [README](../README.md) diff --git a/ruby/Rakefile b/ruby/Rakefile index 85e0fc70..bb07015f 100644 --- a/ruby/Rakefile +++ b/ruby/Rakefile @@ -1,4 +1,3 @@ -# encoding: utf-8 require 'rubygems' require 'bundler' Bundler::GemHelper.install_tasks @@ -12,14 +11,4 @@ end require "rspec/core/rake_task" RSpec::Core::RakeTask.new(:spec) -require_relative 'spec/capture_warnings' -include CaptureWarnings -namespace :spec do - task :warnings do - report_warnings do - Rake::Task['spec'].invoke - end - end -end - -task default: ['spec:warnings'] +task default: :spec diff --git a/ruby/cucumber-messages.gemspec b/ruby/cucumber-messages.gemspec index cbbe95cd..5771faed 100644 --- a/ruby/cucumber-messages.gemspec +++ b/ruby/cucumber-messages.gemspec @@ -1,5 +1,3 @@ -# -*- encoding: utf-8 -*- - version = File.read(File.expand_path("VERSION", __dir__)).strip Gem::Specification.new do |s| @@ -12,21 +10,23 @@ Gem::Specification.new do |s| s.homepage = "https://github.com/cucumber/messages-ruby#readme" s.platform = Gem::Platform::RUBY s.license = "MIT" - s.required_ruby_version = ">= 2.3" + s.required_ruby_version = ">= 2.5" + s.required_rubygems_version = ">= 3.0.0" s.metadata = { - 'bug_tracker_uri' => 'https://github.com/cucumber/messages/issues', - 'changelog_uri' => 'https://github.com/cucumber/messages/blob/main/CHANGELOG.md', - 'documentation_uri' => 'https://www.rubydoc.info/github/cucumber/messages', - 'mailing_list_uri' => 'https://groups.google.com/forum/#!forum/cukes', - 'source_code_uri' => 'https://github.com/cucumber/messages', - } + 'bug_tracker_uri' => 'https://github.com/cucumber/messages/issues', + 'changelog_uri' => 'https://github.com/cucumber/messages/blob/main/CHANGELOG.md', + 'documentation_uri' => 'https://www.rubydoc.info/github/cucumber/messages', + 'mailing_list_uri' => 'https://groups.google.com/forum/#!forum/cukes', + 'source_code_uri' => 'https://github.com/cucumber/messages', + } - s.add_development_dependency 'cucumber-compatibility-kit', '~> 12.0', '>= 12.0.0' + s.add_development_dependency 'cucumber-compatibility-kit', '~> 12.0' s.add_development_dependency 'rake', '~> 13.0', '>= 13.0.6' - s.add_development_dependency 'rspec', '~> 3.11', '>= 3.11.0' + s.add_development_dependency 'rspec', '~> 3.12' + s.add_development_dependency 'rubocop', '~> 1.28.0' + s.add_development_dependency 'rubocop-rspec', '~> 2.5.0' - s.rubygems_version = ">= 1.6.1" s.files = Dir[ 'README.md', 'LICENSE', diff --git a/ruby/lib/cucumber/messages/message.rb b/ruby/lib/cucumber/messages/message.rb index e6c1e305..cdb79382 100644 --- a/ruby/lib/cucumber/messages/message.rb +++ b/ruby/lib/cucumber/messages/message.rb @@ -8,4 +8,4 @@ class Message include Cucumber::Messages::Message::Serialization end end -end \ No newline at end of file +end diff --git a/ruby/lib/cucumber/messages/message/deserialization.rb b/ruby/lib/cucumber/messages/message/deserialization.rb index 9b01e579..674eed34 100644 --- a/ruby/lib/cucumber/messages/message/deserialization.rb +++ b/ruby/lib/cucumber/messages/message/deserialization.rb @@ -36,4 +36,4 @@ def from_json(json_string) end end end -end \ No newline at end of file +end diff --git a/ruby/lib/cucumber/messages/message/utils.rb b/ruby/lib/cucumber/messages/message/utils.rb index 3091c2c9..17426fa0 100644 --- a/ruby/lib/cucumber/messages/message/utils.rb +++ b/ruby/lib/cucumber/messages/message/utils.rb @@ -43,4 +43,4 @@ def camelize(term) end end end -end \ No newline at end of file +end diff --git a/ruby/scripts/update-gemspec b/ruby/scripts/update-gemspec deleted file mode 100755 index d45401fd..00000000 --- a/ruby/scripts/update-gemspec +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env bash -# -# Updates the *.gemspec in the current directory to use the latest releases of gems -# -set -uf -o pipefail -IFS=$'\n' - -gemspec=$(find . -maxdepth 1 -type f -name "*.gemspec") -if [ "${gemspec}" = "" ]; then - exit 0 -fi -add_dependency_lines=$(cat ${gemspec} | grep "s.add_[a-z_]*dependency '[^']*'") -if [ $? -ne 0 ]; then - # No add_dependency_lines found - nothing to do - exit 0 -fi - -set -e - -gems=$(echo "${add_dependency_lines}" | tr -s ' ' | cut -d ' ' -f3 | cut -d"'" -f 2) -while read -r gem; do - echo "upgrading ${gem}" - if [ "${gem}" = "bundler" ]; then - cat "${gemspec}" | sed "s/\(s.add_[a-z_]*dependency\) '${gem}'.*/\1 '${gem}', '>= 1.16.2'/" > ${gemspec}.tmp - else - gem_line=$(gem list "${gem}" --remote --all --no-prerelease | grep "^${gem}\s") - latest_patch_version=$(echo "${gem_line}" | cut -d'(' -f2 | cut -d')' -f1 | cut -d',' -f1 | cut -d' ' -f1) - latest_minor_version=$(echo "${latest_patch_version}" | cut -d. -f1,2) - cat "${gemspec}" | sed "s/\(s.add_[a-z_]*dependency\) '${gem}'.*/\1 '${gem}', '~> ${latest_minor_version}', '>= ${latest_patch_version}'/" > ${gemspec}.tmp - fi - mv ${gemspec}.tmp ${gemspec} -done <<< "${gems}" diff --git a/ruby/spec/capture_warnings.rb b/ruby/spec/capture_warnings.rb deleted file mode 100644 index 2315009d..00000000 --- a/ruby/spec/capture_warnings.rb +++ /dev/null @@ -1,74 +0,0 @@ -# frozen_string_literal: true -# With thanks to @myronmarston -# https://github.com/vcr/vcr/blob/master/spec/capture_warnings.rb - -module CaptureWarnings - def report_warnings(&block) - current_dir = Dir.pwd - warnings, errors = capture_error(&block).partition { |line| line.include?('warning') } - project_warnings, other_warnings = warnings.uniq.partition { |line| line.include?(current_dir) } - - if errors.any? - puts errors.join("\n") - end - - if other_warnings.any? - puts "#{ other_warnings.count } warnings detected, set VIEW_OTHER_WARNINGS=true to see them." - print_warnings('other', other_warnings) if ENV['VIEW_OTHER_WARNINGS'] - end - - # Until they fix https://bugs.ruby-lang.org/issues/10661 - if RUBY_VERSION == "2.2.0" - project_warnings = project_warnings.reject { |w| w =~ /warning: possible reference to past scope/ } - end - - if project_warnings.any? - puts "#{ project_warnings.count } warnings detected" - print_warnings('cucumber-expressions', project_warnings) - fail "Please remove all cucumber-expressions warnings." - end - - ensure_system_exit_if_required - end - - def capture_error(&block) - old_stderr = STDERR.clone - pipe_r, pipe_w = IO.pipe - pipe_r.sync = true - error = String.new - reader = Thread.new do - begin - loop do - error << pipe_r.readpartial(1024) - end - rescue EOFError - end - end - STDERR.reopen(pipe_w) - block.call - ensure - capture_system_exit - STDERR.reopen(old_stderr) - pipe_w.close - reader.join - return error.split("\n") - end - - def print_warnings(type, warnings) - puts - puts "-" * 30 + " #{type} warnings: " + "-" * 30 - puts - puts warnings.join("\n") - puts - puts "-" * 75 - puts - end - - def ensure_system_exit_if_required - raise @system_exit if @system_exit - end - - def capture_system_exit - @system_exit = $! - end -end