From 0b5498b17e0bea35ed6ba466f219143f4ad96049 Mon Sep 17 00:00:00 2001 From: Ben Behar Date: Sat, 16 Sep 2017 13:44:37 -0500 Subject: [PATCH] removed change in table state when using DataTable#symbolic_hashes --- lib/cucumber/multiline_argument/data_table.rb | 6 ++++-- spec/cucumber/multiline_argument/data_table_spec.rb | 5 +++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/cucumber/multiline_argument/data_table.rb b/lib/cucumber/multiline_argument/data_table.rb index 1ca843a398..dd920ef5bc 100644 --- a/lib/cucumber/multiline_argument/data_table.rb +++ b/lib/cucumber/multiline_argument/data_table.rb @@ -159,8 +159,10 @@ def hashes # [{:foo => '2', :bar => '3', :foo_bar => '5'}, {:foo => '7', :bar => '9', :foo_bar => '16'}] # def symbolic_hashes - @header_conversion_proc = lambda { |h| symbolize_key(h) } - @symbolic_hashes ||= build_hashes + @symbolic_hashes ||= + self.hashes.map do |string_hash| + Hash[string_hash.map{ |a,b| [symbolize_key(a), b] }] + end end # Converts this table into a Hash where the first column is diff --git a/spec/cucumber/multiline_argument/data_table_spec.rb b/spec/cucumber/multiline_argument/data_table_spec.rb index db958552a7..bd213c0c2b 100644 --- a/spec/cucumber/multiline_argument/data_table_spec.rb +++ b/spec/cucumber/multiline_argument/data_table_spec.rb @@ -53,6 +53,11 @@ module MultilineArgument expect{@table.symbolic_hashes}.to_not raise_error end + it 'should not interfere with use of #hashes' do + @table.symbolic_hashes + expect{@table.hashes}.to_not raise_error + end + end describe '#map_column!' do