Class: Capsium::Package::Testing::DataValidationTest

Inherits:
TestCase
  • Object
show all
Defined in:
lib/capsium/package/testing/data_validation_test.rb,
sig/capsium/package/testing/data_validation_test.rbs

Overview

A "data_validation" test (05x-testing): the rows of the data file (format: json or yaml) must validate against the JSON schema file.

Constant Summary collapse

FORMATS =

Returns:

  • (Array[String])
%w[json yaml].freeze

Instance Attribute Summary collapse

Attributes inherited from TestCase

#name

Instance Method Summary collapse

Methods inherited from TestCase

build, from_h, register, types

Constructor Details

#initialize(name:, format:, data_file:, schema_file:) ⇒ DataValidationTest

Returns a new instance of DataValidationTest.



19
20
21
22
23
24
# File 'lib/capsium/package/testing/data_validation_test.rb', line 19

def initialize(name:, format:, data_file:, schema_file:)
  super(name: name)
  @format = format
  @data_file = data_file
  @schema_file = schema_file
end

Instance Attribute Details

#data_fileString (readonly)

Returns the value of attribute data_file.

Returns:

  • (String)


17
18
19
# File 'lib/capsium/package/testing/data_validation_test.rb', line 17

def data_file
  @data_file
end

#formatString (readonly)

Returns the value of attribute format.

Returns:

  • (String)


17
18
19
# File 'lib/capsium/package/testing/data_validation_test.rb', line 17

def format
  @format
end

#schema_fileString (readonly)

Returns the value of attribute schema_file.

Returns:

  • (String)


17
18
19
# File 'lib/capsium/package/testing/data_validation_test.rb', line 17

def schema_file
  @schema_file
end

Instance Method Details

#run(context) ⇒ TestCase::Result

Parameters:

Returns:



26
27
28
29
# File 'lib/capsium/package/testing/data_validation_test.rb', line 26

def run(context)
  problems = validation_problems(context)
  Result.new(name: name, ok: problems.empty?, messages: problems)
end