spec/creditsafe/client_spec.rb in creditsafe-0.5.2 vs spec/creditsafe/client_spec.rb in creditsafe-0.6.0

- old
+ new

@@ -134,14 +134,18 @@ let(:client) { described_class.new(username: username, password: password) } let(:country_code) { "GB" } let(:registration_number) { "RN123" } let(:city) { nil } let(:postal_code) { nil } + let(:company_name) { nil } + let(:vat_number) { nil } let(:search_criteria) do { country_code: country_code, registration_number: registration_number, + company_name: company_name, + vat_number: vat_number, city: city, postal_code: postal_code, }.reject { |_, v| v.nil? } end @@ -192,11 +196,13 @@ it { is_expected.to_not raise_error } end end context "with a company name" do - let(:search_criteria) { { country_code: "FR", company_name: "Mimes Inc" } } + let(:country_code) { "FR" } + let(:registration_number) { nil } + let(:company_name) { "Mimes Inc" } it { is_expected.to_not raise_error } it "selects a valid match type for the country code" do find_company @@ -209,17 +215,65 @@ expect(request).to have_been_made end end + context "with a vat_number" do + let(:vat_number) { "942404110" } + let(:registration_number) { nil } + + it { is_expected.to raise_error(ArgumentError) } + + context "in US" do + let(:country_code) { "US" } + + it { is_expected.to_not raise_error } + end + end + + context "with different invalid required criteria combinations used" do + context "with registration number and company name" do + let(:company_name) { "Mimes Inc" } + + it { is_expected.to raise_error(ArgumentError) } + end + + context "with registration number and vat_number" do + let(:vat_number) { "942404110" } + + it { is_expected.to raise_error(ArgumentError) } + end + + context "with company name and vat_number" do + let(:registration_number) { nil } + let(:company_name) { "Mimes Inc" } + let(:vat_number) { "942404110" } + + it { is_expected.to raise_error(ArgumentError) } + end + + context "with all three required criteria" do + let(:company_name) { "Mimes Inc" } + let(:vat_number) { "942404110" } + + it { is_expected.to raise_error(ArgumentError) } + end + + context "with no required criteria" do + let(:registration_number) { nil } + + it { is_expected.to raise_error(ArgumentError) } + end + end + it "requests the company deatils" do find_company expect(a_request(:post, URL).with do |req| expect(CompareXML.equivalent?( Nokogiri::XML(req.body), load_xml_fixture("find-companies-request.xml"), verbose: true, - )).to eq([]) + )).to eq([]) end).to have_been_made end it "returns the company details" do expect(find_company).