Browse Source

refactor to ensure that the questions ownershipsch instance variable and the value of ownershipsch on the log is the same in tests

pull/2470/head
Arthur Campbell 2 years ago
parent
commit
a7bc64aa89
  1. 12
      spec/models/form/sales/questions/mortgageused_spec.rb

12
spec/models/form/sales/questions/mortgageused_spec.rb

@ -1,13 +1,15 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::Mortgageused, type: :model do
subject(:question) { described_class.new(question_id, question_definition, page, ownershipsch: 1) }
subject(:question) { described_class.new(question_id, question_definition, page, ownershipsch:) }
let(:ownershipsch) { 1 }
let(:question_id) { nil }
let(:question_definition) { nil }
let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) }
let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form:)) }
let(:log) { build(:sales_log) }
let(:stairowned) { nil }
let(:log) { build(:sales_log, ownershipsch:, stairowned:) }
it "has the correct answer_options" do
expect(question.answer_options).to eq({
@ -18,7 +20,7 @@ RSpec.describe Form::Sales::Questions::Mortgageused, type: :model do
end
context "when staircase owned percentage is 100%" do
let(:log) { build(:sales_log, stairowned: 100) }
let(:stairowned) { 100 }
it "shows the don't know option" do
expect(question.displayed_answer_options(log)).to eq({
@ -30,7 +32,7 @@ RSpec.describe Form::Sales::Questions::Mortgageused, type: :model do
end
context "when an outright sale" do
subject(:question) { described_class.new(question_id, question_definition, page, ownershipsch: 3) }
let(:ownershipsch) { 3 }
it "shows the don't know option" do
expect(question.displayed_answer_options(log)).to eq({
@ -42,7 +44,7 @@ RSpec.describe Form::Sales::Questions::Mortgageused, type: :model do
end
context "when staircase owned percentage is less than 100%" do
let(:log) { build(:sales_log, stairowned: 99) }
let(:stairowned) { 99 }
it "shows the don't know option" do
expect(question.displayed_answer_options(log)).to eq({

Loading…
Cancel
Save