diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 153b6c40..ddc4d8eb 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2023-11-16 16:44:59 UTC using RuboCop version 1.27.0. +# on 2023-11-29 11:28:59 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 @@ -9,7 +9,8 @@ # TODO: [LH] Initial state -> 53 files inspected, 2221 offenses detected, 1663 offenses auto-correctable # TODO: [LH] Part 1 iteration -> 53 files inspected, 1990 offenses detected, 1442 offenses auto-correctable # TODO: [LH] Part 2 iteration -> 53 files inspected, 506 offenses detected, 163 offenses auto-correctable -# TODO: [LH] v13 -> 53 files inspected, 450 offenses detected, 150 offenses auto-correctable +# TODO: [LH] v12 -> 53 files inspected, 450 offenses detected, 150 offenses auto-correctable +# TODO: [LH] v12 -> 53 files inspected, 453 offenses detected, 148 offenses auto-correctable # Offense count: 1 # This cop supports safe auto-correction (--auto-correct). @@ -55,11 +56,10 @@ Layout/FirstArrayElementIndentation: Exclude: - 'spec/cucumber/core_spec.rb' -# Offense count: 2 +# Offense count: 1 # This cop supports safe auto-correction (--auto-correct). Layout/HeredocIndentation: Exclude: - - 'spec/cucumber/core/gherkin/writer_spec.rb' - 'spec/cucumber/core/test/doc_string_spec.rb' # Offense count: 2 @@ -116,7 +116,7 @@ Layout/TrailingWhitespace: Metrics/AbcSize: Max: 23 -# Offense count: 54 +# Offense count: 55 # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods. # IgnoredMethods: refine Metrics/BlockLength: @@ -145,7 +145,13 @@ Naming/RescuedExceptionsVariableName: - 'lib/cucumber/core/test/action.rb' - 'lib/cucumber/core/test/around_hook.rb' -# Offense count: 64 +# Offense count: 1 +# This cop supports safe auto-correction (--auto-correct). +RSpec/BeEq: + Exclude: + - 'spec/cucumber/core/event_bus_spec.rb' + +# Offense count: 63 # This cop supports safe auto-correction (--auto-correct). # Configuration parameters: EnabledMethods. RSpec/Capybara/FeatureMethods: @@ -173,10 +179,10 @@ RSpec/DescribedClass: Exclude: - 'spec/cucumber/core/test/doc_string_spec.rb' -# Offense count: 44 +# Offense count: 50 # Configuration parameters: CountAsOne. RSpec/ExampleLength: - Max: 20 + Max: 32 # Offense count: 1 # This cop supports safe auto-correction (--auto-correct). @@ -403,7 +409,7 @@ Style/SymbolArray: # Offense count: 2 # This cop supports unsafe auto-correction (--auto-correct-all). -# Configuration parameters: AllowMethodsWithArguments, IgnoredMethods. +# Configuration parameters: AllowMethodsWithArguments, IgnoredMethods, AllowComments. # IgnoredMethods: respond_to, define_method Style/SymbolProc: Exclude: diff --git a/CHANGELOG.md b/CHANGELOG.md index ecaa0d5d..009d5cf6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,13 +13,16 @@ Please visit [cucumber/CONTRIBUTING.md](https://github.com/cucumber/cucumber/blo - Now using a 2-tiered changelog to avoid any bugs when using polyglot-release - More refactoring of the repo by fixing up a bunch of manual rubocop offenses (See PR's for details) ([#259](https://github.com/cucumber/cucumber-ruby-core/pull/259) [#262](https://github.com/cucumber/cucumber-ruby-core/pull/262) [#268](https://github.com/cucumber/cucumber-ruby-core/pull/268) [#274](https://github.com/cucumber/cucumber-ruby-core/pull/274)) -- In all `Summary` and `Result` classes, changed the `strict` argument into a keyword argument. +- In all `Summary` and `Result` classes, changed the `strict` argument into a keyword argument See upgrading notes for [13.0.0.md](upgrading_notes/13.0.0.md#upgrading-to-1300) ([#261](https://github.com/cucumber/cucumber-ruby-core/pull/261)) - Permit usage of gherkin v27 ### Fixed -- Restore support for matching a scenario by its Feature, Background, and Rule line numbers. ([#247](https://github.com/cucumber/cucumber-ruby-core/pull/237)) +- Restore support for matching a scenario by its Feature, Background, and Rule line numbers ([#247](https://github.com/cucumber/cucumber-ruby-core/pull/247)) + +### Removed +- Remove legacy `unindent` gem (Now no longer required since Ruby 2.3 and Squiggly heredocs) ([#278](https://github.com/cucumber/cucumber-ruby-core/pull/278)) ## [12.0.0] - 2023-09-06 ### Changed diff --git a/cucumber-core.gemspec b/cucumber-core.gemspec index 117a96bf..11fdfd18 100644 --- a/cucumber-core.gemspec +++ b/cucumber-core.gemspec @@ -29,11 +29,10 @@ Gem::Specification.new do |s| s.add_development_dependency 'rake', '~> 13.0', '>= 13.0.6' s.add_development_dependency 'rspec', '~> 3.11', '>= 3.11.0' - s.add_development_dependency 'rubocop', '1.27' + s.add_development_dependency 'rubocop', '~> 1.28.2' s.add_development_dependency 'rubocop-rake', '~> 0.6.0' - s.add_development_dependency 'rubocop-rspec', '2.8' - s.add_development_dependency 'rubocop-packaging', '~> 0.5', '>= 0.5.1' - s.add_development_dependency 'unindent', '~> 1.0', '>= 1.0' + s.add_development_dependency 'rubocop-rspec', '~> 2.10.0' + s.add_development_dependency 'rubocop-packaging', '~> 0.5.1' s.files = Dir['CHANGELOG.md', 'CONTRIBUTING.md', 'README.md', 'LICENSE', 'lib/**/*'] s.rdoc_options = ['--charset=UTF-8'] diff --git a/spec/cucumber/core/gherkin/writer_spec.rb b/spec/cucumber/core/gherkin/writer_spec.rb index 5578d11c..f0e910d4 100644 --- a/spec/cucumber/core/gherkin/writer_spec.rb +++ b/spec/cucumber/core/gherkin/writer_spec.rb @@ -1,24 +1,26 @@ # frozen_string_literal: true require 'cucumber/core/gherkin/writer' -require 'unindent' describe Cucumber::Core::Gherkin::Writer do include described_class it 'generates a uri by default' do source = gherkin { feature } - expect(source.uri).to eq 'features/test.feature' + + expect(source.uri).to eq('features/test.feature') end it 'allows you to specify a URI' do source = gherkin('features/path/to/my.feature') { feature } - expect(source.uri).to eq 'features/path/to/my.feature' + + expect(source.uri).to eq('features/path/to/my.feature') end it 'generates the feature statement by default' do source = gherkin { feature } - expect(source).to eq "Feature:\n" + + expect(source).to eq("Feature:\n") end context 'when a name is provided' do @@ -26,27 +28,31 @@ source = gherkin do feature "A Feature\n" end - expect(source).to eq "Feature: A Feature\n" + + expect(source).to eq("Feature: A Feature\n") end end context 'when a description is provided' do + let(:expected) do + <<~FEATURE + Feature: A Feature + This is the description + which can span + multiple lines. + FEATURE + end + it 'includes the description in the feature statement' do source = gherkin do - feature 'A Feature', description: <<-FEATURE - This is the description - which can span - multiple lines. + feature 'A Feature', description: <<~FEATURE + This is the description + which can span + multiple lines. FEATURE end - expected = <<-FEATURE - Feature: A Feature - This is the description - which can span - multiple lines. - FEATURE - expect(source).to eq expected.unindent + expect(source).to eq(expected) end end @@ -55,7 +61,8 @@ source = gherkin do feature 'A Feature', keyword: 'Business Need' end - expect(source).to eq "Business Need: A Feature\n" + + expect(source).to eq("Business Need: A Feature\n") end end @@ -65,7 +72,7 @@ feature language: 'ru' end - expect(source).to eq "# language: ru\nFeature:\n" + expect(source).to eq("# language: ru\nFeature:\n") end end @@ -77,7 +84,7 @@ feature end - expect(source.to_s).to eq "# wow\n# great\nFeature:\n" + expect(source.to_s).to eq("# wow\n# great\nFeature:\n") end end @@ -93,6 +100,15 @@ end context 'when a comment is provided' do + let(:expected) do + <<~FEATURE + Feature: + + # wow + Scenario: + FEATURE + end + it 'includes the comment in the scenario statement' do source = gherkin do feature do @@ -100,35 +116,35 @@ scenario end end - expect(source.to_s).to eq <<-FEATURE.unindent - Feature: - # wow - Scenario: - FEATURE + expect(source.to_s).to eq(expected) end end context 'when a description is provided' do + let(:expected) do + <<~FEATURE + Feature: + + Scenario: + This is the description + which can span + multiple lines. + FEATURE + end + it 'includes the description in the scenario statement' do source = gherkin do feature do - scenario description: <<-SCENARIO - This is the description - which can span - multiple lines. + scenario description: <<~SCENARIO + This is the description + which can span + multiple lines. SCENARIO end end - expect(source).to eq <<-FEATURE.unindent - Feature: - - Scenario: - This is the description - which can span - multiple lines. - FEATURE + expect(source).to eq(expected) end end @@ -146,6 +162,18 @@ end context 'when a docstring is provided' do + let(:expected) do + <<~FEATURE + Feature: + + Scenario: + Given failing + """text/plain + some text + """ + FEATURE + end + it 'includes the content type when provided' do source = gherkin do feature do @@ -157,21 +185,23 @@ end end - expect(source).to eq <<-FEATURE.unindent - Feature: - - Scenario: - Given failing - """text/plain - some text - """ - FEATURE + expect(source).to eq(expected) end end end end context 'with a background' do + let(:expected) do + <<~FEATURE + Feature: + + Background: + One line, + and two.. + FEATURE + end + it 'can have a description' do source = gherkin do feature do @@ -179,17 +209,20 @@ end end - expect(source).to eq <<-FEATURE.unindent - Feature: - - Background: - One line, - and two.. - FEATURE + expect(source).to eq(expected) end end context 'with a scenario outline' do + let(:expected) do + <<~FEATURE + Feature: + + Scenario Outline: + Doesn't need to be multi-line. + FEATURE + end + it 'can have a description' do source = gherkin do feature do @@ -197,15 +230,21 @@ end end - expect(source).to eq <<-FEATURE.unindent - Feature: - - Scenario Outline: - Doesn't need to be multi-line. - FEATURE + expect(source).to eq(expected) end context 'with an examples table' do + let(:expected) do + <<~FEATURE + Feature: + + Scenario Outline: + + Examples: + Doesn't need to be multi-line. + FEATURE + end + it 'can have a description' do source = gherkin do feature do @@ -215,108 +254,87 @@ end end - expect(source).to eq <<-FEATURE.unindent - Feature: - - Scenario Outline: - - Examples: - Doesn't need to be multi-line. - FEATURE + expect(source).to eq(expected) end end end - it 'can generate a complex feature' do - source = gherkin do - comment 'wow' - feature 'Fully featured', language: 'en', tags: '@always' do - comment 'cool' - background do - step 'passing' - end + context 'with a feature file with many options' do + let(:expected) do + <<~FEATURE + # language: en + # wow + @always + Feature: Fully featured + + # cool + Background: + Given passing + + Scenario: + Given passing + + # here + @first @second + Scenario: with doc string + # and here + Given failing + """ + I wish I was a little bit taller + """ + + # yay + Scenario Outline: eating + Given there are cucumbers + When I eat cucumbers + Then I should have cucumbers + + # hmmm + Examples: + | start | eat | left | + | 12 | 5 | 7 | + | 20 | 5 | 15 | + FEATURE + end - scenario do - step 'passing' - end + it 'can generate a complex feature' do + source = gherkin do + comment 'wow' + feature 'Fully featured', language: 'en', tags: '@always' do + comment 'cool' + background do + step 'passing' + end - comment 'here' - scenario 'with doc string', tags: '@first @second' do - comment 'and here' - step 'passing' - step 'failing', keyword: 'When' do - doc_string <<-DOC_STRING - I wish I was a little bit taller. - I wish I was a baller. - DOC_STRING + scenario do + step 'passing' end - end - scenario 'with a table...' do - step 'passes:' do - table do - row 'name', 'age', 'location' - row 'Janine', '43', 'Antarctica' + comment 'here' + scenario 'with doc string', tags: '@first @second' do + comment 'and here' + step 'failing' do + doc_string 'I wish I was a little bit taller' end end - end - comment 'yay' - scenario_outline 'eating' do - step 'there are cucumbers' - step 'I eat cucumbers', keyword: 'When' - step 'I should have cucumbers', keyword: 'Then' - - comment 'hmmm' - examples do - row 'start', 'eat', 'left' - row '12', '5', '7' - row '20', '5', '15' + comment 'yay' + scenario_outline 'eating' do + step 'there are cucumbers' + step 'I eat cucumbers', keyword: 'When' + step 'I should have cucumbers', keyword: 'Then' + + comment 'hmmm' + examples do + row 'start', 'eat', 'left' + row '12', '5', '7' + row '20', '5', '15' + end end end end - end - expect(source.to_s).to eq <<-FEATURE.unindent -# language: en -# wow -@always -Feature: Fully featured - - # cool - Background: - Given passing - - Scenario: - Given passing - - # here - @first @second - Scenario: with doc string - # and here - Given passing - When failing - """ - I wish I was a little bit taller. - I wish I was a baller. - """ - - Scenario: with a table... - Given passes: - | name | age | location | - | Janine | 43 | Antarctica | - - # yay - Scenario Outline: eating - Given there are cucumbers - When I eat cucumbers - Then I should have cucumbers - - # hmmm - Examples: - | start | eat | left | - | 12 | 5 | 7 | - | 20 | 5 | 15 | - FEATURE + expect(source.to_s).to eq(expected) + end end end