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
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
expect(subsection_link(subsection, case_log)).to match(/household-characteristics/)
end
end
context "for a subsection that cannot be started yet" do
context "with a subsection that cannot be started yet" do
before do
allow(subsection).to receive(:status).with(case_log).and_return(:cannot_start_yet)
end

46
spec/lib/tasks/form_definition_validator_spec.rb

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

Loading…
Cancel
Save