spec/valvat/lookup_spec.rb in valvat-1.1.4 vs spec/valvat/lookup_spec.rb in valvat-1.1.5
- old
+ new
@@ -34,10 +34,11 @@
end
context 'with details' do
let(:details) do
{
+ '@xmlns:ns2': 'urn:ec.europa.eu:taxud:vies:services:checkVat:types',
country_code: 'IE',
vat_number: '6388047V',
name: 'GOOGLE IRELAND LIMITED',
address: '3RD FLOOR, GORDON HOUSE, BARROW STREET, DUBLIN 4',
valid: true
@@ -62,10 +63,11 @@
context 'with request identifier' do
let(:response) { described_class.validate('IE6388047V', requester: 'IE6388047V') }
let(:details) do
{
+ '@xmlns:ns2': 'urn:ec.europa.eu:taxud:vies:services:checkVat:types',
country_code: 'IE',
vat_number: '6388047V',
name: 'GOOGLE IRELAND LIMITED',
company_type: nil,
address: '3RD FLOOR, GORDON HOUSE, BARROW STREET, DUBLIN 4',
@@ -130,11 +132,11 @@
describe 'Error : SERVICE_UNAVAILABLE' do
subject(:result) { described_class.validate('DE300', options) }
it 'returns nil' do
- expect(result).to be(nil)
+ expect(result).to be_nil
end
it 'raises error with raise_error: true' do
expect do
described_class.validate('DE300', options.merge(raise_error: true))
@@ -144,11 +146,11 @@
describe 'Error : MS_UNAVAILABLE' do
subject(:result) { described_class.validate('DE301', options) }
it 'returns nil' do
- expect(result).to be(nil)
+ expect(result).to be_nil
end
it 'raises error with raise_error: true' do
expect do
described_class.validate('DE301', options.merge(raise_error: true))
@@ -162,11 +164,11 @@
it 'raises error' do
expect { result }.to raise_error(Valvat::Timeout)
end
it 'returns nil with raise_error set to false' do
- expect(described_class.validate('DE302', options.merge(raise_error: false))).to be(nil)
+ expect(described_class.validate('DE302', options.merge(raise_error: false))).to be_nil
end
end
describe 'Error : VAT_BLOCKED' do
subject(:result) { described_class.validate('DE400', options) }
@@ -174,11 +176,11 @@
it 'raises error' do
expect { result }.to raise_error(Valvat::BlockedError, /VAT_BLOCKED/)
end
it 'returns nil with raise_error set to false' do
- expect(described_class.validate('DE400', options.merge(raise_error: false))).to be(nil)
+ expect(described_class.validate('DE400', options.merge(raise_error: false))).to be_nil
end
end
describe 'Error : IP_BLOCKED' do
subject(:result) { described_class.validate('DE401', options) }
@@ -186,11 +188,11 @@
it 'raises error' do
expect { result }.to raise_error(Valvat::BlockedError, /IP_BLOCKED/)
end
it 'returns nil with raise_error set to false' do
- expect(described_class.validate('DE401', options.merge(raise_error: false))).to be(nil)
+ expect(described_class.validate('DE401', options.merge(raise_error: false))).to be_nil
end
end
describe 'Error : GLOBAL_MAX_CONCURRENT_REQ' do
subject(:result) { described_class.validate('DE500', options) }
@@ -198,11 +200,11 @@
it 'raises error' do
expect { result }.to raise_error(Valvat::RateLimitError, /GLOBAL_MAX_CONCURRENT_REQ/)
end
it 'returns nil with raise_error set to false' do
- expect(described_class.validate('DE500', options.merge(raise_error: false))).to be(nil)
+ expect(described_class.validate('DE500', options.merge(raise_error: false))).to be_nil
end
end
describe 'Error : GLOBAL_MAX_CONCURRENT_REQ_TIME' do
subject(:result) { described_class.validate('DE501', options) }
@@ -210,11 +212,11 @@
it 'raises error' do
expect { result }.to raise_error(Valvat::RateLimitError, /GLOBAL_MAX_CONCURRENT_REQ_TIME/)
end
it 'returns nil with raise_error set to false' do
- expect(described_class.validate('DE501', options.merge(raise_error: false))).to be(nil)
+ expect(described_class.validate('DE501', options.merge(raise_error: false))).to be_nil
end
end
describe 'Error : MS_MAX_CONCURRENT_REQ' do
subject(:result) { described_class.validate('DE600', options) }
@@ -222,11 +224,11 @@
it 'raises error' do
expect { result }.to raise_error(Valvat::RateLimitError, /MS_MAX_CONCURRENT_REQ/)
end
it 'returns nil with raise_error set to false' do
- expect(described_class.validate('DE600', options.merge(raise_error: false))).to be(nil)
+ expect(described_class.validate('DE600', options.merge(raise_error: false))).to be_nil
end
end
describe 'Error : MS_MAX_CONCURRENT_REQ_TIME' do
subject(:result) { described_class.validate('DE601', options) }
@@ -234,44 +236,46 @@
it 'raises error' do
expect { result }.to raise_error(Valvat::RateLimitError, /MS_MAX_CONCURRENT_REQ_TIME/)
end
it 'returns nil with raise_error set to false' do
- expect(described_class.validate('DE601', options.merge(raise_error: false))).to be(nil)
+ expect(described_class.validate('DE601', options.merge(raise_error: false))).to be_nil
end
end
describe 'Error : Savon::UnknownOperationError' do
+ subject(:result) { described_class.validate('DE601', options) }
+
before do
- dbl = double(Savon::Client)
+ dbl = instance_double(Savon::Client)
allow(Savon::Client).to receive(:new).and_return(dbl)
allow(dbl).to receive(:call).and_raise(Savon::UnknownOperationError.new('from stub'))
end
- subject(:result) { described_class.validate('DE601', options) }
it 'raises error' do
expect { result }.to raise_error(Valvat::OperationUnknown, /#<Savon::UnknownOperationError: from stub>/)
end
it 'returns nil with raise_error set to false' do
- expect(described_class.validate('DE601', options.merge(raise_error: false))).to be(nil)
+ expect(described_class.validate('DE601', options.merge(raise_error: false))).to be_nil
end
end
describe 'Error : Savon::HTTPError' do
+ subject(:result) { described_class.validate('DE601', options) }
+
before do
- dbl = double(Savon::Client)
+ dbl = instance_double(Savon::Client)
allow(Savon::Client).to receive(:new).and_return(dbl)
allow(dbl).to receive(:call).and_raise(Savon::HTTPError.new(Struct.new(:code, :body).new(403, 'from stub')))
end
- subject(:result) { described_class.validate('DE601', options) }
it 'raises error' do
expect { result }.to raise_error(Valvat::HTTPError, /#<Savon::HTTPError: HTTP error \(403\): from stub>/)
end
it 'returns nil with raise_error set to false' do
- expect(described_class.validate('DE601', options.merge(raise_error: false))).to be(nil)
+ expect(described_class.validate('DE601', options.merge(raise_error: false))).to be_nil
end
end
end
end