ibandit 0.11.14 → 0.11.15

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3060e96d5d67d57e9759c68bfd68b4174b65291c
4
- data.tar.gz: 259f05d4b483b3fc7d96fa22c9904301063ad8fc
3
+ metadata.gz: a159dff483326ad700b9d6c2348be9a36b6eb9fd
4
+ data.tar.gz: a3ebcafd962ddad867a8d8103840dd2e6514e1bf
5
5
  SHA512:
6
- metadata.gz: b9c623c432caaefd6aa60fbbf63f3c75380e7723f71164b21d3d6279b71a7416b96b7812932673b24cf09d849d3dfc2106792527e12f47836f4c14f294fbc305
7
- data.tar.gz: 6244f013565d3f83c28f8d4d244a80b1fc89d8cd533607f02ac919331e1bba02ea79e5f3576274fc990bc34ee078d2cfcca53a3d973f0158ab76ae04ebc7f776
6
+ metadata.gz: ca3965ca8a619cf55fe945a3209d59f7c3f2381b6e3512539c21f31e8676470f2952fc1ad8a594e453518bc7498a28de6dc5b2641bb2e76c03382f4a7344b030
7
+ data.tar.gz: f12360f3a4cc08548b40263e16d2962f97a90d23d4a0ca4bbd3533d2c902fcb5aa267032f52dabb821ca484e5142982dcc8cf5c885fe6164a9aa06e876148653
@@ -1,3 +1,7 @@
1
+ ## 0.11.15 - August 30, 2018
2
+
3
+ - Validate New Zealand branch codes
4
+
1
5
  ## 0.11.14 - July 26, 2018
2
6
 
3
7
  - Add support for NZ pseudo-IBANs
@@ -282,6 +282,7 @@ module Ibandit
282
282
  when "DE" then supports_iban_determination?
283
283
  when "SE" then valid_swedish_details?
284
284
  when "AU" then valid_australian_details?
285
+ when "NZ" then valid_nz_details?
285
286
  else true
286
287
  end
287
288
  end
@@ -354,6 +355,13 @@ module Ibandit
354
355
  true
355
356
  end
356
357
 
358
+ def valid_nz_details?
359
+ return true unless country_code == "NZ"
360
+ return true unless Ibandit.modulus_checker
361
+
362
+ valid_modulus_check_branch_code?
363
+ end
364
+
357
365
  def valid_australian_details?
358
366
  return true unless country_code == "AU"
359
367
 
@@ -1,3 +1,3 @@
1
1
  module Ibandit
2
- VERSION = "0.11.14".freeze
2
+ VERSION = "0.11.15".freeze
3
3
  end
@@ -1952,6 +1952,108 @@ describe Ibandit::IBAN do
1952
1952
  end
1953
1953
  end
1954
1954
 
1955
+ describe "valid_nz_details" do
1956
+ subject { iban.valid_nz_details? }
1957
+
1958
+ context "with non-NewZealand details" do
1959
+ let(:arg) do
1960
+ {
1961
+ country_code: "GB",
1962
+ bank_code: "1234",
1963
+ branch_code: "200000",
1964
+ account_number: "55779911",
1965
+ }
1966
+ end
1967
+
1968
+ it { is_expected.to be(true) }
1969
+ end
1970
+
1971
+ context "with NewZealand details" do
1972
+ let(:arg) do
1973
+ {
1974
+ country_code: "NZ",
1975
+ bank_code: "01",
1976
+ branch_code: "0004",
1977
+ account_number: "123456789",
1978
+ }
1979
+ end
1980
+
1981
+ context "without a modulus checker defined" do
1982
+ it { is_expected.to be(true) }
1983
+ end
1984
+
1985
+ context "with a modulus checker defined" do
1986
+ before do
1987
+ Ibandit.modulus_checker = double(
1988
+ valid_branch_code?: valid_branch_code,
1989
+ )
1990
+ iban.valid_nz_details?
1991
+ end
1992
+ after { Ibandit.modulus_checker = nil }
1993
+
1994
+ let(:valid_branch_code) { true }
1995
+
1996
+ it "calls valid_branch_code? with an IBAN object" do
1997
+ expect(Ibandit.modulus_checker).
1998
+ to receive(:valid_branch_code?).
1999
+ with(instance_of(Ibandit::IBAN))
2000
+
2001
+ iban.valid_nz_details?
2002
+ end
2003
+
2004
+ it { is_expected.to be(true) }
2005
+
2006
+ context "with an invalid branch code" do
2007
+ let(:valid_branch_code) { false }
2008
+
2009
+ it { is_expected.to be(false) }
2010
+
2011
+ context "locale en", locale: :en do
2012
+ specify do
2013
+ expect(iban.errors).to include(branch_code: "is invalid")
2014
+ end
2015
+ end
2016
+
2017
+ context "locale fr", locale: :fr do
2018
+ specify do
2019
+ expect(iban.errors).to include(branch_code: "est invalide")
2020
+ end
2021
+ end
2022
+
2023
+ context "locale de", locale: :de do
2024
+ specify do
2025
+ expect(iban.errors).to include(branch_code: "ist nicht gültig")
2026
+ end
2027
+ end
2028
+
2029
+ context "locale pt", locale: :pt do
2030
+ specify do
2031
+ expect(iban.errors).to include(branch_code: "é inválido")
2032
+ end
2033
+ end
2034
+
2035
+ context "locale es", locale: :es do
2036
+ specify do
2037
+ expect(iban.errors).to include(branch_code: "es inválido")
2038
+ end
2039
+ end
2040
+
2041
+ context "locale it", locale: :it do
2042
+ specify do
2043
+ expect(iban.errors).to include(branch_code: "non è valido")
2044
+ end
2045
+ end
2046
+
2047
+ context "locale nl", locale: :nl do
2048
+ specify do
2049
+ expect(iban.errors).to include(branch_code: "is ongeldig")
2050
+ end
2051
+ end
2052
+ end
2053
+ end
2054
+ end
2055
+ end
2056
+
1955
2057
  describe "#valid?" do
1956
2058
  describe "validations called" do
1957
2059
  after { iban.valid? }
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: 0.11.14
4
+ version: 0.11.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - GoCardless
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-27 00:00:00.000000000 Z
11
+ date: 2018-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri