spec/valvat/lookup_spec.rb in valvat-0.6.1 vs spec/valvat/lookup_spec.rb in valvat-0.6.2

- old
+ new

@@ -3,21 +3,39 @@ describe Valvat::Lookup do describe "#validate" do context "existing vat number" do it "returns true" do - Valvat::Lookup.validate("DE259597697").should eql(true) + result = Valvat::Lookup.validate("LU21416127") + + unless result.nil? + result.should eql(true) + else + puts "Skipping LU vies lookup spec" + end end it "allows Valvat instance as input" do - Valvat::Lookup.validate(Valvat.new("DE259597697")).should eql(true) + result = Valvat::Lookup.validate(Valvat.new("LU21416127")) + + unless result.nil? + result.should eql(true) + else + puts "Skipping LU vies lookup spec" + end end end context "not existing vat number" do it "returns false" do - Valvat::Lookup.validate("DE259597696").should eql(false) + result = Valvat::Lookup.validate("LU21416128") + + unless result.nil? + result.should eql(false) + else + puts "Skipping LU vies lookup spec" + end end end context "invalid country code / input" do without_any_web_requests! @@ -58,26 +76,38 @@ puts "Skipping LU vies lookup spec; result = #{result.inspect}" end end it "still returns false on not existing vat number" do - Valvat::Lookup.validate("DE259597696", :detail => true).should eql(false) + result = Valvat::Lookup.validate("LU21416128", :detail => true) + + unless result.nil? + result.should eql(false) + else + puts "Skipping LU vies lookup spec" + end end end context "with request identifier" do it "returns hash of details instead of true" do - response = Valvat::Lookup.validate("DE259597697", :requester_vat => "IE6388047V") - response[:request_identifier].size.should eql(16) - request_identifier = response[:request_identifier] - response.delete(:request_date).should be_kind_of(Date) - response.should eql({ - :country_code=>"DE", - :vat_number=>"259597697", - :name => nil, - :company_type=>nil, - :request_identifier=> request_identifier - }) + response = Valvat::Lookup.validate("LU21416127", :requester_vat => "IE6388047V") + + if response + response[:request_identifier].size.should eql(16) + request_identifier = response[:request_identifier] + response.delete(:request_date).should be_kind_of(Date) + response.should eql({ + :country_code=>"LU", + :vat_number=>"21416127", + :name => "EBAY EUROPE S.A R.L.", + :company_type=>nil, + :address => "22, BOULEVARD ROYAL\nL-2449 LUXEMBOURG", + :request_identifier=> request_identifier + }) + else + puts "Skipping LU vies lookup spec" + end end end context "error on request" do before do