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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3967a9c57971d2941311ac3669ab2b440f1e4aed
4
- data.tar.gz: e639752002e485025b6255f9592a62b9900ee763
3
+ metadata.gz: 179e94a9310e590bdbe6b16fb6f3fa6e49535c5d
4
+ data.tar.gz: 5b727e33c86f8a30b724ea6435b47d0258731497
5
5
  SHA512:
6
- metadata.gz: 57c403612b7adb97f2240c89411186d186c35c30f7c027580b06be44fd42b19ee394a2dbbb8157556f5e31986a6be9f8018c8a14b90941698316290fe4df931f
7
- data.tar.gz: 6ab47c60821c888040d2989a2c22817cf23a22dd4a6731a9cfbe9440961b95f8baec156824b374e5607751ab3f438ae20f49b394bb0b4d6e73fef3aa9fe392c7
6
+ metadata.gz: 33bcc32cc39d265627e8bac2d04abc4f29f2ec6d14e7dd062e55e77f2999f3184fa16da203e7a4fc101ca5f6df9eedfb61f90d126fd34380ff8db2180deb4c1e
7
+ data.tar.gz: 9ff76bf3659848efd836707db1e5bc391c9fe12c41f5482f29a0dbc3c2c09f2519bb3211db41432ddb1943778f740e66fa247387f76310dd6697c6e47b78fc11
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ 0.0.3
2
+ -----
3
+
4
+ * Raise an exception when an unexpected response is returned (i.e. invalid user and password)
5
+
1
6
  0.0.2
2
7
  -----
3
8
 
@@ -1,3 +1,3 @@
1
1
  module IbanCalculator
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -28,8 +28,15 @@ module IbanCalculator
28
28
  end
29
29
 
30
30
  def self.validate_iban(iban)
31
- client = Savon.client(wsdl: config.url, logger: config.logger)
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.2
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-08-11 00:00:00.000000000 Z
11
+ date: 2014-09-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport