diff --git a/lib/cucumber/core/ast/examples_table.rb b/lib/cucumber/core/ast/examples_table.rb index 79c4f9f9..cab5de44 100644 --- a/lib/cucumber/core/ast/examples_table.rb +++ b/lib/cucumber/core/ast/examples_table.rb @@ -82,6 +82,10 @@ def ==(other) other.data == data end + def [](parameter_name) + @data[parameter_name] + end + def values @data.values end diff --git a/spec/cucumber/core/ast/examples_table_spec.rb b/spec/cucumber/core/ast/examples_table_spec.rb index 0592a57a..1b4a4cb3 100644 --- a/spec/cucumber/core/ast/examples_table_spec.rb +++ b/spec/cucumber/core/ast/examples_table_spec.rb @@ -75,11 +75,16 @@ module Cucumber::Core::Ast end end - describe 'accesing the values' do + describe 'accessing the values' do it 'returns the actual row values' do row = ExamplesTable::Row.new({'x' => '1', 'y' => '2'}, 1, location, language, comments) expect( row.values ).to eq ['1', '2'] end + + it "can access a row value by it's parameter name" do + row = ExamplesTable::Row.new({'x' => '1', 'y' => '2'}, 1, location, language, comments) + expect( row['x']).to eq '1' + end end describe 'equality' do