Module: QAT::Formatter::Builder
Overview
Helper for Formatters , most of the main methods are done to reduce code duplication
Instance Method Summary
collapse
#background, #calculate_row_number, #create_feature_hash, #features?, #get_example_values, #get_lines_from_scenario
Instance Method Details
#add_values_to_examples(cells) ⇒ Object
78
79
80
81
82
|
# File 'lib/qat/formatter/builder.rb', line 78
def add_values_to_examples(cells)
@examples_values = cells.map do |data|
data.value.to_s
end
end
|
#build(test_case, ast_lookup) ⇒ Object
10
11
12
13
14
15
16
17
18
|
# File 'lib/qat/formatter/builder.rb', line 10
def build (test_case, ast_lookup)
@background_hash = nil
uri = test_case.location.file
feature = ast_lookup.gherkin_document(uri).feature
feature(feature, uri)
background = feature.children.first.background
background(background) if background
scenario(ast_lookup.scenario_source(test_case), test_case)
end
|
#create_id_from_scenario_source(scenario_source) ⇒ Object
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/qat/formatter/builder.rb', line 63
def create_id_from_scenario_source(scenario_source)
if scenario_source.type == :Scenario
@examples_values = nil
scenario_source.scenario.name
else
@examples_values = []
scenario_outline_name = scenario_source.scenario_outline.name
examples_name = scenario_source.examples.name
get_example_values scenario_source
@row_number = calculate_row_number(scenario_source)
"#{scenario_outline_name};#{examples_name};#{@row_number}"
end
end
|
#feature(feature, uri) ⇒ Object
20
21
22
23
24
25
26
27
|
# File 'lib/qat/formatter/builder.rb', line 20
def feature (feature, uri)
feature_tags = feature.tags
create_feature_hash feature, uri
return if feature_tags.empty?
tags_array = []
feature_tags.each { |tag| tags_array << tag.name }
@feature_hash[:tags] = tags_array
end
|
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/qat/formatter/builder.rb', line 43
def get_scenario_tags tags
if tags.empty?
@scenario[:tags] = []
else
tags_array = []
tags.each { |tag|
name = tag.name
if @test_id_tags
tags_array << name unless name.match(/@test#(\d+)/)
else
tags_array << name
end
}
@scenario[:tags] = tags_array
end
end
|
#scenario(scenario_source, test_case) ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/qat/formatter/builder.rb', line 29
def scenario(scenario_source, test_case)
scenario = scenario_source.type == :Scenario ? scenario_source.scenario : scenario_source.scenario_outline
@scenario = {
id: "#{@feature_hash[:id]};#{create_id_from_scenario_source(scenario_source)}",
keyword: scenario.keyword,
name: test_case.name,
description: scenario.description || '',
line: get_lines_from_scenario(scenario_source, test_case),
type: 'scenario'
}
get_scenario_tags test_case.tags
end
|