From 88aa947b3a06d48eeba4aee5e13d5f25330de326 Mon Sep 17 00:00:00 2001 From: Kostiantyn Kostiuk Date: Thu, 29 Feb 2024 18:53:16 +0200 Subject: [PATCH] rspec: Check that all jsons can be loaded into struct Signed-off-by: Kostiantyn Kostiuk --- spec/srb_json_load_spec.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 spec/srb_json_load_spec.rb diff --git a/spec/srb_json_load_spec.rb b/spec/srb_json_load_spec.rb new file mode 100644 index 00000000..df2a8bc6 --- /dev/null +++ b/spec/srb_json_load_spec.rb @@ -0,0 +1,24 @@ +require 'json' + +require './lib/models/driver' + +JSON_TYPES_MAP = { + './lib/engines/hcktest/drivers/*.json' => AutoHCK::Models::Driver, +}.freeze + +describe 'srb_json_load' do + Dir['./**/*.json'].each do |json_file| + next if json_file.include? 'jtd.json' + + it json_file.to_s do + pair = JSON_TYPES_MAP.find { File.fnmatch(_1[0], json_file) } + + if pair.nil? + pending("NO TYPE FOR #{json_file}") + raise + end + + expect { pair[1].from_json_file(json_file) }.not_to raise_error + end + end +end