Class: Hiptest::NodeModifiers::DatatableFixer

Inherits:
Hiptest::Nodes::Walker show all
Defined in:
lib/hiptest-publisher/node_modifiers/datatable_fixer.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Hiptest::Nodes::Walker

#walk_node

Class Method Details

.add(project) ⇒ Object



6
7
8
# File 'lib/hiptest-publisher/node_modifiers/datatable_fixer.rb', line 6

def self.add(project)
  self.new.walk_node(project)
end

Instance Method Details

#walk_scenario(scenario) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/hiptest-publisher/node_modifiers/datatable_fixer.rb', line 10

def walk_scenario(scenario)
  return if scenario.children[:datatable].nil?

  @argument_names = scenario.children[:parameters].map{|param| param.children[:name]}

  scenario.children[:datatable].children[:datasets].map do |dataset|
    arguments_mapping = {}
    dataset.children[:arguments].map do |arg|
      arguments_mapping[arg.children[:name]] = arg
    end

    dataset.children[:arguments] = @argument_names.map do |arg_name|
      if arguments_mapping.has_key?(arg_name)
        arguments_mapping[arg_name]
      else
        Hiptest::Nodes::Argument.new(arg_name, Hiptest::Nodes::StringLiteral.new(''))
      end
    end
  end
end