lib/cucumber/parser/feature.rb in aslakhellesoy-cucumber-0.2.3.2 vs lib/cucumber/parser/feature.rb in aslakhellesoy-cucumber-0.2.3.3

- old
+ new

@@ -54,18 +54,18 @@ end end module Feature2 - def build + def build(filter) background = bg.respond_to?(:build) ? bg.build : nil Ast::Feature.new( background, comment.build, tags.build, header.text_value, - feature_elements.build(background) + feature_elements.build(background, filter) ) end end def _nt_feature @@ -203,10 +203,14 @@ elements[1] end end module Tags2 + def at_line?(line) + ts.elements.detect{|e| e.tag.line == line} + end + def build tag_names = ts.elements.map{|e| e.tag.tag_name.text_value} Ast::Tags.new(ts.line, tag_names) end end @@ -563,12 +567,16 @@ return r0 end module FeatureElements0 - def build(background) - elements.map{|s| s.build(background)} + def build(background, filter) + elements.map do |feature_element| + if filter.nil? || filter.accept?(feature_element) + feature_element.build(background, filter) + end + end.compact end end def _nt_feature_elements start_index = index @@ -640,11 +648,17 @@ elements[8] end end module Scenario1 - def build(background) + def at_line?(line) + scenario_keyword.line == line || + steps.at_line?(line) || + tags.at_line?(line) + end + + def build(background, filter) Ast::Scenario.new( background, comment.build, tags.build, scenario_keyword.line, @@ -758,20 +772,31 @@ elements[9] end end module ScenarioOutline1 - def build(background) + def at_line?(line) + outline_at_line?(line) || + examples_sections.at_line?(line) || + tags.at_line?(line) + end + + def outline_at_line?(line) + scenario_outline_keyword.line == line || + steps.at_line?(line) + end + + def build(background, filter) Ast::ScenarioOutline.new( background, comment.build, tags.build, scenario_outline_keyword.line, scenario_outline_keyword.text_value, name.text_value, steps.build, - examples_sections.build + examples_sections.build(filter, self) ) end end def _nt_scenario_outline @@ -843,10 +868,14 @@ return r0 end module Steps0 + def at_line?(line) + elements.detect{|e| e.at_line?(line)} + end + def build elements.map{|e| e.build} end end @@ -900,10 +929,15 @@ elements[7] end end module Step1 + def at_line?(line) + step_keyword.line == line || + (multi.respond_to?(:at_line?) && multi.at_line?(line)) + end + def build if multi.respond_to?(:build) Ast::Step.new(step_keyword.line, step_keyword.text_value, name.text_value.strip, multi.build) else Ast::Step.new(step_keyword.line, step_keyword.text_value, name.text_value.strip) @@ -1003,13 +1037,21 @@ return r0 end module ExamplesSections0 - def build - elements.map{|e| e.build} + def at_line?(line) + elements.detect { |e| e.at_line?(line) } end + + def build(filter, scenario_outline) + elements.map do |e| + if(filter.nil? || filter.accept?(e) || filter.outline_at_line?(scenario_outline)) + e.build(filter, scenario_outline) + end + end.compact + end end def _nt_examples_sections start_index = index if node_cache[:examples_sections].has_key?(index) @@ -1056,13 +1098,18 @@ elements[6] end end module Examples1 - def build - [examples_keyword.line, examples_keyword.text_value, name.text_value, table.raw] + def at_line?(line) + examples_keyword.line == line || + table.at_line?(line) end + + def build(filter, scenario_outline) + [examples_keyword.line, examples_keyword.text_value, name.text_value, table.raw(filter, scenario_outline)] + end end def _nt_examples start_index = index if node_cache[:examples].has_key?(index) @@ -1231,9 +1278,13 @@ elements[2] end end module PyString2 + def at_line?(line) + line >= open_py_string.line && line <= close_py_string.line + end + def build Ast::PyString.new(open_py_string.line, close_py_string.line, s.text_value, open_py_string.indentation) end end \ No newline at end of file