Class: Cucumber::Formatter::NameBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/cucumber/formatter/junit.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(test_case, ast_lookup) ⇒ NameBuilder

Returns a new instance of NameBuilder.



212
213
214
215
216
217
218
219
220
221
222
# File 'lib/cucumber/formatter/junit.rb', line 212

def initialize(test_case, ast_lookup)
  @name_suffix = ''
  @row_name = ''
  scenario_source = ast_lookup.scenario_source(test_case)
  if scenario_source.type == :Scenario
    scenario(scenario_source.scenario)
  else
    scenario_outline(scenario_source.scenario_outline)
    examples_table_row(scenario_source.row)
  end
end

Instance Attribute Details

#name_suffixObject (readonly)

Returns the value of attribute name_suffix.



210
211
212
# File 'lib/cucumber/formatter/junit.rb', line 210

def name_suffix
  @name_suffix
end

#row_nameObject (readonly)

Returns the value of attribute row_name.



210
211
212
# File 'lib/cucumber/formatter/junit.rb', line 210

def row_name
  @row_name
end

#scenario_nameObject (readonly)

Returns the value of attribute scenario_name.



210
211
212
# File 'lib/cucumber/formatter/junit.rb', line 210

def scenario_name
  @scenario_name
end

Instance Method Details

#examples_table_row(row) ⇒ Object



232
233
234
235
# File 'lib/cucumber/formatter/junit.rb', line 232

def examples_table_row(row)
  @row_name = "| #{row.cells.map(&:value).join(' | ')} |"
  @name_suffix = " (outline example : #{@row_name})"
end

#scenario(scenario) ⇒ Object



224
225
226
# File 'lib/cucumber/formatter/junit.rb', line 224

def scenario(scenario)
  @scenario_name = scenario.name.empty? ? 'Unnamed scenario' : scenario.name
end

#scenario_outline(outline) ⇒ Object



228
229
230
# File 'lib/cucumber/formatter/junit.rb', line 228

def scenario_outline(outline)
  @scenario_name = outline.name.empty? ? 'Unnamed scenario outline' : outline.name
end