From 787a31f02c15bacb45d0f306ee7869d021f15cc7 Mon Sep 17 00:00:00 2001 From: aurelien-reeves Date: Wed, 8 Dec 2021 10:51:29 +0100 Subject: [PATCH 1/2] Change map_column 'strict' argument to a keyword argument --- CHANGELOG.md | 4 ++++ UPGRADING.md | 18 ++++++++++++++++++ lib/cucumber/multiline_argument/data_table.rb | 4 +--- .../multiline_argument/data_table_spec.rb | 6 +++--- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e234b1ed00..5fa0fc47c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,10 @@ Please visit [cucumber/CONTRIBUTING.md](https://github.com/cucumber/cucumber/blo ### Changed +- In `DataTable#map_column`, Changed the `strict` argument into a keyword argument. + See [UPGRADING.md](./UPGRADING.md#upgrading-to-800). + ([Issue#1592](https://github.com/cucumber/cucumber-ruby/issues/1592)) + ### Removed - `AfterConfiguration` has been removed. Please use `InstallPlugin` or `BeforeAll` instead. diff --git a/UPGRADING.md b/UPGRADING.md index a0d9bb4f19..e7180312af 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -104,6 +104,24 @@ Cucumber::Cli::Main.new( ).execute! ``` +## DataTable#map_column `strict` argument + +The `strict` argument for the `map_column` method has changed to a keyword argument. + +### Before 8.0.0 + +```ruby +table.map_column('column', false).do |value| +end +``` + +### With cucumber 8.0.0 + +```ruby +table.map_column('column', strict: false).do |value| +end +``` + # Upgrading to 7.1.0 ## The wire protocol diff --git a/lib/cucumber/multiline_argument/data_table.rb b/lib/cucumber/multiline_argument/data_table.rb index deec3274d2..ece74e858f 100644 --- a/lib/cucumber/multiline_argument/data_table.rb +++ b/lib/cucumber/multiline_argument/data_table.rb @@ -274,13 +274,11 @@ def map_headers(mappings = {}, &block) # end # end # - # rubocop:disable Style/OptionalBooleanParameter # the optional boolean parameter is kept for retrocompatibility - def map_column(column_name, strict = true, &conversion_proc) + 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/spec/cucumber/multiline_argument/data_table_spec.rb b/spec/cucumber/multiline_argument/data_table_spec.rb index 92dd18c24b..7fc1efbc3f 100644 --- a/spec/cucumber/multiline_argument/data_table_spec.rb +++ b/spec/cucumber/multiline_argument/data_table_spec.rb @@ -87,14 +87,14 @@ module MultilineArgument it 'should pass silently if a mapped column does not exist in non-strict mode' do expect do - new_table = @table.map_column('two', false, &:to_i) + new_table = @table.map_column('two', strict: false, &:to_i) new_table.hashes end.not_to raise_error end it 'should fail if a mapped column does not exist in strict mode' do expect do - new_table = @table.map_column('two', true, &:to_i) + new_table = @table.map_column('two', strict: true, &:to_i) new_table.hashes end.to raise_error('The column named "two" does not exist') end @@ -161,7 +161,7 @@ module MultilineArgument %w[two 22222] ]) t2 = table.map_headers({ 'two' => 'Two' }, &:upcase) - .map_column('two', false, &:to_i) + .map_column('two', strict: false, &:to_i) expect(t2.rows_hash).to eq('ONE' => '1111', 'Two' => 22_222) end end From 05cdb073a447a6876f1fd2d1774422217dd2b0be Mon Sep 17 00:00:00 2001 From: aurelien-reeves Date: Wed, 8 Dec 2021 10:54:07 +0100 Subject: [PATCH 2/2] Add link to PR in the changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5fa0fc47c2..52a87988ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,7 +36,8 @@ Please visit [cucumber/CONTRIBUTING.md](https://github.com/cucumber/cucumber/blo - In `DataTable#map_column`, Changed the `strict` argument into a keyword argument. See [UPGRADING.md](./UPGRADING.md#upgrading-to-800). - ([Issue#1592](https://github.com/cucumber/cucumber-ruby/issues/1592)) + ([PR#1594](https://github.com/cucumber/cucumber-ruby/pull/1594) + [Issue#1592](https://github.com/cucumber/cucumber-ruby/issues/1592)) ### Removed