diff --git a/CHANGELOG.md b/CHANGELOG.md index e234b1ed00..52a87988ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,11 @@ 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). + ([PR#1594](https://github.com/cucumber/cucumber-ruby/pull/1594) + [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