Browse Source

Cover age pages and questions with tests

pull/1254/head
Kat 3 years ago
parent
commit
fe3fb99d9a
  1. 35
      spec/models/form/lettings/pages/person2_age_spec.rb
  2. 35
      spec/models/form/lettings/pages/person3_age_spec.rb
  3. 35
      spec/models/form/lettings/pages/person4_age_spec.rb
  4. 35
      spec/models/form/lettings/pages/person5_age_spec.rb
  5. 35
      spec/models/form/lettings/pages/person6_age_spec.rb
  6. 35
      spec/models/form/lettings/pages/person7_age_spec.rb
  7. 35
      spec/models/form/lettings/pages/person8_age_spec.rb
  8. 73
      spec/models/form/lettings/questions/age2_known_spec.rb
  9. 60
      spec/models/form/lettings/questions/age2_spec.rb
  10. 73
      spec/models/form/lettings/questions/age3_known_spec.rb
  11. 60
      spec/models/form/lettings/questions/age3_spec.rb
  12. 73
      spec/models/form/lettings/questions/age4_known_spec.rb
  13. 60
      spec/models/form/lettings/questions/age4_spec.rb
  14. 73
      spec/models/form/lettings/questions/age5_known_spec.rb
  15. 60
      spec/models/form/lettings/questions/age5_spec.rb
  16. 73
      spec/models/form/lettings/questions/age6_known_spec.rb
  17. 60
      spec/models/form/lettings/questions/age6_spec.rb
  18. 73
      spec/models/form/lettings/questions/age7_known_spec.rb
  19. 60
      spec/models/form/lettings/questions/age7_spec.rb
  20. 73
      spec/models/form/lettings/questions/age8_known_spec.rb
  21. 60
      spec/models/form/lettings/questions/age8_spec.rb

35
spec/models/form/lettings/pages/person2_age_spec.rb

@ -0,0 +1,35 @@
require "rails_helper"
RSpec.describe Form::Lettings::Pages::Person2Age, type: :model do
subject(:page) { described_class.new(page_id, page_definition, subsection) }
let(:page_id) { "person_2_age" }
let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection) }
it "has correct subsection" do
expect(page.subsection).to eq(subsection)
end
it "has the correct header" do
expect(page.header).to eq("")
end
it "has the correct description" do
expect(page.description).to eq("")
end
it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[age2_known age2])
end
it "has the correct id" do
expect(page.id).to eq("person_2_age")
end
it "has correct depends_on" do
expect(page.depends_on).to eq(
[{ "details_known_2" => 0 }],
)
end
end

35
spec/models/form/lettings/pages/person3_age_spec.rb

@ -0,0 +1,35 @@
require "rails_helper"
RSpec.describe Form::Lettings::Pages::Person3Age, type: :model do
subject(:page) { described_class.new(page_id, page_definition, subsection) }
let(:page_id) { "person_3_age" }
let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection) }
it "has correct subsection" do
expect(page.subsection).to eq(subsection)
end
it "has the correct header" do
expect(page.header).to eq("")
end
it "has the correct description" do
expect(page.description).to eq("")
end
it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[age3_known age3])
end
it "has the correct id" do
expect(page.id).to eq("person_3_age")
end
it "has correct depends_on" do
expect(page.depends_on).to eq(
[{"details_known_3"=>0}],
)
end
end

35
spec/models/form/lettings/pages/person4_age_spec.rb

@ -0,0 +1,35 @@
require "rails_helper"
RSpec.describe Form::Lettings::Pages::Person4Age, type: :model do
subject(:page) { described_class.new(page_id, page_definition, subsection) }
let(:page_id) { "person_4_age" }
let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection) }
it "has correct subsection" do
expect(page.subsection).to eq(subsection)
end
it "has the correct header" do
expect(page.header).to eq("")
end
it "has the correct description" do
expect(page.description).to eq("")
end
it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[age4_known age4])
end
it "has the correct id" do
expect(page.id).to eq("person_4_age")
end
it "has correct depends_on" do
expect(page.depends_on).to eq(
[{ "details_known_4" => 0 }],
)
end
end

35
spec/models/form/lettings/pages/person5_age_spec.rb

@ -0,0 +1,35 @@
require "rails_helper"
RSpec.describe Form::Lettings::Pages::Person5Age, type: :model do
subject(:page) { described_class.new(page_id, page_definition, subsection) }
let(:page_id) { "person_5_age" }
let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection) }
it "has correct subsection" do
expect(page.subsection).to eq(subsection)
end
it "has the correct header" do
expect(page.header).to eq("")
end
it "has the correct description" do
expect(page.description).to eq("")
end
it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[age5_known age5])
end
it "has the correct id" do
expect(page.id).to eq("person_5_age")
end
it "has correct depends_on" do
expect(page.depends_on).to eq(
[{ "details_known_5" => 0 }],
)
end
end

