ibandit 1.2.1 → 1.4.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.
@@ -2,5 +2,6 @@
2
2
 
3
3
  module Ibandit
4
4
  class InvalidCharacterError < StandardError; end
5
+
5
6
  class UnsupportedAccountDetails < StandardError; end
6
7
  end
@@ -307,7 +307,7 @@ module Ibandit
307
307
  end
308
308
 
309
309
  def sum_of_weighted_values
310
- weighted_values.reduce(0, &:+)
310
+ weighted_values.sum
311
311
  end
312
312
 
313
313
  def weighted_values
@@ -550,7 +550,7 @@ module Ibandit
550
550
  end
551
551
 
552
552
  def sum_of_weighted_digits
553
- weighted_digits.reduce(0, &:+)
553
+ weighted_digits.sum
554
554
  end
555
555
 
556
556
  def weighted_digits
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ibandit
4
- VERSION = "1.2.1"
4
+ VERSION = "1.4.1"
5
5
  end
@@ -134,7 +134,7 @@
134
134
  {
135
135
  "convertor": "001400",
136
136
  "valid": [
137
- { "bank_code": "10090603", "account_number": "60624", "converted_bank_code": "30060601" }
137
+ { "bank_code": "30060601", "account_number": "60624", "converted_bank_code": "30060601" }
138
138
  ]
139
139
  },
140
140
  {
@@ -11,7 +11,7 @@ describe Ibandit::IBANAssembler do
11
11
  account_number: iban.swift_account_number,
12
12
  branch_code: iban.swift_branch_code,
13
13
  bank_code: iban.swift_bank_code,
14
- }.reject { |_key, value| value.nil? }
14
+ }.compact
15
15
  end
16
16
 
17
17
  it "successfully reconstructs the IBAN" do
@@ -422,7 +422,7 @@ describe Ibandit::IBAN do
422
422
  its(:swift_bank_code) { is_expected.to eq("0036") }
423
423
  its(:swift_branch_code) { is_expected.to eq("00063") }
424
424
  its(:swift_account_number) { is_expected.to eq("000000123456") }
425
- its(:swift_national_id) { is_expected.to eq("0036") }
425
+ its(:swift_national_id) { is_expected.to eq("003600063") }
426
426
  its(:pseudo_iban) { is_expected.to eq("CAZZ003600063000000123456") }
427
427
 
428
428
  its(:iban) { is_expected.to be_nil }
@@ -441,7 +441,7 @@ describe Ibandit::IBAN do
441
441
  its(:swift_bank_code) { is_expected.to eq("36") }
442
442
  its(:swift_branch_code) { is_expected.to eq("00063") }
443
443
  its(:swift_account_number) { is_expected.to eq("000000123456") }
444
- its(:swift_national_id) { is_expected.to eq("3600") }
444
+ its(:swift_national_id) { is_expected.to eq("3600063") }
445
445
  its(:pseudo_iban) { is_expected.to eq("CAZZ__3600063000000123456") }
446
446
 
447
447
  its(:iban) { is_expected.to be_nil }
@@ -460,7 +460,7 @@ describe Ibandit::IBAN do
460
460
  its(:swift_bank_code) { is_expected.to eq("0036") }
461
461
  its(:swift_branch_code) { is_expected.to eq("00063") }
462
462
  its(:swift_account_number) { is_expected.to eq("000000123456") }
463
- its(:swift_national_id) { is_expected.to eq("0036") }
463
+ its(:swift_national_id) { is_expected.to eq("003600063") }
464
464
  its(:pseudo_iban) { is_expected.to eq("CAZZ003600063000000123456") }
465
465
 
466
466
  its(:iban) { is_expected.to be_nil }
@@ -486,7 +486,7 @@ describe Ibandit::IBAN do
486
486
  its(:swift_bank_code) { is_expected.to eq("0036") }
487
487
  its(:swift_branch_code) { is_expected.to eq("00063") }
488
488
  its(:swift_account_number) { is_expected.to eq("012345678900") }
489
- its(:swift_national_id) { is_expected.to eq("0036") }
489
+ its(:swift_national_id) { is_expected.to eq("003600063") }
490
490
  its(:pseudo_iban) { is_expected.to eq("CAZZ003600063012345678900") }
491
491
 
492
492
  its(:iban) { is_expected.to be_nil }
@@ -3132,7 +3132,7 @@ describe Ibandit::IBAN do
3132
3132
  end
3133
3133
 
3134
3134
  context "for a valid Belgian IBAN" do
3135
- let(:iban_code) { "BE62 5100 0754 7061" }
3135
+ let(:iban_code) { "BE68 5390 0754 7034" }
3136
3136
 
