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.


193
194
195
196
197
198
199
200
201
202
203
# File 'lib/cucumber/formatter/junit.rb', line 193

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


191
192
193
# File 'lib/cucumber/formatter/junit.rb', line 191

def name_suffix
  @name_suffix
end

#row_nameObject (readonly)

Returns the value of attribute row_name


191
192
193
# File 'lib/cucumber/formatter/junit.rb', line 191

def row_name
  @row_name
end

#scenario_nameObject (readonly)

Returns the value of attribute scenario_name


191
192
193
# File 'lib/cucumber/formatter/junit.rb', line 191

def scenario_name
  @scenario_name
end

Instance Method Details

#examples_table_row(row) ⇒ Object


213
214
215
216
# File 'lib/cucumber/formatter/junit.rb', line 213

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

#scenario(scenario) ⇒ Object


205
206
207
# File 'lib/cucumber/formatter/junit.rb', line 205

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

#scenario_outline(outline) ⇒ Object


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

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