Browse Source

assume schema validation true for test

pull/91/head
magicmilo 3 years ago
parent
commit
b410ca04f8
  1. 12
      lib/tasks/form_definition.rake
  2. 3
      spec/lib/tasks/form_definition_validator_spec.rb

12
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)

3
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

Loading…
Cancel
Save