3137
3137
  it { is_expected.to be_valid }
3138
3138
  end
@@ -3179,6 +3179,18 @@ describe Ibandit::IBAN do
3179
3179
  it { is_expected.to_not be_valid }
3180
3180
  end
3181
3181
 
3182
+ context "for a valid Costa Rican IBAN" do
3183
+ let(:iban_code) { "CR05 0152 0200 1026 2840 66" }
3184
+
3185
+ it { is_expected.to be_valid }
3186
+ end
3187
+
3188
+ context "for an invalid Costa Rican IBAN" do
3189
+ let(:iban_code) { "CR05 0152 0200 1026 2840" }
3190
+
3191
+ it { is_expected.to_not be_valid }
3192
+ end
3193
+
3182
3194
  context "for a valid Cypriot IBAN" do
3183
3195
  let(:iban_code) { "CY17 0020 0128 0000 0012 0052 7600" }
3184
3196
 
@@ -3215,6 +3227,18 @@ describe Ibandit::IBAN do
3215
3227
  it { is_expected.to_not be_valid }
3216
3228
  end
3217
3229
 
3230
+ context "for a valid Dominican Republic IBAN" do
3231
+ let(:iban_code) { "DO28 BAGR 0000 0001 2124 5361 1324" }
3232
+
3233
+ it { is_expected.to be_valid }
3234
+ end
3235
+
3236
+ context "for an invalid Dominican Republic IBAN" do
3237
+ let(:iban_code) { "DO28 BAGR 0000 0001 2124 5361" }
3238
+
3239
+ it { is_expected.to_not be_valid }
3240
+ end
3241
+
3218
3242
  context "for a valid Estonian IBAN" do
3219
3243
  let(:iban_code) { "EE38 2200 2210 2014 5685" }
3220
3244
 
@@ -3599,6 +3623,18 @@ describe Ibandit::IBAN do
3599
3623
  it { is_expected.to_not be_valid }
3600
3624
  end
3601
3625
 
3626
+ context "for a valid Palestinian IBAN" do
3627
+ let(:iban_code) { "PS92 PALS 0000 0000 0400 1234 5670 2" }
3628
+
3629
+ it { is_expected.to be_valid }
3630
+ end
3631
+
3632
+ context "for an invalid Palestinian IBAN" do
3633
+ let(:iban_code) { "PS92 PALS 0000 0000 0400 1234 5670" }
3634
+
3635
+ it { is_expected.to_not be_valid }
3636
+ end
3637
+
3602
3638
  context "for a valid Potuguese IBAN" do
3603
3639
  let(:iban_code) { "PT50 0002 0123 1234 5678 9015 4" }
3604
3640
 
@@ -3623,6 +3659,30 @@ describe Ibandit::IBAN do
3623
3659
  it { is_expected.to_not be_valid }
3624
3660
  end
3625
3661
 
3662
+ context "for a valid Kosovan IBAN" do
3663
+ let(:iban_code) { "XK05 1212 0123 4567 8906" }
3664
+
3665
+ it { is_expected.to be_valid }
3666
+ end
3667
+
3668
+ context "for an invalid Kosovan IBAN" do
3669
+ let(:iban_code) { "XK05 1212 0123 4567 890" }
3670
+
3671
+ it { is_expected.to_not be_valid }
3672
+ end
3673
+
3674
+ context "for a valid Timor-Leste IBAN" do
3675
+ let(:iban_code) { "TL38 0080 0123 4567 8910 157" }
3676
+
3677
+ it { is_expected.to be_valid }
3678
+ end
3679
+
3680
+ context "for an invalid Timor-Leste IBAN" do
3681
+ let(:iban_code) { "TL38 0080 0123 4567 8910" }
3682
+
3683
+ it { is_expected.to_not be_valid }
3684
+ end
3685
+
3626
3686
  context "for a valid Romanian IBAN" do
3627
3687
  let(:iban_code) { "RO49 AAAA 1B31 0075 9384 0000" }
3628
3688
 
@@ -3778,6 +3838,114 @@ describe Ibandit::IBAN do
3778
3838
 
3779
3839
  it { is_expected.to_not be_valid }
3780
3840
  end
