class CucumberAnalytics::TableRow
A class modeling a step table row.
Attributes
cells[RW]
The cells that make up the row
Public Class Methods
new(source = nil)
click to toggle source
Creates a new TableRow
object and, if source is provided, populates the object.
# File lib/cucumber_analytics/table_row.rb, line 18 def initialize(source = nil) parsed_row = process_source(source) @cells = [] build_row(parsed_row) if parsed_row end
Public Instance Methods
to_s()
click to toggle source
Returns a gherkin representation of the table row.
# File lib/cucumber_analytics/table_row.rb, line 27 def to_s "| #{cells.join(' | ')} |" end
Private Instance Methods
build_row(parsed_row)
click to toggle source
# File lib/cucumber_analytics/table_row.rb, line 53 def build_row(parsed_row) populate_element_source_line(parsed_row) populate_row_cells(parsed_row) populate_raw_element(parsed_row) end
parse_row(source_text)
click to toggle source
# File lib/cucumber_analytics/table_row.rb, line 44 def parse_row(source_text) base_file_string = "Feature: Fake feature to parse\nScenario:\n* fake step\n" source_text = base_file_string + source_text parsed_file = Parsing::parse_text(source_text) parsed_file.first['elements'].first['steps'].first['rows'].first end
populate_row_cells(parsed_row)
click to toggle source
# File lib/cucumber_analytics/table_row.rb, line 59 def populate_row_cells(parsed_row) @cells = parsed_row['cells'] end
process_source(source)
click to toggle source
# File lib/cucumber_analytics/table_row.rb, line 35 def process_source(source) case when source.is_a?(String) parse_row(source) else source end end