Class: Reagan::TestJSON

Inherits:
Object
  • Object
show all
Defined in:
lib/reagan/test_json.rb

Overview

tests to make sure the version has been updated on the cookbook

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ TestJSON

Returns a new instance of TestJSON.



24
25
26
# File 'lib/reagan/test_json.rb', line 24

def initialize(file)
  @file = file
end

Instance Method Details

#testObject

performs JSON format test returns true if json can be parsed and false if it cannot



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/reagan/test_json.rb', line 30

def test
  puts 'Running JSON parsing test:'
  begin
    json_file = File.read(File.join(Config.settings['jenkins']['workspace_dir'], @file))
    JSON.parse(json_file)
    success = true
  rescue JSON::JSONError
    success = false
  end
  puts success ? 'PASS: JSON parses'.indent : 'FAIL: JSON does NOT parse'.indent.to_red
  success
end