spec/valvat/lookup_spec.rb in valvat-0.6.4 vs spec/valvat/lookup_spec.rb in valvat-0.6.5
- old
+ new
@@ -6,21 +6,21 @@
it "returns true" do
result = Valvat::Lookup.validate("LU21416127")
unless result.nil?
- result.should eql(true)
+ expect(result).to eql(true)
else
puts "Skipping LU vies lookup spec"
end
end
it "allows Valvat instance as input" do
result = Valvat::Lookup.validate(Valvat.new("LU21416127"))
unless result.nil?
- result.should eql(true)
+ expect(result).to eql(true)
else
puts "Skipping LU vies lookup spec"
end
end
end
@@ -28,33 +28,33 @@
context "not existing vat number" do
it "returns false" do
result = Valvat::Lookup.validate("LU21416128")
unless result.nil?
- result.should eql(false)
+ expect(result).to eql(false)
else
puts "Skipping LU vies lookup spec"
end
end
end
context "invalid country code / input" do
without_any_web_requests!
it "returns false" do
- Valvat::Lookup.validate("AE259597697").should eql(false)
- Valvat::Lookup.validate("").should eql(false)
+ expect(Valvat::Lookup.validate("AE259597697")).to eql(false)
+ expect(Valvat::Lookup.validate("")).to eql(false)
end
end
context "with details" do
it "returns hash of details instead of true" do
result = Valvat::Lookup.validate("IE6388047V", :detail => true)
if result
- result.delete(:request_date).should be_kind_of(Date)
- result.should eql({
+ expect(result.delete(:request_date)).to be_kind_of(Date)
+ expect(result).to eql({
:country_code=>"IE",
:vat_number=>"6388047V",
:name=>"GOOGLE IRELAND LIMITED",
:address=>"3RD FLOOR ,GORDON HOUSE ,BARROW STREET ,DUBLIN 4"
})
@@ -63,12 +63,12 @@
end
result = Valvat::Lookup.validate("LU21416127", :detail => true)
if result
- result.delete(:request_date).should be_kind_of(Date)
- result.should eql({
+ expect(result.delete(:request_date)).to be_kind_of(Date)
+ expect(result).to eql({
:country_code=>"LU",
:vat_number=>"21416127",
:name=>"EBAY EUROPE S.A R.L.",
:address=>"22, BOULEVARD ROYAL\nL-2449 LUXEMBOURG"
})
@@ -79,11 +79,11 @@
it "still returns false on not existing vat number" do
result = Valvat::Lookup.validate("LU21416128", :detail => true)
unless result.nil?
- result.should eql(false)
+ expect(result).to eql(false)
else
puts "Skipping LU vies lookup spec"
end
end
end
@@ -91,14 +91,14 @@
context "with request identifier" do
it "returns hash of details instead of true" do
response = Valvat::Lookup.validate("LU21416127", :requester_vat => "IE6388047V")
if response
- response[:request_identifier].size.should eql(16)
+ expect(response[:request_identifier].size).to eql(16)
request_identifier = response[:request_identifier]
- response.delete(:request_date).should be_kind_of(Date)
- response.should eql({
+ expect(response.delete(:request_date)).to be_kind_of(Date)
+ expect(response).to eql({
:country_code=>"LU",
:vat_number=>"21416127",
:name => "EBAY EUROPE S.A R.L.",
:company_type=>nil,
:address => "22, BOULEVARD ROYAL\nL-2449 LUXEMBOURG",
@@ -111,19 +111,19 @@
end
context "error on request" do
before do
@request = double("request")
- Valvat::Lookup::Request.stub(:new => @request)
- @request.stub(:perform).and_raise(ArgumentError.new)
+ allow(Valvat::Lookup::Request).to receive_messages(:new => @request)
+ allow(@request).to receive(:perform).and_raise(ArgumentError.new)
end
it "should return nil" do
- Valvat::Lookup.validate("LU21416127").should eql(nil)
+ expect(Valvat::Lookup.validate("LU21416127")).to eql(nil)
end
it "should raise error with raise_error option" do
- lambda {Valvat::Lookup.validate("LU21416127", :raise_error => true)}.should raise_error(ArgumentError)
+ expect {Valvat::Lookup.validate("LU21416127", :raise_error => true)}.to raise_error(ArgumentError)
end
end
# TODO : Reactivate with coorect "down" response
# context "country web service down" do