35
spec/models/form/lettings/pages/person6_age_spec.rb

@ -0,0 +1,35 @@
require "rails_helper"
RSpec.describe Form::Lettings::Pages::Person6Age, type: :model do
subject(:page) { described_class.new(page_id, page_definition, subsection) }
let(:page_id) { "person_6_age" }
let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection) }
it "has correct subsection" do
expect(page.subsection).to eq(subsection)
end
it "has the correct header" do
expect(page.header).to eq("")
end
it "has the correct description" do
expect(page.description).to eq("")
end
it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[age6_known age6])
end
it "has the correct id" do
expect(page.id).to eq("person_6_age")
end
it "has correct depends_on" do
expect(page.depends_on).to eq(
[{"details_known_6"=>0}],
)
end
end

35
spec/models/form/lettings/pages/person7_age_spec.rb

@ -0,0 +1,35 @@
require "rails_helper"
RSpec.describe Form::Lettings::Pages::Person7Age, type: :model do
subject(:page) { described_class.new(page_id, page_definition, subsection) }
let(:page_id) { "person_7_age" }
let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection) }
it "has correct subsection" do
expect(page.subsection).to eq(subsection)
end
it "has the correct header" do
expect(page.header).to eq("")
end
it "has the correct description" do
expect(page.description).to eq("")
end
it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[age7_known age7])
end
it "has the correct id" do
expect(page.id).to eq("person_7_age")
end
it "has correct depends_on" do
expect(page.depends_on).to eq(
[{"details_known_7"=>0}],
)
end
end

35
spec/models/form/lettings/pages/person8_age_spec.rb

@ -0,0 +1,35 @@
require "rails_helper"
RSpec.describe Form::Lettings::Pages::Person8Age, type: :model do
subject(:page) { described_class.new(page_id, page_definition, subsection) }
let(:page_id) { "person_8_age" }
let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection) }
it "has correct subsection" do
expect(page.subsection).to eq(subsection)
end
it "has the correct header" do
expect(page.header).to eq("")
end
it "has the correct description" do
expect(page.description).to eq("")
end
it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[age8_known age8])
end
it "has the correct id" do
expect(page.id).to eq("person_8_age")
end
it "has correct depends_on" do
expect(page.depends_on).to eq(
[{"details_known_8"=>0}],
)
end
end

73
spec/models/form/lettings/questions/age2_known_spec.rb

@ -0,0 +1,73 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::Age2Known, type: :model do
subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { "age2_known" }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
before do
allow(page).to receive(:id).and_return("age2_known")
end
it "has correct page" do
expect(question.page).to eq(page)
end
it "has the correct type" do
expect(question.type).to eq("radio")
end
it "is not marked as derived" do
expect(question.derived?).to be false
end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"0" => { "value" => "Yes" },
"1" => { "value" => "No" },
})
end
it "has the correct hint" do
expect(question.hint_text).to eq("")
end
it "has the correct id" do
expect(question.id).to eq("age2_known")
end
it "has the correct header" do
expect(question.header).to eq("Do you know person 2’s age?")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("")
end
it "has correct conditional for" do
expect(question.conditional_for).to eq({
"age2" => [0],
})
end
it "has the correct hidden_in_check_answers" do
expect(question.hidden_in_check_answers).to eq(
{
"depends_on" => [
{
"age2_known" => 0,
},
{
"age2_known" => 1,
},
],
},
)
end
it "has the correct check_answers_card_number" do
expect(question.check_answers_card_number).to eq(2)
end
end

60
spec/models/form/lettings/questions/age2_spec.rb

@ -0,0 +1,60 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::Age2, type: :model do
subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { "age2" }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
it "has correct page" do
expect(question.page).to eq(page)
end
it "has the correct header" do
expect(question.header).to eq("Age")
end
it "has the correct type" do
expect(question.type).to eq("numeric")
end
it "is not marked as derived" do
expect(question.derived?).to be false
end
it "has the correct hint" do
expect(question.hint_text).to be_nil
end
it "has the correct min" do
expect(question.min).to eq(0)
end
it "has the correct max" do
expect(question.max).to eq(120)
end
it "has the correct id" do
expect(question.id).to eq("age2")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Person 2’s age")
end
it "has the correct width" do
expect(question.width).to eq(2)
end
it "has the correct inferred check answers value" do
expect(question.inferred_check_answers_value).to eq([{
"condition" => { "age2_known" => 1 },
"value" => "Not known",
}])
end
it "has the correct check_answers_card_number" do
expect(question.check_answers_card_number).to eq(2)
end
end

