This class conforms to the Gherkin event API and builds the “legacy” AST. It will be replaced later when we have a new “clean” AST.
# File lib/cucumber/parser/gherkin_builder.rb, line 12 12: def ast 13: @feature || @multiline_arg 14: end
# File lib/cucumber/parser/gherkin_builder.rb, line 27 27: def background(statement) 28: @background = Ast::Background.new( 29: Ast::Comment.new(statement.comments.map{|comment| comment.value}.join("\n")), 30: statement.line, 31: statement.keyword, 32: legacy_name_for(statement.name, statement.description), 33: steps=[] 34: ) 35: @feature.background = @background 36: @background.feature = @feature 37: @step_container = @background 38: end
# File lib/cucumber/parser/gherkin_builder.rb, line 97 97: def eof 98: end
# File lib/cucumber/parser/gherkin_builder.rb, line 74 74: def examples(statement, examples_rows) 75: examples_fields = [ 76: Ast::Comment.new(statement.comments.map{|comment| comment.value}.join("\n")), 77: statement.line, 78: statement.keyword, 79: legacy_name_for(statement.name, statement.description), 80: matrix(examples_rows) 81: ] 82: @step_container.add_examples(examples_fields) 83: end
# File lib/cucumber/parser/gherkin_builder.rb, line 16 16: def feature(statement, uri) 17: @feature = Ast::Feature.new( 18: nil, 19: Ast::Comment.new(statement.comments.map{|comment| comment.value}.join("\n")), 20: Ast::Tags.new(nil, statement.tags.map{|tag| tag.name}), 21: statement.keyword, 22: legacy_name_for(statement.name, statement.description), 23: [] 24: ) 25: end
# File lib/cucumber/parser/gherkin_builder.rb, line 40 40: def scenario(statement) 41: scenario = Ast::Scenario.new( 42: @background, 43: Ast::Comment.new(statement.comments.map{|comment| comment.value}.join("\n")), 44: Ast::Tags.new(nil, statement.tags.map{|tag| tag.name}), 45: statement.line, 46: statement.keyword, 47: legacy_name_for(statement.name, statement.description), 48: steps=[] 49: ) 50: @feature.add_feature_element(scenario) 51: @background.feature_elements << scenario if @background 52: @step_container = scenario 53: end
# File lib/cucumber/parser/gherkin_builder.rb, line 55 55: def scenario_outline(statement) 56: scenario_outline = Ast::ScenarioOutline.new( 57: @background, 58: Ast::Comment.new(statement.comments.map{|comment| comment.value}.join("\n")), 59: Ast::Tags.new(nil, statement.tags.map{|tag| tag.name}), 60: statement.line, 61: statement.keyword, 62: legacy_name_for(statement.name, statement.description), 63: steps=[], 64: example_sections=[] 65: ) 66: @feature.add_feature_element(scenario_outline) 67: if @background 68: @background = @background.dup 69: @background.feature_elements << scenario_outline 70: end 71: @step_container = scenario_outline 72: end
# File lib/cucumber/parser/gherkin_builder.rb, line 85 85: def step(statement, multiline_arg, result) 86: @table_owner = Ast::Step.new(statement.line, statement.keyword, statement.name) 87: multiline_arg = rubify(multiline_arg) 88: case(multiline_arg) 89: when Gherkin::Formatter::Model::PyString 90: @table_owner.multiline_arg = Ast::PyString.new(multiline_arg.value) 91: when Array 92: @table_owner.multiline_arg = Ast::Table.new(matrix(multiline_arg)) 93: end 94: @step_container.add_step(@table_owner) 95: end
# File lib/cucumber/parser/gherkin_builder.rb, line 106 106: def legacy_name_for(name, description) 107: s = name 108: s += "\n#{description}" if description != "" 109: s 110: end
# File lib/cucumber/parser/gherkin_builder.rb, line 112 112: def matrix(gherkin_table) 113: gherkin_table.map do |gherkin_row| 114: row = gherkin_row.cells 115: class << row 116: attr_accessor :line 117: end 118: row.line = gherkin_row.line 119: row 120: end 121: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.