Module: QAT::Formatter::UtilityFuction

Included in:
Builder, Helper
Defined in:
lib/qat/formatter/utility_function.rb

Overview

Helper for Formatters , most of the main methods are done to reduce code duplication

Since:

  • 0.1.0

Instance Method Summary collapse

Instance Method Details

#background(background) ⇒ Object

Since:

  • 0.1.0



9
10
11
12
13
14
15
16
17
# File 'lib/qat/formatter/utility_function.rb', line 9

def background(background)
  @background_hash = {
    keyword:     background.keyword,
    name:        background.name,
    description: background.description.nil? ? '' : background.description,
    line:        background.location.line,
    type:        'background'
  }
end

#calculate_row_number(scenario_source) ⇒ Object

Since:

  • 0.1.0



38
39
40
41
42
# File 'lib/qat/formatter/utility_function.rb', line 38

def calculate_row_number(scenario_source)
  scenario_source.examples.table_body.each_with_index do |row, index|
    return index + 1 if row == scenario_source.row
  end
end

#create_feature_hash(feature, uri) ⇒ Object

Since:

  • 0.1.0



19
20
21
22
23
24
25
26
27
28
# File 'lib/qat/formatter/utility_function.rb', line 19

def create_feature_hash feature,uri
  @feature_hash = {
    id:          feature.name,
    uri:         uri,
    keyword:     feature.keyword,
    name:        feature.name,
    description: feature.description.nil? ? '' : feature.description,
    line:        feature.location.line
  }
end

#features?(test_step) ⇒ Boolean

Returns:

  • (Boolean)

Since:

  • 0.1.0



52
53
54
# File 'lib/qat/formatter/utility_function.rb', line 52

def features?(test_step)
  test_step.location.file.include?('.feature')
end

#get_example_values(scenario_source) ⇒ Object

Since:

  • 0.1.0



44
45
46
47
48
49
50
# File 'lib/qat/formatter/utility_function.rb', line 44

def get_example_values(scenario_source)
  scenario_source.examples.table_body.each do |row|
    if row == scenario_source.row
      add_values_to_examples row.cells
    end
  end
end

#get_lines_from_scenario(scenario_source, test_case) ⇒ Object

Since:

  • 0.1.0



30
31
32
33
34
35
36
# File 'lib/qat/formatter/utility_function.rb', line 30

def get_lines_from_scenario(scenario_source, test_case)
  if scenario_source.type == :Scenario
    test_case.location.lines.max
  else
    test_case.location.lines.min
  end
end