73
spec/models/form/lettings/questions/age3_known_spec.rb

@ -0,0 +1,73 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::Age3Known, type: :model do
subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { "age3_known" }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
before do
allow(page).to receive(:id).and_return("age3_known")
end
it "has correct page" do
expect(question.page).to eq(page)
end
it "has the correct type" do
expect(question.type).to eq("radio")
end
it "is not marked as derived" do
expect(question.derived?).to be false
end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"0" => { "value" => "Yes" },
"1" => { "value" => "No" },
})
end
it "has the correct hint" do
expect(question.hint_text).to eq("")
end
it "has the correct id" do
expect(question.id).to eq("age3_known")
end
it "has the correct header" do
expect(question.header).to eq("Do you know person 3’s age?")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("")
end
it "has correct conditional for" do
expect(question.conditional_for).to eq({
"age3" => [0],
})
end
it "has the correct hidden_in_check_answers" do
expect(question.hidden_in_check_answers).to eq(
{
"depends_on" => [
{
"age3_known" => 0,
},
{
"age3_known" => 1,
},
],
},
)
end
it "has the correct check_answers_card_number" do
expect(question.check_answers_card_number).to eq(3)
end
end

60
spec/models/form/lettings/questions/age3_spec.rb

@ -0,0 +1,60 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::Age3, type: :model do
subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { "age3" }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
it "has correct page" do
expect(question.page).to eq(page)
end
it "has the correct header" do
expect(question.header).to eq("Age")
end
it "has the correct type" do
expect(question.type).to eq("numeric")
end
it "is not marked as derived" do
expect(question.derived?).to be false
end
it "has the correct hint" do
expect(question.hint_text).to be_nil
end
it "has the correct min" do
expect(question.min).to eq(0)
end
it "has the correct max" do
expect(question.max).to eq(120)
end
it "has the correct id" do
expect(question.id).to eq("age3")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Person 3’s age")
end
it "has the correct width" do
expect(question.width).to eq(2)
end
it "has the correct inferred check answers value" do
expect(question.inferred_check_answers_value).to eq([{
"condition" => { "age3_known" => 1 },
"value" => "Not known",
}])
end
it "has the correct check_answers_card_number" do
expect(question.check_answers_card_number).to eq(3)
end
end

73
spec/models/form/lettings/questions/age4_known_spec.rb

@ -0,0 +1,73 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::Age4Known, type: :model do
subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { "age4_known" }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
before do
allow(page).to receive(:id).and_return("age4_known")
end
it "has correct page" do
expect(question.page).to eq(page)
end
it "has the correct type" do
expect(question.type).to eq("radio")
end
it "is not marked as derived" do
expect(question.derived?).to be false
end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"0" => { "value" => "Yes" },
"1" => { "value" => "No" },
})
end
it "has the correct hint" do
expect(question.hint_text).to eq("")
end
it "has the correct id" do
expect(question.id).to eq("age4_known")
end
it "has the correct header" do
expect(question.header).to eq("Do you know person 4’s age?")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("")
end
it "has correct conditional for" do
expect(question.conditional_for).to eq({
"age4" => [0],
})
end
it "has the correct hidden_in_check_answers" do
expect(question.hidden_in_check_answers).to eq(
{
"depends_on" => [
{
"age4_known" => 0,
},
{
"age4_known" => 1,
},
],
},
)
end
it "has the correct check_answers_card_number" do
expect(question.check_answers_card_number).to eq(4)
end
end

60
spec/models/form/lettings/questions/age4_spec.rb

@ -0,0 +1,60 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::Age4, type: :model do
subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { "age4" }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
it "has correct page" do
expect(question.page).to eq(page)
end
it "has the correct header" do
expect(question.header).to eq("Age")
end
it "has the correct type" do
expect(question.type).to eq("numeric")
end
it "is not marked as derived" do
expect(question.derived?).to be false
end
it "has the correct hint" do
expect(question.hint_text).to be_nil
end
it "has the correct min" do
expect(question.min).to eq(0)
end
it "has the correct max" do
expect(question.max).to eq(120)
end
it "has the correct id" do
expect(question.id).to eq("age4")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Person 4’s age")
end
it "has the correct width" do
expect(question.width).to eq(2)
end
it "has the correct inferred check answers value" do
expect(question.inferred_check_answers_value).to eq([{
"condition" => { "age4_known" => 1 },
"value" => "Not known",
}])
end
it "has the correct check_answers_card_number" do
expect(question.check_answers_card_number).to eq(4)
end
end

