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.


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

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


208
209
210
# File 'lib/cucumber/formatter/junit.rb', line 208

def name_suffix
  @name_suffix
end

#row_nameObject (readonly)

Returns the value of attribute row_name


208
209
210
# File 'lib/cucumber/formatter/junit.rb', line 208

def row_name
  @row_name
end

#scenario_nameObject (readonly)

Returns the value of attribute scenario_name


208
209
210
# File 'lib/cucumber/formatter/junit.rb', line 208

def scenario_name
  @scenario_name
end

Instance Method Details

#examples_table_row(row) ⇒ Object


230
231
232
233
# File 'lib/cucumber/formatter/junit.rb', line 230

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

#scenario(scenario) ⇒ Object


222
223
224
# File 'lib/cucumber/formatter/junit.rb', line 222

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

#scenario_outline(outline) ⇒ Object


226
227
228
# File 'lib/cucumber/formatter/junit.rb', line 226

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