Skip to content

Commit

Permalink
ap-5097: Attempt to clarify specs by specifying opening or closing cu…
Browse files Browse the repository at this point in the history
…rly quotes

Attempt to clarify spec descriptions by specifying whether it is testing
replacement of opening or closing curly quotes
  • Loading branch information
kmahern authored and naseberry committed Jul 23, 2024
1 parent c793aaf commit 560b1e8
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
<msg:Client>
<client:Name xmlns:client="http://legalservices.gov.uk/CCMS/ClientManagement/Client/1.0/ClientBIO">
<common:Title xmlns:common="http://legalservices.gov.uk/Enterprise/Common/1.0/Common">MRS.</common:Title>
<common:Surname xmlns:common="http://legalservices.gov.uk/Enterprise/Common/1.0/Common">O''Hare</common:Surname>
<common:Surname xmlns:common="http://legalservices.gov.uk/Enterprise/Common/1.0/Common">O'Hare</common:Surname>
<common:FirstName xmlns:common="http://legalservices.gov.uk/Enterprise/Common/1.0/Common">lenovo</common:FirstName>
<common:SurnameAtBirth xmlns:common="http://legalservices.gov.uk/Enterprise/Common/1.0/Common">O''Hare</common:SurnameAtBirth>
<common:FullName xmlns:common="http://legalservices.gov.uk/Enterprise/Common/1.0/Common">lenovo O''Hare</common:FullName>
<common:SurnameAtBirth xmlns:common="http://legalservices.gov.uk/Enterprise/Common/1.0/Common">O'Hare</common:SurnameAtBirth>
<common:FullName xmlns:common="http://legalservices.gov.uk/Enterprise/Common/1.0/Common">lenovo O'Hare</common:FullName>
</client:Name>
<client:DateOfBirth xmlns:client="http://legalservices.gov.uk/CCMS/ClientManagement/Client/1.0/ClientBIO">1972-01-01</client:DateOfBirth>
<client:Gender xmlns:client="http://legalservices.gov.uk/CCMS/ClientManagement/Client/1.0/ClientBIO">FEMALE</client:Gender>
Expand Down
44 changes: 32 additions & 12 deletions spec/services/ccms/parsers/applicant_search_response_parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,21 +97,41 @@ module Parsers
end
end

context "and the applicant's surname contains a special character" do
let(:parser) { described_class.new(expected_tx_id, ccms_data_from_file("applicant_search_responses/special_characters_match.xml"), applicant) }
let(:applicant) { create(:applicant, first_name: "lenovo", last_name: "O’‘Hare", date_of_birth: Date.new(1972, 1, 1), national_insurance_number: "QQ123456A") }

it "extracts the number of records fetched" do
expect(parser.record_count).to eq "1"
context "and the applicant's name contains a special character" do
context "and the applicant's last name contains an opening curly quote" do
let(:parser) { described_class.new(expected_tx_id, ccms_data_from_file("applicant_search_responses/special_characters_match.xml"), applicant) }
let(:applicant) { create(:applicant, first_name: "lenovo", last_name: "O‘Hare", date_of_birth: Date.new(1972, 1, 1), national_insurance_number: "QQ123456A") }

it "extracts the number of records fetched" do
expect(parser.record_count).to eq "1"
end

it "returns the applicant_ccms_reference" do
expect(parser.applicant_ccms_reference).to eq "4390016"
end

it "expects logger to receive" do
expect(Rails.logger).to receive(:info).with("CCMS::Parsers::ApplicantSearchResponseParser:: CCMS records returned: 1, Full matches: 1, ChosenMatch: 4390016")
parser.applicant_ccms_reference
end
end

it "returns the applicant_ccms_reference" do
expect(parser.applicant_ccms_reference).to eq "4390016"
end
context "and the applicant's last name contains an closing curly quote" do
let(:parser) { described_class.new(expected_tx_id, ccms_data_from_file("applicant_search_responses/special_characters_match.xml"), applicant) }
let(:applicant) { create(:applicant, first_name: "lenovo", last_name: "O’Hare", date_of_birth: Date.new(1972, 1, 1), national_insurance_number: "QQ123456A") }

it "expects logger to receive" do
expect(Rails.logger).to receive(:info).with("CCMS::Parsers::ApplicantSearchResponseParser:: CCMS records returned: 1, Full matches: 1, ChosenMatch: 4390016")
parser.applicant_ccms_reference
it "extracts the number of records fetched" do
expect(parser.record_count).to eq "1"
end

it "returns the applicant_ccms_reference" do
expect(parser.applicant_ccms_reference).to eq "4390016"
end

it "expects logger to receive" do
expect(Rails.logger).to receive(:info).with("CCMS::Parsers::ApplicantSearchResponseParser:: CCMS records returned: 1, Full matches: 1, ChosenMatch: 4390016")
parser.applicant_ccms_reference
end
end
end
end
Expand Down
68 changes: 48 additions & 20 deletions spec/services/ccms/requestors/applicant_add_requestor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,28 +134,56 @@ module Requestors
end
end

