From de9f0dac0bb6ed3227859bbb6c7607f35c87593b Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire Date: Tue, 16 May 2023 10:53:29 +0100 Subject: [PATCH] test: add main tests --- .../sales/year2023/row_parser_spec.rb | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/spec/services/bulk_upload/sales/year2023/row_parser_spec.rb b/spec/services/bulk_upload/sales/year2023/row_parser_spec.rb index 4d337ffeb..f6e9632c6 100644 --- a/spec/services/bulk_upload/sales/year2023/row_parser_spec.rb +++ b/spec/services/bulk_upload/sales/year2023/row_parser_spec.rb @@ -156,6 +156,9 @@ RSpec.describe BulkUpload::Sales::Year2023::RowParser do stub_request(:get, "https://api.os.uk/search/places/v1/uprn?key=OS_DATA_KEY&uprn=100023336956") .to_return(status: 200, body:, headers: {}) + stub_request(:get, "https://api.os.uk/search/places/v1/uprn?key=OS_DATA_KEY&uprn=2") + .to_return(status: 404, body:, headers: {}) + parser.valid? end @@ -564,10 +567,20 @@ RSpec.describe BulkUpload::Sales::Year2023::RowParser do ].each do |data| describe "##{data[:field]} (#{data[:name]})" do context "when UPRN present" do - let(:attributes) { setup_section_params.merge({ field_19: "100023336956", data[:field] => nil }) } + context "when UPRN valid" do + let(:attributes) { setup_section_params.merge({ field_19: "100023336956", data[:field] => nil }) } + + it "can be blank" do + expect(parser.errors[data[:field]]).to be_blank + end + end + + context "when UPRN invalid" do + let(:attributes) { setup_section_params.merge({ field_19: "2", data[:field] => nil }) } - it "can be blank" do - expect(parser.errors[data[:field]]).to be_blank + it "cannot be blank" do + expect(parser.errors[data[:field]]).not_to be_blank + end end end