Skip to content

Commit

Permalink
rspec: Check that all jsons can be loaded into struct
Browse files Browse the repository at this point in the history
Signed-off-by: Kostiantyn Kostiuk <[email protected]>
  • Loading branch information
kostyanf14 committed Mar 6, 2024
1 parent d614261 commit dcba5e2
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions spec/srb_json_load_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
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
types = JSON_TYPES_MAP.filter_map { |json_files_pattern, type| type if File.fnmatch(json_files_pattern, json_file) }

if types.empty?
pending("NO TYPE FOR #{json_file}")
raise
end

data = types.first.from_json_file(json_file)
expect(data).not_to be_nil
end
end
end

0 comments on commit dcba5e2

Please sign in to comment.