Module: Taf::JSONParser

Defined in:
lib/taf/json_parser.rb

Overview

json_parser.rb - json parser functions

Class Method Summary collapse

Class Method Details

.parse_test_header_data(parse_json) ⇒ Object



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

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']
  Taf::MyLog.log.info "Number of test steps: #{number_test_steps}"
  Taf::MyLog.log.info "Test Description: #{test_des}"
  Taf::MyLog.log.info "TestID: #{@test_id} \n"
end

.parse_test_step_data(parse_json) ⇒ Object

parseTestStepData



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/taf/json_parser.rb', line 33

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'],
                  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



28
29
30
# File 'lib/taf/json_parser.rb', line 28

def self.project_id
  @project_id
end

.test_idObject



24
25
26
# File 'lib/taf/json_parser.rb', line 24

def self.test_id
  @test_id
end