context "when the applicant has a surname containing special characters" do
before do
applicant.update!(last_name: "O’‘Hare")
context "when the applicant has a name containing special characters" do
context "when the last name contains an opening single curly quote" do
before do
applicant.update!(last_name: "O‘Hare")
end

it "generates the expected XML" do
allow(requestor).to receive(:transaction_request_id).and_return(expected_tx_id)
expect(requestor.formatted_xml).to be_soap_envelope_with(
command: "clientbim:ClientAddRQ",
transaction_id: expected_tx_id,
matching: [
"<common:Surname>O'Hare</common:Surname>",
"<common:SurnameAtBirth>O'Hare</common:SurnameAtBirth>",
"<clientbio:NINumber>QQ123456Q</clientbio:NINumber>",
"<common:AddressLine1>102 Petty France</common:AddressLine1>",
"<common:AddressLine2>St James Park</common:AddressLine2>",
"<common:City>London</common:City>",
"<common:County>Westminster</common:County>",
"<common:Country>GBR</common:Country>",
"<common:PostalCode>SW1H 9AJ</common:PostalCode>",
],
)
end
end

it "generates the expected XML" do
allow(requestor).to receive(:transaction_request_id).and_return(expected_tx_id)
expect(requestor.formatted_xml).to be_soap_envelope_with(
command: "clientbim:ClientAddRQ",
transaction_id: expected_tx_id,
matching: [
"<common:Surname>O''Hare</common:Surname>",
"<common:SurnameAtBirth>O''Hare</common:SurnameAtBirth>",
"<clientbio:NINumber>QQ123456Q</clientbio:NINumber>",
"<common:AddressLine1>102 Petty France</common:AddressLine1>",
"<common:AddressLine2>St James Park</common:AddressLine2>",
"<common:City>London</common:City>",
"<common:County>Westminster</common:County>",
"<common:Country>GBR</common:Country>",
"<common:PostalCode>SW1H 9AJ</common:PostalCode>",
],
)
context "when the first name contains a closing single curly quote" do
before do
applicant.update!(first_name: "L’Novo")
end

it "generates the expected XML" do
allow(requestor).to receive(:transaction_request_id).and_return(expected_tx_id)
expect(requestor.formatted_xml).to be_soap_envelope_with(
command: "clientbim:ClientAddRQ",
transaction_id: expected_tx_id,
matching: [
"<common:Surname>Hurlock</common:Surname>",
"<common:FirstName>L'Novo</common:FirstName>",
"<common:SurnameAtBirth>Hurlock</common:SurnameAtBirth>",
"<clientbio:NINumber>QQ123456Q</clientbio:NINumber>",
"<common:AddressLine1>102 Petty France</common:AddressLine1>",
"<common:AddressLine2>St James Park</common:AddressLine2>",
"<common:City>London</common:City>",
"<common:County>Westminster</common:County>",
"<common:Country>GBR</common:Country>",
"<common:PostalCode>SW1H 9AJ</common:PostalCode>",
],
)
end
end
end
end
Expand Down
48 changes: 35 additions & 13 deletions spec/services/ccms/requestors/applicant_search_requestor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,25 +51,47 @@ module Requestors
end
end

context "when the applicant has a surname containing special characters" do
context "when the applicant has a name containing a special character" do
let(:applicant) do
create(:applicant,
first_name: "lenovo",
last_name: "O’‘Hare",
first_name:,
last_name:,
date_of_birth: Date.new(1969, 1, 1),
national_insurance_number: "YS327299B")
end

it "generates the expected XML" do
allow(requestor).to receive(:transaction_request_id).and_return(expected_tx_id)
expect(requestor.formatted_xml).to be_soap_envelope_with(
command: "clientbim:ClientInqRQ",
transaction_id: expected_tx_id,
matching: %w[
<clientbio:Surname>O''Hare</clientbio:Surname>
<clientbio:FirstName>lenovo</clientbio:FirstName>
],
)
context "when the last name contains an opening single curly quote" do
let(:last_name) { "O‘Hare" }
let(:first_name) { "lenovo" }

it "generates the expected XML" do
allow(requestor).to receive(:transaction_request_id).and_return(expected_tx_id)
expect(requestor.formatted_xml).to be_soap_envelope_with(
command: "clientbim:ClientInqRQ",
transaction_id: expected_tx_id,
matching: %w[
<clientbio:Surname>O'Hare</clientbio:Surname>
<clientbio:FirstName>lenovo</clientbio:FirstName>
],
)
end
end

context "when the first name contains an closing single curly quote" do
let(:last_name) { "hurlock" }
let(:first_name) { "l’novo" }

it "generates the expected XML" do
allow(requestor).to receive(:transaction_request_id).and_return(expected_tx_id)
expect(requestor.formatted_xml).to be_soap_envelope_with(
command: "clientbim:ClientInqRQ",
transaction_id: expected_tx_id,
matching: %w[
<clientbio:Surname>hurlock</clientbio:Surname>
<clientbio:FirstName>l'novo</clientbio:FirstName>
],
)
end
end
end
end
Expand Down

0 comments on commit 560b1e8

Please sign in to comment.