From b410ca04f81e131b76a94de818c26a2778fba013 Mon Sep 17 00:00:00 2001 From: magicmilo Date: Mon, 15 Nov 2021 13:25:01 +0000 Subject: [PATCH] assume schema validation true for test --- lib/tasks/form_definition.rake | 12 ++++++------ spec/lib/tasks/form_definition_validator_spec.rb | 3 ++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/tasks/form_definition.rake b/lib/tasks/form_definition.rake index 50b649d5e..d3ed40a2a 100644 --- a/lib/tasks/form_definition.rake +++ b/lib/tasks/form_definition.rake @@ -15,7 +15,6 @@ namespace :form_definition do desc "Validate JSON against Generic Form Schema" task validate_all: :environment do - directories = ["config/forms", "spec/fixtures/forms"] paths = get_all_form_paths(directories) @@ -26,7 +25,6 @@ namespace :form_definition do end task :validate, %i[path] => :environment do |_task, args| - puts args path = Rails.root.join("config/forms/schema/generic.json") @@ -36,11 +34,13 @@ namespace :form_definition do puts path + binding.pry + if JSON::Validator.validate(meta_schema, schema) - puts "Schema Definition is Valid" - else - puts "Schema Definition in #{path} is not valid against draft4 json schema." - return + puts "Schema Definition is Valid" + else + puts "Schema Definition in #{path} is not valid against draft4 json schema." + next end path = Rails.root.join(args.path) diff --git a/spec/lib/tasks/form_definition_validator_spec.rb b/spec/lib/tasks/form_definition_validator_spec.rb index a85664b7d..c61b39c3e 100644 --- a/spec/lib/tasks/form_definition_validator_spec.rb +++ b/spec/lib/tasks/form_definition_validator_spec.rb @@ -22,11 +22,12 @@ describe "rake form_definition:validate", type: :task do before do Rake.application.rake_require("tasks/form_definition") Rake::Task.define_task(:environment) + allow(JSON::Validator).to receive(:validate).and_return(true) task.reenable end it "runs the validate task for the given form definition" do - expect(JSON::Validator).to receive(:validate!).at_least(1).time + expect(JSON::Validator).to receive(:validate!).at_least(2).times task.invoke("config/forms/2021_2022.json") end end