73
spec/models/form/lettings/questions/age5_known_spec.rb

@ -0,0 +1,73 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::Age5Known, type: :model do
subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { "age5_known" }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
before do
allow(page).to receive(:id).and_return("age5_known")
end
it "has correct page" do
expect(question.page).to eq(page)
end
it "has the correct type" do
expect(question.type).to eq("radio")
end
it "is not marked as derived" do
expect(question.derived?).to be false
end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"0" => { "value" => "Yes" },
"1" => { "value" => "No" },
})
end
it "has the correct hint" do
expect(question.hint_text).to eq("")
end
it "has the correct id" do
expect(question.id).to eq("age5_known")
end
it "has the correct header" do
expect(question.header).to eq("Do you know person 5’s age?")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("")
end
it "has correct conditional for" do
expect(question.conditional_for).to eq({
"age5" => [0],
})
end
it "has the correct hidden_in_check_answers" do
expect(question.hidden_in_check_answers).to eq(
{
"depends_on" => [
{
"age5_known" => 0,
},
{
"age5_known" => 1,
},
],
},
)
end
it "has the correct check_answers_card_number" do
expect(question.check_answers_card_number).to eq(5)
end
end

60
spec/models/form/lettings/questions/age5_spec.rb

@ -0,0 +1,60 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::Age5, type: :model do
subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { "age5" }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
it "has correct page" do
expect(question.page).to eq(page)
end
it "has the correct header" do
expect(question.header).to eq("Age")
end
it "has the correct type" do
expect(question.type).to eq("numeric")
end
it "is not marked as derived" do
expect(question.derived?).to be false
end
it "has the correct hint" do
expect(question.hint_text).to be_nil
end
it "has the correct min" do
expect(question.min).to eq(0)
end
it "has the correct max" do
expect(question.max).to eq(120)
end
it "has the correct id" do
expect(question.id).to eq("age5")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Person 5’s age")
end
it "has the correct width" do
expect(question.width).to eq(2)
end
it "has the correct inferred check answers value" do
expect(question.inferred_check_answers_value).to eq([{
"condition" => { "age5_known" => 1 },
"value" => "Not known",
}])
end
it "has the correct check_answers_card_number" do
expect(question.check_answers_card_number).to eq(5)
end
end

73
spec/models/form/lettings/questions/age6_known_spec.rb

@ -0,0 +1,73 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::Age6Known, type: :model do
subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { "age6_known" }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
before do
allow(page).to receive(:id).and_return("age6_known")
end
it "has correct page" do
expect(question.page).to eq(page)
end
it "has the correct type" do
expect(question.type).to eq("radio")
end
it "is not marked as derived" do
expect(question.derived?).to be false
end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"0" => { "value" => "Yes" },
"1" => { "value" => "No" },
})
end
it "has the correct hint" do
expect(question.hint_text).to eq("")
end
it "has the correct id" do
expect(question.id).to eq("age6_known")
end
it "has the correct header" do
expect(question.header).to eq("Do you know person 6’s age?")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("")
end
it "has correct conditional for" do
expect(question.conditional_for).to eq({
"age6" => [0],
})
end
it "has the correct hidden_in_check_answers" do
expect(question.hidden_in_check_answers).to eq(
{
"depends_on" => [
{
"age6_known" => 0,
},
{
"age6_known" => 1,
},
],
},
)
end
it "has the correct check_answers_card_number" do
expect(question.check_answers_card_number).to eq(6)
end
end

60
spec/models/form/lettings/questions/age6_spec.rb

@ -0,0 +1,60 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::Age6, type: :model do
subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { "age6" }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
it "has correct page" do
expect(question.page).to eq(page)
end
it "has the correct header" do
expect(question.header).to eq("Age")
end
it "has the correct type" do
expect(question.type).to eq("numeric")
end
it "is not marked as derived" do
expect(question.derived?).to be false
end
it "has the correct hint" do
expect(question.hint_text).to be_nil
end
it "has the correct min" do
expect(question.min).to eq(0)
end
it "has the correct max" do
expect(question.max).to eq(120)
end
it "has the correct id" do
expect(question.id).to eq("age6")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Person 6’s age")
end
it "has the correct width" do
expect(question.width).to eq(2)
end
it "has the correct inferred check answers value" do
expect(question.inferred_check_answers_value).to eq([{
"condition" => { "age6_known" => 1 },
"value" => "Not known",
}])
end
it "has the correct check_answers_card_number" do
expect(question.check_answers_card_number).to eq(6)
end
end

