iban_calculator 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/iban_calculator/version.rb +1 -1
- data/lib/iban_calculator.rb +9 -2
- data/spec/iban_calculator_spec.rb +14 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 179e94a9310e590bdbe6b16fb6f3fa6e49535c5d
|
4
|
+
data.tar.gz: 5b727e33c86f8a30b724ea6435b47d0258731497
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33bcc32cc39d265627e8bac2d04abc4f29f2ec6d14e7dd062e55e77f2999f3184fa16da203e7a4fc101ca5f6df9eedfb61f90d126fd34380ff8db2180deb4c1e
|
7
|
+
data.tar.gz: 9ff76bf3659848efd836707db1e5bc391c9fe12c41f5482f29a0dbc3c2c09f2519bb3211db41432ddb1943778f740e66fa247387f76310dd6697c6e47b78fc11
|
data/CHANGELOG.md
CHANGED
data/lib/iban_calculator.rb
CHANGED
@@ -28,8 +28,15 @@ module IbanCalculator
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def self.validate_iban(iban)
|
31
|
-
|
32
|
-
response = client.call(:validate_iban, message: { iban: iban, user: config.user, password: config.password })
|
31
|
+
response = execute(:validate_iban, iban: iban, user: config.user, password: config.password)
|
33
32
|
IbanValidatorResponse.new(response.body[:validate_iban_response][:return])
|
34
33
|
end
|
34
|
+
|
35
|
+
def self.execute(method, options = {})
|
36
|
+
client = Savon.client(wsdl: config.url, logger: config.logger)
|
37
|
+
client.call(method, message: options).tap do |response|
|
38
|
+
status = response.body[:"#{method}_response"][:return][:result]
|
39
|
+
fail(ServiceError, status) unless status == 'passed'
|
40
|
+
end
|
41
|
+
end
|
35
42
|
end
|
@@ -48,4 +48,18 @@ describe IbanCalculator do
|
|
48
48
|
IbanCalculator.logger = old_logger
|
49
49
|
end
|
50
50
|
end
|
51
|
+
|
52
|
+
|
53
|
+
describe '.execute' do
|
54
|
+
context 'invalid username and password' do
|
55
|
+
let(:error_message) { 'User someone, password test: invalid username-password combination' }
|
56
|
+
let(:response) { { failing_response: { return: { result: error_message } } } }
|
57
|
+
|
58
|
+
before { allow_any_instance_of(Savon::Client).to receive(:call) { double(body: response) } }
|
59
|
+
|
60
|
+
it 'raises a generic exception' do
|
61
|
+
expect { IbanCalculator.execute(:failing) }.to raise_error(IbanCalculator::ServiceError, error_message)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
51
65
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iban_calculator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maximilian Schulz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|