Skip to content

Commit

Permalink
Valvat::Lookup specs: Use less brittle country services and skip on d…
Browse files Browse the repository at this point in the history
…own services
  • Loading branch information
yolk committed Jul 30, 2013
1 parent ee7acc0 commit 3e0ce72
Showing 1 changed file with 33 additions and 22 deletions.
55 changes: 33 additions & 22 deletions spec/valvat/lookup_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,33 @@

context "with details" do
it "returns hash of details instead of true" do
Valvat::Lookup.validate("IE6388047V", :detail => true).should eql({
:country_code=>"IE",
:vat_number=>"6388047V",
:request_date=> Date.today,
:name=>"GOOGLE IRELAND LIMITED",
:address=>"1ST & 2ND FLOOR ,GORDON HOUSE ,BARROW STREET ,DUBLIN 4"
})
result = Valvat::Lookup.validate("IE6388047V", :detail => true)

Valvat::Lookup.validate("LU21416127", :detail => true).should eql({
:country_code=>"LU",
:vat_number=>"21416127",
:request_date=> Date.today,
:name=>"EBAY EUROPE S.A R.L.",
:address=>"22, BOULEVARD ROYAL\nL-2449 LUXEMBOURG"
})
if result
result.should eql({
:country_code=>"IE",
:vat_number=>"6388047V",
:request_date=> Date.today,
:name=>"GOOGLE IRELAND LIMITED",
:address=>"1ST & 2ND FLOOR ,GORDON HOUSE ,BARROW STREET ,DUBLIN 4"
})
else
puts "Skipping IE vies lookup spec; result = #{result.inspect}"
end

result = Valvat::Lookup.validate("LU21416127", :detail => true)

if result
result.should eql({
:country_code=>"LU",
:vat_number=>"21416127",
:request_date=> Date.today,
:name=>"EBAY EUROPE S.A R.L.",
:address=>"22, BOULEVARD ROYAL\nL-2449 LUXEMBOURG"
})
else
puts "Skipping LU vies lookup spec; result = #{result.inspect}"
end
end

it "still returns false on not existing vat number" do
Expand All @@ -54,17 +66,16 @@

context "with request identifier" do
it "returns hash of details instead of true" do
response = Valvat::Lookup.validate("LU21416127", :requester_vat => "IE6388047V")
response = Valvat::Lookup.validate("DE259597697", :requester_vat => "IE6388047V")
response[:request_identifier].size.should eql(16)
response[:request_identifier] = "some_uniq_string"
request_identifier = response[:request_identifier]
response.should eql({
:country_code=>"LU",
:vat_number=>"21416127",
:country_code=>"DE",
:vat_number=>"259597697",
:request_date=> Date.today,
:name => "EBAY EUROPE S.A R.L.",
:address => "22, BOULEVARD ROYAL\nL-2449 LUXEMBOURG",
:company_type => nil,
:request_identifier => "some_uniq_string"
:name => nil,
:company_type=>nil,
:request_identifier=> request_identifier
})
end
end
Expand Down

0 comments on commit 3e0ce72

Please sign in to comment.