Browse Source

Push form definition and tasklist helper spec fixes

pull/264/head
Stéphane Meny 3 years ago
parent
commit
9122afd107
No known key found for this signature in database
GPG Key ID: 9D0AFEA988527923
  1. 4
      spec/helpers/tasklist_helper_spec.rb
  2. 46
      spec/lib/tasks/form_definition_validator_spec.rb

4
spec/helpers/tasklist_helper_spec.rb

@ -57,13 +57,13 @@ RSpec.describe TasklistHelper do
describe "subsection link" do describe "subsection link" do
let(:subsection) { case_log.form.get_subsection("household_characteristics") } let(:subsection) { case_log.form.get_subsection("household_characteristics") }
context "for a subsection that's enabled" do context "with a subsection that's enabled" do
it "returns the subsection link url" do it "returns the subsection link url" do
expect(subsection_link(subsection, case_log)).to match(/household-characteristics/) expect(subsection_link(subsection, case_log)).to match(/household-characteristics/)
end end
end end
context "for a subsection that cannot be started yet" do context "with a subsection that cannot be started yet" do
before do before do
allow(subsection).to receive(:status).with(case_log).and_return(:cannot_start_yet) allow(subsection).to receive(:status).with(case_log).and_return(:cannot_start_yet)
end end

46
spec/lib/tasks/form_definition_validator_spec.rb

@ -1,33 +1,35 @@
require "rails_helper" require "rails_helper"
require "rake" require "rake"
describe "rake form_definition:validate_all", type: :task do RSpec.describe "form_definition" do
subject(:task) { Rake::Task["form_definition:validate_all"] } describe ":validate_all", type: :task do
subject(:task) { Rake::Task["form_definition:validate_all"] }
before do before do
Rake.application.rake_require("tasks/form_definition") Rake.application.rake_require("tasks/form_definition")
Rake::Task.define_task(:environment) Rake::Task.define_task(:environment)
task.reenable task.reenable
end end
it "runs the validate task for each form definition in the project" do it "runs the validate task for each form definition in the project" do
expect(Rake::Task["form_definition:validate"]).to receive(:invoke).exactly(4).times expect(Rake::Task["form_definition:validate"]).to receive(:invoke).exactly(4).times
task.invoke task.invoke
end
end end
end
describe "rake form_definition:validate", type: :task do describe ":validate", type: :task do
subject(:task) { Rake::Task["form_definition:validate"] } subject(:task) { Rake::Task["form_definition:validate"] }
before do before do
Rake.application.rake_require("tasks/form_definition") Rake.application.rake_require("tasks/form_definition")
Rake::Task.define_task(:environment) Rake::Task.define_task(:environment)
allow(JSON::Validator).to receive(:validate).and_return(true) allow(JSON::Validator).to receive(:validate).and_return(true)
task.reenable task.reenable
end end
it "runs the validate task for the given form definition" do 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(1).time
task.invoke("config/forms/2021_2022.json") task.invoke("config/forms/2021_2022.json")
end
end end
end end

Loading…
Cancel
Save