diff --git a/spec/wizards/placements/add_placement/steps/phase_spec.rb b/spec/wizards/placements/add_placement/steps/phase_spec.rb index 827ce2ccfe..cc025a154f 100644 --- a/spec/wizards/placements/add_placement/steps/phase_spec.rb +++ b/spec/wizards/placements/add_placement/steps/phase_spec.rb @@ -9,34 +9,38 @@ it { is_expected.to validate_presence_of(:school) } it { is_expected.to validate_presence_of(:phase) } - context "when the phase is primary" do - it "is valid" do - step = described_class.new(school: create(:placements_school), phase: "Primary") + context "when validating the phase" do + let(:school) { build(:placements_school) } - expect(step).to be_valid + context "and the phase is primary" do + it "is valid" do + step = described_class.new(school:, phase: "Primary") + + expect(step).to be_valid + end end - end - context "when the phase is secondary" do - it "is valid" do - step = described_class.new(school: create(:placements_school), phase: "Secondary") + context "and the phase is secondary" do + it "is valid" do + step = described_class.new(school:, phase: "Secondary") - expect(step).to be_valid + expect(step).to be_valid + end end - end - context "when the is not primary or secondary" do - it "is invalid" do - step = described_class.new(school: create(:placements_school), phase: "Nursery") + context "and the phase is not primary or secondary" do + it "is invalid" do + step = described_class.new(school:, phase: "Nursery") - expect(step).not_to be_valid + expect(step).not_to be_valid + end end end end describe "#phases_for_selection" do it "returns primary and secondary phases" do - step = described_class.new(school: create(:placements_school)) + step = described_class.new(school: build(:placements_school)) expect(step.phases_for_selection).to eq({ primary: "Primary", secondary: "Secondary" }) end @@ -44,7 +48,7 @@ describe "#wizard_attributes" do it "returns the phase" do - step = described_class.new(school: create(:placements_school), phase: "Primary") + step = described_class.new(school: build(:placements_school), phase: "Primary") expect(step.wizard_attributes).to eq({ phase: "Primary" }) end