Module: JsonParser

Defined in:
lib/parser/json_parser.rb

Overview

Created on 02 Aug 2018 @author: Andy Perrett

Versions: 1.0 - Baseline

json_parser.rb - json parser functions

Class Method Summary collapse

Class Method Details

.parse_test_header_data(parse_json) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/parser/json_parser.rb', line 13

def self.parse_test_header_data(parse_json)
  # get the number of test steps in the file
  number_test_steps = parse_json['steps'].count
  # get the remaining test data
  @test_id = parse_json['testId']
  @project_id = parse_json['projectId']
  test_des = parse_json['testDescription']
  MyLog.log.info "Number of test steps: #{number_test_steps}"
  MyLog.log.info "Test Description: #{test_des}"
  MyLog.log.info "TestID: #{@test_id} \n"
end

.parse_test_step_data(parse_json) ⇒ Object

parseTestStepData



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/parser/json_parser.rb', line 34

def self.parse_test_step_data(parse_json)
  parsed_step = {
    testdesc: parse_json['description'],
    testFunction: parse_json['function'].downcase,
    testvalue: parse_json['value0'],
    locate: parse_json['value1'] || 'id',
    testvalue2: parse_json['value2'],
    locate2: parse_json['value3'] || 'id',
    skipTestCase: parse_json['skipTestCase'] == 'yes'
  }

  parsed_step
  # if an error reading the test step data then re-raise the exception
rescue StandardError => e
  raise e
end

.project_idObject



29
30
31
# File 'lib/parser/json_parser.rb', line 29

def self.project_id
  @project_id
end

.test_idObject



25
26
27
# File 'lib/parser/json_parser.rb', line 25

def self.test_id
  @test_id
end