diff --git a/CHANGELOG.md b/CHANGELOG.md index 36e42ae..a48c14f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +### Added +- [Ruby] Initial rubocop gems and basic compliance added (More work to come) ([#49](https://github.com/cucumber/compatibility-kit/pull/49)) + ### Changed - [Ruby] Minimum ruby version is now bumped from 2.3 to 2.5 ([#47](https://github.com/cucumber/compatibility-kit/pull/47)) @@ -25,7 +28,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [11.2.0] - 2022-12-23 ### Changed -- Update cucumber-messages requirement from ~> 19.1, >= 19.1.2 to >= 19.1.2, < 22.0 in /ruby ([#28](https://github.com/cucumber/compatibility-kit/pull/28)) +- [Ruby] Update cucumber-messages requirement from `~> 19.1, >= 19.1.2` to `>= 19.1.2, < 22.0` ([#28](https://github.com/cucumber/compatibility-kit/pull/28)) ## [11.1.0] - 2022-12-17 diff --git a/ruby/.rubocop.yml b/ruby/.rubocop.yml new file mode 100644 index 0000000..42ed64e --- /dev/null +++ b/ruby/.rubocop.yml @@ -0,0 +1,32 @@ +require: + - rubocop-performance + - rubocop-rake + - rubocop-rspec + +inherit_from: .rubocop_todo.yml + +inherit_mode: + merge: + - Exclude + +AllCops: + TargetRubyVersion: 2.5 + NewCops: enable + +# Disabled on our repo's to enable polyglot-release +# TODO: Re-enable once rubocop > 1.40 +#Gemspec/RequireMFA: +# Enabled: false + +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 0000000..55df7fc --- /dev/null +++ b/ruby/.rubocop_todo.yml @@ -0,0 +1,317 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2023-10-05 09:37:18 UTC using RuboCop version 1.17.0. +# The point is for the user to remove these configuration records +# one by one as the offenses are removed from the code base. +# Note that changes in the inspected code, or installation of new +# versions of RuboCop, may require this file to be generated again. + +# TODO: Oct '23 -> 25 files inspected, 145 offenses detected, 96 offenses auto-correctable + +# Offense count: 1 +# Cop supports --auto-correct. +Layout/EmptyLineAfterGuardClause: + Exclude: + - 'lib/messages_comparator.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: aligned, indented, indented_relative_to_receiver +Layout/MultilineMethodCallIndentation: + Exclude: + - 'lib/cucumber-compatibility-kit.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator. +# SupportedStylesForExponentOperator: space, no_space +Layout/SpaceAroundOperators: + Exclude: + - 'features/attachments/attachments.feature.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: require_no_space, require_space +Layout/SpaceInLambdaLiteral: + Exclude: + - 'features/parameter-types/parameter-types.feature.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. +# SupportedStyles: space, no_space +# SupportedStylesForEmptyBraces: space, no_space +Layout/SpaceInsideBlockBraces: + Exclude: + - 'features/attachments/attachments.feature.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: space, no_space +Layout/SpaceInsideStringInterpolation: + Exclude: + - 'spec/capture_warnings.rb' + +# Offense count: 1 +# Configuration parameters: AllowComments, AllowEmptyLambdas. +Lint/EmptyBlock: + Exclude: + - 'features/minimal/minimal.feature.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Lint/EnsureReturn: + Exclude: + - 'spec/capture_warnings.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Lint/NonDeterministicRequireOrder: + Exclude: + - 'Rakefile' + +# Offense count: 1 +# Configuration parameters: AllowComments, AllowNil. +Lint/SuppressedException: + Exclude: + - 'spec/capture_warnings.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments. +Lint/UnusedBlockArgument: + Exclude: + - 'features/unknown-parameter-type/unknown-parameter-type.feature.rb' + +# Offense count: 3 +# Configuration parameters: IgnoredMethods, CountRepeatedAttributes. +Metrics/AbcSize: + Max: 27 + +# Offense count: 3 +# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods. +# IgnoredMethods: refine +Metrics/BlockLength: + Max: 83 + +# Offense count: 3 +# Configuration parameters: IgnoredMethods. +Metrics/CyclomaticComplexity: + Max: 11 + +# Offense count: 3 +# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods. +Metrics/MethodLength: + Max: 20 + +# Offense count: 3 +# Configuration parameters: IgnoredMethods. +Metrics/PerceivedComplexity: + Max: 11 + +# Offense count: 7 +# Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, Regex, IgnoreExecutableScripts, AllowedAcronyms. +# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS +Naming/FileName: + Exclude: + - 'features/data-tables/data-tables.feature.rb' + - 'features/examples-tables/examples-tables.feature.rb' + - 'features/parameter-types/parameter-types.feature.rb' + - 'features/stack-traces/stack-traces.feature.rb' + - 'features/unknown-parameter-type/unknown-parameter-type.feature.rb' + - 'lib/cucumber-compatibility-kit.rb' + - 'spec/cucumber-compatibility-kit_spec.rb' + +# Offense count: 2 +# Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros. +# NamePrefix: is_, has_, have_ +# ForbiddenPrefixes: is_, has_, have_ +# AllowedMethods: is_a? +# MethodDefinitionMacros: define_method, define_singleton_method +Naming/PredicateName: + Exclude: + - 'lib/cucumber-compatibility-kit.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Performance/Count: + Exclude: + - 'lib/cucumber-compatibility-kit.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Performance/RedundantBlockCall: + Exclude: + - 'spec/capture_warnings.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: AutoCorrect. +Performance/StringInclude: + Exclude: + - 'spec/capture_warnings.rb' + +# Offense count: 1 +Performance/UnfreezeString: + Exclude: + - 'spec/capture_warnings.rb' + +# Offense count: 2 +# Configuration parameters: Max. +RSpec/ExampleLength: + Exclude: + - 'spec/messages_comparator_spec.rb' + +# Offense count: 3 +# Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly. +# Include: **/*_spec*rb*, **/spec/**/* +RSpec/FilePath: + Exclude: + - 'spec/cucumber-compatibility-kit_spec.rb' + - 'spec/keys_checker_spec.rb' + - 'spec/messages_comparator_spec.rb' + +# Offense count: 1 +# Configuration parameters: AllowSubject. +RSpec/MultipleMemoizedHelpers: + Max: 7 + +# Offense count: 10 +# Configuration parameters: IgnoreSharedExamples. +RSpec/NamedSubject: + Exclude: + - 'spec/keys_checker_spec.rb' + - 'spec/messages_comparator_spec.rb' + +# Offense count: 1 +Rake/Desc: + Exclude: + - 'Rakefile' + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, IgnoredMethods, AllowBracesOnProceduralOneLiners, BracesRequiredMethods. +# SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces +# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object +# FunctionalMethods: let, let!, subject, watch +# IgnoredMethods: lambda, proc, it +Style/BlockDelimiters: + Exclude: + - 'spec/cucumber-compatibility-kit_spec.rb' + - 'spec/keys_checker_spec.rb' + - 'templates/specs.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: nested, compact +Style/ClassAndModuleChildren: + Exclude: + - 'lib/cucumber-compatibility-kit.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: Keywords. +# Keywords: TODO, FIXME, OPTIMIZE, HACK, REVIEW, NOTE +Style/CommentAnnotation: + Exclude: + - 'lib/shared_examples.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/Encoding: + Exclude: + - 'Rakefile' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/ExpandPathArguments: + Exclude: + - 'Rakefile' + +# Offense count: 3 +# Cop supports --auto-correct. +Style/GlobalStdStream: + Exclude: + - 'spec/capture_warnings.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: AllowedReceivers. +Style/HashEachMethods: + Exclude: + - 'lib/messages_comparator.rb' + +# Offense count: 5 +# Cop supports --auto-correct. +Style/IfUnlessModifier: + Exclude: + - 'features/retry/retry.feature.rb' + - 'lib/shared_examples.rb' + - 'spec/capture_warnings.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: IgnoredMethods. +Style/MethodCallWithoutArgsParentheses: + Exclude: + - 'spec/messages_comparator_spec.rb' + +# Offense count: 1 +Style/MixinUsage: + Exclude: + - 'Rakefile' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, IgnoredMethods. +# SupportedStyles: predicate, comparison +Style/NumericPredicate: + Exclude: + - 'lib/cucumber-compatibility-kit.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, AllowedCompactTypes. +# SupportedStyles: compact, exploded +Style/RaiseArgs: + Exclude: + - 'lib/cucumber-compatibility-kit.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: Methods. +Style/RedundantArgument: + Exclude: + - 'features/attachments/attachments.feature.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/RedundantBegin: + Exclude: + - 'spec/capture_warnings.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Style/RedundantSelf: + Exclude: + - 'features/attachments/attachments.feature.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: only_raise, only_fail, semantic +Style/SignalException: + Exclude: + - 'lib/shared_examples.rb' + - 'spec/capture_warnings.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: MinSize, WordRegex. +# SupportedStyles: percent, brackets +Style/WordArray: + EnforcedStyle: brackets diff --git a/ruby/Gemfile b/ruby/Gemfile index fa75df1..7f4f5e9 100644 --- a/ruby/Gemfile +++ b/ruby/Gemfile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + source 'https://rubygems.org' gemspec diff --git a/ruby/Rakefile b/ruby/Rakefile index 85e0fc7..5a08f60 100644 --- a/ruby/Rakefile +++ b/ruby/Rakefile @@ -1,15 +1,17 @@ # encoding: utf-8 +# frozen_string_literal: true + require 'rubygems' require 'bundler' Bundler::GemHelper.install_tasks -$:.unshift File.expand_path("../lib", __FILE__) +$LOAD_PATH.unshift File.expand_path('../lib', __FILE__) Dir['./rake/*.rb'].each do |f| require f end -require "rspec/core/rake_task" +require 'rspec/core/rake_task' RSpec::Core::RakeTask.new(:spec) require_relative 'spec/capture_warnings' diff --git a/ruby/cucumber-compatibility-kit.gemspec b/ruby/cucumber-compatibility-kit.gemspec index e1f0fcc..755cbeb 100644 --- a/ruby/cucumber-compatibility-kit.gemspec +++ b/ruby/cucumber-compatibility-kit.gemspec @@ -1,3 +1,5 @@ +# frozen_string_literal: true + version = File.read(File.expand_path('VERSION', __dir__)).strip Gem::Specification.new do |s| @@ -23,6 +25,10 @@ Gem::Specification.new do |s| s.add_dependency 'cucumber-messages', '>= 19.1.2', '< 22.1' s.add_dependency 'rake', '~> 13.0', '>= 13.0.6' s.add_dependency 'rspec', '~> 3.12' + s.add_dependency 'rubocop', '~> 1.17.0' + s.add_dependency 'rubocop-performance', '~> 1.7.0' + s.add_dependency 'rubocop-rake', '~> 0.5.0' + s.add_dependency 'rubocop-rspec', '~> 2.0.0' s.executables = [] s.rubygems_version = '>= 3.0.0' diff --git a/ruby/features/attachments/attachments.feature.rb b/ruby/features/attachments/attachments.feature.rb index 870a2c6..fcd3854 100644 --- a/ruby/features/attachments/attachments.feature.rb +++ b/ruby/features/attachments/attachments.feature.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'stringio' # Cucumber-JVM needs to use a Before hook in order to create attachments diff --git a/ruby/features/data-tables/data-tables.feature.rb b/ruby/features/data-tables/data-tables.feature.rb index 2843acf..efb3e77 100644 --- a/ruby/features/data-tables/data-tables.feature.rb +++ b/ruby/features/data-tables/data-tables.feature.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + When('the following table is transposed:') do |table| @transposed = table.transpose end diff --git a/ruby/features/examples-tables/examples-tables.feature.rb b/ruby/features/examples-tables/examples-tables.feature.rb index a7ea109..9b0bcd5 100644 --- a/ruby/features/examples-tables/examples-tables.feature.rb +++ b/ruby/features/examples-tables/examples-tables.feature.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Given('there are {int} cucumbers') do |initial_count| @count = initial_count end diff --git a/ruby/features/hooks/hooks.feature.rb b/ruby/features/hooks/hooks.feature.rb index 2e1787c..6039161 100644 --- a/ruby/features/hooks/hooks.feature.rb +++ b/ruby/features/hooks/hooks.feature.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + def attach_or_embed(world, data, media_type) # Backward compatibility as the steps are also used by cucumber-ruby 3 which does not support `attach` world.respond_to?(:attach) ? attach(data, media_type) : embed(data, media_type) diff --git a/ruby/features/minimal/minimal.feature.rb b/ruby/features/minimal/minimal.feature.rb index dc32696..68adecb 100644 --- a/ruby/features/minimal/minimal.feature.rb +++ b/ruby/features/minimal/minimal.feature.rb @@ -1,2 +1,4 @@ +# frozen_string_literal: true + Given('I have {int} cukes in my belly') do |cuke_count| -end \ No newline at end of file +end diff --git a/ruby/features/parameter-types/parameter-types.feature.rb b/ruby/features/parameter-types/parameter-types.feature.rb index beaf5e9..609c57f 100644 --- a/ruby/features/parameter-types/parameter-types.feature.rb +++ b/ruby/features/parameter-types/parameter-types.feature.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Flight attr_reader :from, :to @@ -18,4 +20,3 @@ def initialize(from, to) expect(flight.to).to eq('CDG') expect(delay).to eq(45) end - diff --git a/ruby/features/pending/pending.feature.rb b/ruby/features/pending/pending.feature.rb index e40f418..09e6e3f 100644 --- a/ruby/features/pending/pending.feature.rb +++ b/ruby/features/pending/pending.feature.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Given('an implemented step') do # no-op end @@ -8,4 +10,4 @@ Given('a step that isnt implemented yet') do 'pending' -end \ No newline at end of file +end diff --git a/ruby/features/retry/retry.feature.rb b/ruby/features/retry/retry.feature.rb index e43b176..51bd8fa 100644 --- a/ruby/features/retry/retry.feature.rb +++ b/ruby/features/retry/retry.feature.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Given('a step that always passes') do # no-op end diff --git a/ruby/features/rules/rules.feature.rb b/ruby/features/rules/rules.feature.rb index 11172e1..9c09585 100644 --- a/ruby/features/rules/rules.feature.rb +++ b/ruby/features/rules/rules.feature.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Given('there are {int} {float} coins inside') do |count, coin_type| expect(count).not_to be_nil expect(coin_type.to_s).not_to be_empty diff --git a/ruby/features/skipped/skipped.feature.rb b/ruby/features/skipped/skipped.feature.rb index efd9dc6..cfc19bd 100644 --- a/ruby/features/skipped/skipped.feature.rb +++ b/ruby/features/skipped/skipped.feature.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Before('@skip') do 'skipped' end @@ -12,4 +14,4 @@ Given('a step that skips') do 'skipped' -end \ No newline at end of file +end diff --git a/ruby/features/stack-traces/stack-traces.feature.rb b/ruby/features/stack-traces/stack-traces.feature.rb index ccd52ea..85f2f92 100644 --- a/ruby/features/stack-traces/stack-traces.feature.rb +++ b/ruby/features/stack-traces/stack-traces.feature.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + When('a step throws an exception') do raise StandardError, 'An exception is raised here' end diff --git a/ruby/features/undefined/undefined.feature.rb b/ruby/features/undefined/undefined.feature.rb index 9b9119c..e6ceea6 100644 --- a/ruby/features/undefined/undefined.feature.rb +++ b/ruby/features/undefined/undefined.feature.rb @@ -1,7 +1,9 @@ +# frozen_string_literal: true + Given('an implemented step') do # no-op end Given('a step that we expect to be skipped') do # no-op -end \ No newline at end of file +end diff --git a/ruby/features/unknown-parameter-type/unknown-parameter-type.feature.rb b/ruby/features/unknown-parameter-type/unknown-parameter-type.feature.rb index 56e01a5..4bb04d5 100644 --- a/ruby/features/unknown-parameter-type/unknown-parameter-type.feature.rb +++ b/ruby/features/unknown-parameter-type/unknown-parameter-type.feature.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Given('{airport} is closed because of a strike') do |airport| raise StandardError, 'Should not be called because airport type not defined' -end \ No newline at end of file +end diff --git a/ruby/lib/cucumber-compatibility-kit.rb b/ruby/lib/cucumber-compatibility-kit.rb index 9c20ff8..ae0e2ce 100644 --- a/ruby/lib/cucumber-compatibility-kit.rb +++ b/ruby/lib/cucumber-compatibility-kit.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'shared_examples' module Cucumber::CompatibilityKit diff --git a/ruby/lib/keys_checker.rb b/ruby/lib/keys_checker.rb index 58655e9..eaa72ba 100644 --- a/ruby/lib/keys_checker.rb +++ b/ruby/lib/keys_checker.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module CCK class KeysChecker def self.compare(found, expected) diff --git a/ruby/lib/messages_comparator.rb b/ruby/lib/messages_comparator.rb index 6463a57..d2ebe0e 100644 --- a/ruby/lib/messages_comparator.rb +++ b/ruby/lib/messages_comparator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative 'keys_checker' module CCK diff --git a/ruby/lib/shared_examples.rb b/ruby/lib/shared_examples.rb index 056abf6..a6d6ddb 100644 --- a/ruby/lib/shared_examples.rb +++ b/ruby/lib/shared_examples.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'json' require 'rspec' require 'cucumber/messages' @@ -10,8 +12,8 @@ # let(:example) { } # the name of the example to test # let(:messages) { } # the messages to validate - let(:example) { raise "`example` missing: add `let(:example) { example_name }` to your spec" } - let(:messages) { raise "`messages` missing: add `let(:messages) { ndjson }` to your spec" } + let(:example) { raise '`example` missing: add `let(:example) { example_name }` to your spec' } + let(:messages) { raise '`messages` missing: add `let(:messages) { ndjson }` to your spec' } let(:example_path) { Cucumber::CompatibilityKit.example_path(example) } diff --git a/ruby/spec/capture_warnings.rb b/ruby/spec/capture_warnings.rb index 2315009..507cf4f 100644 --- a/ruby/spec/capture_warnings.rb +++ b/ruby/spec/capture_warnings.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # With thanks to @myronmarston # https://github.com/vcr/vcr/blob/master/spec/capture_warnings.rb @@ -18,14 +19,14 @@ def report_warnings(&block) end # Until they fix https://bugs.ruby-lang.org/issues/10661 - if RUBY_VERSION == "2.2.0" + 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." + fail 'Please remove all cucumber-expressions warnings.' end ensure_system_exit_if_required @@ -56,11 +57,11 @@ def capture_error(&block) def print_warnings(type, warnings) puts - puts "-" * 30 + " #{type} warnings: " + "-" * 30 + puts '-' * 30 + " #{type} warnings: " + '-' * 30 puts puts warnings.join("\n") puts - puts "-" * 75 + puts '-' * 75 puts end @@ -69,6 +70,6 @@ def ensure_system_exit_if_required end def capture_system_exit - @system_exit = $! + @system_exit = $ERROR_INFO end end diff --git a/ruby/spec/cucumber-compatibility-kit_spec.rb b/ruby/spec/cucumber-compatibility-kit_spec.rb index 86bda37..32c2151 100644 --- a/ruby/spec/cucumber-compatibility-kit_spec.rb +++ b/ruby/spec/cucumber-compatibility-kit_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'cucumber-compatibility-kit' describe Cucumber::CompatibilityKit do @@ -28,7 +30,7 @@ describe '#examples_path' do it 'returns the path of the features folder' do - expect(Cucumber::CompatibilityKit.examples_path) + expect(described_class.examples_path) .to eq(features_path) end end @@ -36,14 +38,14 @@ describe '#example_path' do context 'with an existing example' do it 'returns the path of the folder of the example' do - expect(Cucumber::CompatibilityKit.example_path('hooks')) + expect(described_class.example_path('hooks')) .to eq("#{features_path}/hooks") end end context 'with an unexisting example' do it 'raises ArgumentError' do - expect { Cucumber::CompatibilityKit.example_path('should-not-exists') } + expect { described_class.example_path('should-not-exists') } .to raise_error(ArgumentError) end end @@ -51,22 +53,22 @@ describe '#gherkin_examples' do it 'returns the list of gherkin examples' do - expect(Cucumber::CompatibilityKit.gherkin_examples) + expect(described_class.gherkin_examples) .to match_array(gherkin_examples) end end describe '#markdown_examples' do it 'returns the list of markdown examples' do - expect(Cucumber::CompatibilityKit.markdown_examples) + expect(described_class.markdown_examples) .to match_array(markdown_examples) end end describe '#all_examples' do it 'returns the list of all available examples' do - expect(Cucumber::CompatibilityKit.all_examples) + expect(described_class.all_examples) .to match_array(gherkin_examples + markdown_examples) end end -end \ No newline at end of file +end diff --git a/ruby/spec/keys_checker_spec.rb b/ruby/spec/keys_checker_spec.rb index 4d9b3c8..c226f21 100644 --- a/ruby/spec/keys_checker_spec.rb +++ b/ruby/spec/keys_checker_spec.rb @@ -1,9 +1,11 @@ +# frozen_string_literal: true + require 'rspec' require 'cucumber/messages' require_relative '../lib/keys_checker' describe CCK::KeysChecker do - let(:subject) { CCK::KeysChecker } + let(:subject) { described_class } describe '#compare' do let(:complete) do diff --git a/ruby/spec/messages_comparator_spec.rb b/ruby/spec/messages_comparator_spec.rb index 48dabb0..96b08af 100644 --- a/ruby/spec/messages_comparator_spec.rb +++ b/ruby/spec/messages_comparator_spec.rb @@ -1,9 +1,11 @@ +# frozen_string_literal: true + require 'rspec' require 'cucumber/messages' require_relative '../lib/messages_comparator' describe CCK::MessagesComparator do - subject() { CCK::MessagesComparator } + subject() { described_class } context 'when executed as part of a CI' do before do diff --git a/ruby/templates/specs.rb b/ruby/templates/specs.rb index 1500297..cc2eed5 100644 --- a/ruby/templates/specs.rb +++ b/ruby/templates/specs.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'cucumber-compatibility-kit' describe 'Cucumber Compatibility Kit' do