73
spec/models/form/lettings/questions/age7_known_spec.rb

@ -0,0 +1,73 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::Age7Known, type: :model do
subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { "age7_known" }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
before do
allow(page).to receive(:id).and_return("age7_known")
end
it "has correct page" do
expect(question.page).to eq(page)
end
it "has the correct type" do
expect(question.type).to eq("radio")
end
it "is not marked as derived" do
expect(question.derived?).to be false
end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"0" => { "value" => "Yes" },
"1" => { "value" => "No" },
})
end
it "has the correct hint" do
expect(question.hint_text).to eq("")
end
it "has the correct id" do
expect(question.id).to eq("age7_known")
end
it "has the correct header" do
expect(question.header).to eq("Do you know person 7’s age?")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("")
end
it "has correct conditional for" do
expect(question.conditional_for).to eq({
"age7" => [0],
})
end
it "has the correct hidden_in_check_answers" do
expect(question.hidden_in_check_answers).to eq(
{
"depends_on" => [
{
"age7_known" => 0,
},
{
"age7_known" => 1,
},
],
},
)
end
it "has the correct check_answers_card_number" do
expect(question.check_answers_card_number).to eq(7)
end
end

60
spec/models/form/lettings/questions/age7_spec.rb

@ -0,0 +1,60 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::Age7, type: :model do
subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { "age7" }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
it "has correct page" do
expect(question.page).to eq(page)
end
it "has the correct header" do
expect(question.header).to eq("Age")
end
it "has the correct type" do
expect(question.type).to eq("numeric")
end
it "is not marked as derived" do
expect(question.derived?).to be false
end
it "has the correct hint" do
expect(question.hint_text).to be_nil
end
it "has the correct min" do
expect(question.min).to eq(0)
end
it "has the correct max" do
expect(question.max).to eq(120)
end
it "has the correct id" do
expect(question.id).to eq("age7")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Person 7’s age")
end
it "has the correct width" do
expect(question.width).to eq(2)
end
it "has the correct inferred check answers value" do
expect(question.inferred_check_answers_value).to eq([{
"condition" => { "age7_known" => 1 },
"value" => "Not known",
}])
end
it "has the correct check_answers_card_number" do
expect(question.check_answers_card_number).to eq(7)
end
end

73
spec/models/form/lettings/questions/age8_known_spec.rb

@ -0,0 +1,73 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::Age8Known, type: :model do
subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { "age8_known" }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
before do
allow(page).to receive(:id).and_return("age8_known")
end
it "has correct page" do
expect(question.page).to eq(page)
end
it "has the correct type" do
expect(question.type).to eq("radio")
end
it "is not marked as derived" do
expect(question.derived?).to be false
end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"0" => { "value" => "Yes" },
"1" => { "value" => "No" },
})
end
it "has the correct hint" do
expect(question.hint_text).to eq("")
end
it "has the correct id" do
expect(question.id).to eq("age8_known")
end
it "has the correct header" do
expect(question.header).to eq("Do you know person 8’s age?")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("")
end
it "has correct conditional for" do
expect(question.conditional_for).to eq({
"age8" => [0],
})
end
it "has the correct hidden_in_check_answers" do
expect(question.hidden_in_check_answers).to eq(
{
"depends_on" => [
{
"age8_known" => 0,
},
{
"age8_known" => 1,
},
],
},
)
end
it "has the correct check_answers_card_number" do
expect(question.check_answers_card_number).to eq(8)
end
end

60
spec/models/form/lettings/questions/age8_spec.rb

@ -0,0 +1,60 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::Age8, type: :model do
subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { "age8" }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
it "has correct page" do
expect(question.page).to eq(page)
end
it "has the correct header" do
expect(question.header).to eq("Age")
end
it "has the correct type" do
expect(question.type).to eq("numeric")
end
it "is not marked as derived" do
expect(question.derived?).to be false
end
it "has the correct hint" do
expect(question.hint_text).to be_nil
end
it "has the correct min" do
expect(question.min).to eq(0)
end
it "has the correct max" do
expect(question.max).to eq(120)
end
it "has the correct id" do
expect(question.id).to eq("age8")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Person 8’s age")
end
it "has the correct width" do
expect(question.width).to eq(2)
end
it "has the correct inferred check answers value" do
expect(question.inferred_check_answers_value).to eq([{
"condition" => { "age8_known" => 1 },
"value" => "Not known",
}])
end
it "has the correct check_answers_card_number" do
expect(question.check_answers_card_number).to eq(8)
end
end
Loading…
Cancel
Save