3841
+
3842
+ context "with a valid LC iban" do
3843
+ let(:iban_code) { "LC55 HEMM 0001 0001 0012 0012 0002 3015" }
3844
+
3845
+ it { is_expected.to be_valid }
3846
+ end
3847
+
3848
+ context "with an invalid LC iban" do
3849
+ let(:iban_code) { "LC55 HEMM 0001 0001 0012 0012 0002" }
3850
+
3851
+ it { is_expected.to_not be_valid }
3852
+ end
3853
+
3854
+ context "with a valid UA iban" do
3855
+ let(:iban_code) { "UA21 3223 1300 0002 6007 2335 6600 1" }
3856
+
3857
+ it { is_expected.to be_valid }
3858
+ end
3859
+
3860
+ context "with an invalid UA iban" do
3861
+ let(:iban_code) { "UA21 3223 1300 0002 6007 2335 6600 " }
3862
+
3863
+ it { is_expected.to_not be_valid }
3864
+ end
3865
+
3866
+ context "with a valid ST iban" do
3867
+ let(:iban_code) { "ST23 0001 0001 0051 8453 1014 6" }
3868
+
3869
+ it { is_expected.to be_valid }
3870
+ end
3871
+
3872
+ context "with an invalid ST iban" do
3873
+ let(:iban_code) { "ST23 0001 0001 0051 8453 1014" }
3874
+
3875
+ it { is_expected.to_not be_valid }
3876
+ end
3877
+
3878
+ context "with a valid SC iban" do
3879
+ let(:iban_code) { "SC18 SSCB 1101 0000 0000 0000 1497 USD" }
3880
+
3881
+ it { is_expected.to be_valid }
3882
+ end
3883
+
3884
+ context "with an invalid SC iban" do
3885
+ let(:iban_code) { "SC18 SSCB 1101 0000 0000 0000 USD" }
3886
+
3887
+ it { is_expected.to_not be_valid }
3888
+ end
3889
+
3890
+ context "with a valid IQ iban" do
3891
+ let(:iban_code) { "IQ98 NBIQ 8501 2345 6789 012" }
3892
+
3893
+ it { is_expected.to be_valid }
3894
+ end
3895
+
3896
+ context "with an invalid IQ iban" do
3897
+ let(:iban_code) { "IQ98 NBIQ 8501 2345 6789" }
3898
+
3899
+ it { is_expected.to_not be_valid }
3900
+ end
3901
+
3902
+ context "with a valid SV iban" do
3903
+ let(:iban_code) { "SV 62 CENR 00000000000000700025" }
3904
+
3905
+ it { is_expected.to be_valid }
3906
+ end
3907
+
3908
+ context "with an invalid SV iban" do
3909
+ let(:iban_code) { "SV 62 CENR 00000000000000700" }
3910
+
3911
+ it { is_expected.to_not be_valid }
3912
+ end
3913
+
3914
+ context "with a valid BY iban" do
3915
+ let(:iban_code) { "BY13 NBRB 3600 9000 0000 2Z00 AB00" }
3916
+
3917
+ it { is_expected.to be_valid }
3918
+ end
3919
+
3920
+ context "with an invalid BY iban" do
3921
+ let(:iban_code) { "BY13 NBRB 3600 9000 0000 2Z00" }
3922
+
3923
+ it { is_expected.to_not be_valid }
3924
+ end
3925
+
3926
+ context "with a valid VA iban" do
3927
+ let(:iban_code) { "VA59 001 1230 0001 2345 678" }
3928
+
3929
+ it { is_expected.to be_valid }
3930
+ end
3931
+
3932
+ context "with an invalid VA iban" do
3933
+ let(:iban_code) { "VA59 001 1230 0001 2345" }
3934
+
3935
+ it { is_expected.to_not be_valid }
3936
+ end
3937
+
3938
+ context "with a valid EG iban" do
3939
+ let(:iban_code) { "EG380019000500000000263180002" }
3940
+
3941
+ it { is_expected.to be_valid }
3942
+ end
3943
+
3944
+ context "with an invalid EG iban" do
3945
+ let(:iban_code) { "EG3800190005000000002631800" }
3946
+
3947
+ it { is_expected.to_not be_valid }
3948
+ end
3781
3949
  end
3782
3950
 
3783
3951
  describe "#local_check_digits" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ibandit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - GoCardless
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-01 00:00:00.000000000 Z
11
+ date: 2021-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gc_ruboconfig
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.17.0
19
+ version: 2.24.0
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 2.17.0
26
+ version: 2.24.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: nokogiri
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -149,6 +149,7 @@ files:
149
149
  - ".gitignore"
150
150
  - ".rubocop.yml"
151
151
  - ".rubocop_todo.yml"
152
+ - ".ruby-version"
152
153
  - CHANGELOG.md
153
154
  - Gemfile
154
155
  - LICENSE
@@ -224,7 +225,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
224
225
  - !ruby/object:Gem::Version
225
226
  version: '0'
226
227
  requirements: []
227
- rubygems_version: 3.0.3
228
+ rubygems_version: 3.2.3
228
229
  signing_key:
229
230
  specification_version: 4
230
231
  summary: Convert national banking details into IBANs, and vice-versa.