valvat 1.1.5 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,34 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe Valvat::Lookup::Fault do
6
- it "returns {valid: false} on fault 'INVALID_INPUT'" do
7
- expect(described_class.new({
8
- fault: { faultstring: 'INVALID_INPUT' }
9
- }).to_hash).to eql({ valid: false })
10
- end
11
-
12
- {
13
- 'SERVICE_UNAVAILABLE' => Valvat::ServiceUnavailable,
14
- 'MS_UNAVAILABLE' => Valvat::MemberStateUnavailable,
15
- 'INVALID_REQUESTER_INFO' => Valvat::InvalidRequester,
16
- 'TIMEOUT' => Valvat::Timeout,
17
- 'VAT_BLOCKED' => Valvat::BlockedError,
18
- 'IP_BLOCKED' => Valvat::BlockedError,
19
- 'GLOBAL_MAX_CONCURRENT_REQ' => Valvat::RateLimitError,
20
- 'GLOBAL_MAX_CONCURRENT_REQ_TIME' => Valvat::RateLimitError,
21
- 'MS_MAX_CONCURRENT_REQ' => Valvat::RateLimitError,
22
- 'MS_MAX_CONCURRENT_REQ_TIME' => Valvat::RateLimitError,
23
- 'ANYTHING ELSE' => Valvat::UnknownViesError,
24
- 'REALLY ANYTHING' => Valvat::UnknownViesError
25
- }.each do |fault, error|
26
- it "returns error on fault '#{fault}'" do
27
- expect(described_class.new({
28
- fault: { faultstring: fault }
29
- }).to_hash).to eql({
30
- error: error.new(fault)
31
- })
32
- end
33
- end
34
- end
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe Valvat::Lookup::Request do
6
- it 'returns Response on success' do
7
- response = described_class.new('IE6388047V', {}).perform
8
- expect(response).to be_a(Valvat::Lookup::Response)
9
-
10
- # Skip if VIES is down
11
- expect(response.to_hash[:name]).to eql('GOOGLE IRELAND LIMITED') unless response.is_a?(Valvat::Lookup::Fault)
12
- end
13
-
14
- it 'returns Fault on failure' do
15
- response = described_class.new('XC123123', {}).perform
16
- expect(response).to be_a(Valvat::Lookup::Fault)
17
- expect(response.to_hash).to eql({ valid: false })
18
- end
19
-
20
- context 'when Savon::UnknownOperationError is (wrongly) thrown' do
21
- before do
22
- dbl = instance_double(Savon::Client)
23
- allow(Savon::Client).to receive(:new).and_return(dbl)
24
- allow(dbl).to receive(:call).and_raise(Savon::UnknownOperationError.new('from stub'))
25
- end
26
-
27
- it 'does handle it like vies down' do
28
- response = described_class.new('IE6388047V', {}).perform
29
- expect(response.to_hash[:error]).to be_a(Valvat::OperationUnknown)
30
- end
31
- end
32
- end
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe Valvat::Lookup::Response do
6
- it 'removes @xmlns from :check_vat_response hash' do
7
- expect(described_class.new({
8
- check_vat_response: { :a => 1, :b => 2, :@xmlns => true }
9
- }).to_hash).to eql({ a: 1, b: 2 })
10
- end
11
-
12
- it "removes 'trader_'-Prefixes :check_vat_response hash" do
13
- expect(described_class.new({
14
- check_vat_response: { a: 1, trader_b: 2 }
15
- }).to_hash).to eql({ a: 1, b: 2 })
16
- end
17
-
18
- it 'accepts hash keyed as :check_vat_approx_response' do
19
- expect(described_class.new({
20
- check_vat_approx_response: { a: 1, b: 2 }
21
- }).to_hash).to eql({ a: 1, b: 2 })
22
- end
23
-
24
- it 'allows direct access to hash via []' do
25
- expect(described_class.new({
26
- check_vat_response: { a: 123, b: 2 }
27
- })[:a]).to be(123)
28
- end
29
- end