diff --git a/lib/cucumber/core/gherkin/ast_builder.rb b/lib/cucumber/core/gherkin/ast_builder.rb index b703de94..2dab3244 100644 --- a/lib/cucumber/core/gherkin/ast_builder.rb +++ b/lib/cucumber/core/gherkin/ast_builder.rb @@ -373,6 +373,12 @@ def result def rows attributes[:rows] = attributes[:rows].map { |r| r[:cells].map { |c| c[:value] } } end + + def location + first_line = attributes[:location][:line] + last_line = first_line + attributes[:rows].length - 1 + Ast::Location.new(file, first_line..last_line) + end end class DocStringBuilder < Builder diff --git a/spec/cucumber/core/test/filters/locations_filter_spec.rb b/spec/cucumber/core/test/filters/locations_filter_spec.rb index b58f7e82..e53c8f25 100644 --- a/spec/cucumber/core/test/filters/locations_filter_spec.rb +++ b/spec/cucumber/core/test/filters/locations_filter_spec.rb @@ -96,6 +96,9 @@ module Cucumber::Core Given a table | a | b | | 1 | 2 | + | 3 | 4 | + + Scenario: empty END end @@ -192,10 +195,25 @@ def test_case_named(name) test_cases.find { |c| c.name == 'with a table' } end - it "matches a location on the first table row" do + it "matches a location at the start of the table" do location = Ast::Location.new(file, 23) expect( test_case.match_locations?([location]) ).to be_truthy end + + it "matches a location in the middle of the table" do + location = Ast::Location.new(file, 24) + expect( test_case.match_locations?([location]) ).to be_truthy + end + + it "matches a location at the end of the table" do + location = Ast::Location.new(file, 25) + expect( test_case.match_locations?([location]) ).to be_truthy + end + + it "does not match a location after the table" do + location = Ast::Location.new(file, 26) + expect( test_case.match_locations?([location]) ).to be_falsey + end end context "with duplicate locations in the filter" do