sepa_king 0.12.0 → 0.14.0

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
  SHA256:
3
- metadata.gz: 50a8c2ef19885186d039b8f47eec9b27074dfe71917ad3dbee6ed164f4410169
4
- data.tar.gz: f0220baed094637316211e1e2b5dc5fc57dfc6ec11211881f73c59561d4df565
3
+ metadata.gz: bbdd7991d9da595e8a78eef4ede917a4bf96f425305da1ea0f908e9c04c23750
4
+ data.tar.gz: 5ac2d38ed83dec60f68ea9f70b8be7bd16e01385457c41f58f15dc00990e07a9
5
5
  SHA512:
6
- metadata.gz: c0a3ab450bca76dd5889866129d3e5172ce7d7b51cfb1f329709d01a510c14ef30a4ad3114b968ec406510f5360149518f1905adfd4e2784cbfd0d06c27a11a1
7
- data.tar.gz: 4ff86a20f750668a273248ae3ab60928f22ccbc25f195678ad6c6afaa39df5006a2dcf7cd0fef6a2fe18c2f91dea364e19f66f1ab57f84ae9f378ee4bdf0a78e
6
+ metadata.gz: 10dd0ce9bae0413cc3ed0d65b470fc8f0911bd4035cc19a3a4505a88d6076ee552b1c0d4cd8e8d0d0ab9542a9d42eb717418d43a7e5c6ad5212fab2d4d042123
7
+ data.tar.gz: a27678581e7f3d371d47fe58ad77b9245bade4d05adaa69dd1ec0425efb253fb4db8f624f77e5ce2cbf18b9000e429614b4068b61fa466e46a9d347a03ccd75b
@@ -0,0 +1,50 @@
1
+ name: Test
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+
7
+ jobs:
8
+ test:
9
+ runs-on: ubuntu-latest
10
+
11
+ strategy:
12
+ fail-fast: false
13
+ matrix:
14
+ ruby: [ '2.7', '3.0', '3.1' ]
15
+ rails: [ '4.2', '5.0', '5.1', '5.2', '6.0', '6.1', '7.0' ]
16
+ exclude:
17
+ - ruby: '2.7'
18
+ rails: '4.2'
19
+ - ruby: '3.0'
20
+ rails: '4.2'
21
+ - ruby: '3.0'
22
+ rails: '5.0'
23
+ - ruby: '3.0'
24
+ rails: '5.1'
25
+ - ruby: '3.0'
26
+ rails: '5.2'
27
+ - ruby: '3.1'
28
+ rails: '4.2'
29
+ - ruby: '3.1'
30
+ rails: '5.0'
31
+ - ruby: '3.1'
32
+ rails: '5.1'
33
+ - ruby: '3.1'
34
+ rails: '5.2'
35
+
36
+ name: Ruby ${{ matrix.ruby }} / Rails ${{ matrix.rails }}
37
+ env:
38
+ BUNDLE_GEMFILE: gemfiles/Gemfile-activemodel-${{ matrix.rails }}.x
39
+
40
+ steps:
41
+ - uses: actions/checkout@v3
42
+
43
+ - name: Setup Ruby
44
+ uses: ruby/setup-ruby@v1
45
+ with:
46
+ ruby-version: ${{ matrix.ruby }}
47
+ bundler-cache: true # 'bundle install' and cache gems
48
+
49
+ - name: RSpec
50
+ run: bundle exec rake
data/.gitignore CHANGED
@@ -4,6 +4,6 @@ coverage/*
4
4
  rdoc/*
5
5
  pkg/*
6
6
  .DS_Store
7
- Gemfile.lock
7
+ Gemfile*.lock
8
8
  # tmp disable
9
9
  docs/
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013-2019 Georg Leciejewski (Sales King GmbH) & Georg Ledermann
1
+ Copyright (c) 2013-2022 Georg Leciejewski (Sales King GmbH) & Georg Ledermann
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -1,10 +1,9 @@
1
1
  # Ruby gem for creating SEPA XML files
2
2
 
3
- [![Build Status](https://travis-ci.org/salesking/sepa_king.svg)](http://travis-ci.org/salesking/sepa_king)
3
+ [![Build Status](https://github.com/salesking/sepa_king/workflows/Test/badge.svg?branch=master)](https://github.com/salesking/sepa_king/actions)
4
4
  [![Code Climate](https://codeclimate.com/github/salesking/sepa_king/badges/gpa.svg)](https://codeclimate.com/github/salesking/sepa_king)
5
5
  [![Coverage Status](https://coveralls.io/repos/salesking/sepa_king/badge.svg?branch=master)](https://coveralls.io/r/salesking/sepa_king?branch=master)
6
6
  [![Gem Version](https://badge.fury.io/rb/sepa_king.svg)](http://badge.fury.io/rb/sepa_king)
7
- [![Dependency Status](https://gemnasium.com/salesking/sepa_king.svg)](https://gemnasium.com/salesking/sepa_king)
8
7
 
9
8
  We love building payment applications! So after developing the [DTAUS library for Ruby](https://github.com/salesking/king_dtaus) we move on with SEPA.
10
9
 
@@ -16,15 +15,15 @@ This gem implements the following two messages out of the ISO 20022 standard:
16
15
  * Credit Transfer Initiation (`pain.001.003.03`, `pain.001.002.03` and `pain.001.001.03`)
17
16
  * Direct Debit Initiation (`pain.008.003.02`, `pain.008.002.02` and `pain.008.001.02`)
18
17
 
19
- It handles the _Specification of Data Formats_ v2.7 (2013-11-04).
18
+ It handles the _Specification of Data Formats_ v3.3 (2019-11-17).
20
19
 
21
20
  BTW: **pain** is a shortcut for **Pa**yment **In**itiation.
22
21
 
23
22
 
24
23
  ## Requirements
25
24
 
26
- * Ruby 2.2 or newer
27
- * ActiveModel 3.1 or newer (including 6.0)
25
+ * Ruby 2.7 or newer
26
+ * ActiveModel 4.2 or newer (including 7.0)
28
27
 
29
28
 
30
29
  ## Installation
@@ -146,8 +145,8 @@ sdd.add_transaction(
146
145
  sdd.add_transaction ...
147
146
 
148
147
  # Last: create XML string
149
- xml_string = sdd.to_xml # Use latest schema pain.008.003.02
150
- xml_string = sdd.to_xml('pain.008.002.02') # Use former schema pain.008.002.02
148
+ xml_string = sdd.to_xml # Use schema pain.008.001.02
149
+ xml_string = sdd.to_xml('pain.008.002.02') # Use schema pain.008.002.02
151
150
  ```
152
151
 
153
152
 
@@ -237,8 +236,8 @@ sct.add_transaction(
237
236
  sct.add_transaction ...
238
237
 
239
238
  # Last: create XML string
240
- xml_string = sct.to_xml # Use latest schema pain.001.003.03
241
- xml_string = sct.to_xml('pain.001.002.03') # Use former schema pain.001.002.03
239
+ xml_string = sct.to_xml # Use schema pain.001.001.03
240
+ xml_string = sct.to_xml('pain.001.002.03') # Use schema pain.001.002.03
242
241
  ```
243
242
 
244
243
  ## Validations
@@ -286,7 +285,7 @@ https://github.com/salesking/sepa_king/graphs/contributors
286
285
 
287
286
  ## Resources
288
287
 
289
- * http://www.ebics.de/index.php?id=77
288
+ * https://www.ebics.de/de/datenformate
290
289
  * SalesKing: http://salesking.eu
291
290
 
292
291
 
@@ -294,4 +293,4 @@ https://github.com/salesking/sepa_king/graphs/contributors
294
293
 
295
294
  Released under the MIT license
296
295
 
297
- Copyright (c) 2013-2019 Georg Leciejewski (SalesKing), Georg Ledermann (https://github.com/ledermann)
296
+ Copyright (c) 2013-2022 Georg Leciejewski (SalesKing), Georg Ledermann (https://github.com/ledermann)
@@ -2,4 +2,4 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec path: '..'
4
4
 
5
- gem 'activemodel', '~>4.1.15'
5
+ gem 'activemodel', '~> 6.1.4'
@@ -2,4 +2,4 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec path: '..'
4
4
 
5
- gem 'activemodel', '~>3.1.12'
5
+ gem 'activemodel', '~> 7.0.1'
@@ -5,7 +5,7 @@ module SEPA
5
5
  self.account_class = DebtorAccount
6
6
  self.transaction_class = CreditTransferTransaction
7
7
  self.xml_main_tag = 'CstmrCdtTrfInitn'
8
- self.known_schemas = [ PAIN_001_003_03, PAIN_001_002_03, PAIN_001_001_03, PAIN_001_001_03_CH_02 ]
8
+ self.known_schemas = [ PAIN_001_001_03, PAIN_001_001_03_CH_02, PAIN_001_003_03, PAIN_001_002_03 ]
9
9
 
10
10
  private
11
11
  # Find groups of transactions which share the same values of some attributes
@@ -17,7 +17,7 @@ module SEPA
17
17
  }
18
18
  end
19
19
 
20
- def build_payment_informations(builder)
20
+ def build_payment_informations(builder, schema_name)
21
21
  # Build a PmtInf block for every group of transactions
22
22
  grouped_transactions.each do |group, transactions|
23
23
  # All transactions with the same requested_date are placed into the same PmtInf block
@@ -52,7 +52,7 @@ module SEPA
52
52
  builder.FinInstnId do
53
53
  if account.bic
54
54
  builder.BIC(account.bic)
55
- else
55
+ elsif schema_name != PAIN_001_001_03_CH_02
56
56
  builder.Othr do
57
57
  builder.Id('NOTPROVIDED')
58
58
  end
@@ -5,7 +5,7 @@ module SEPA
5
5
  self.account_class = CreditorAccount
6
6
  self.transaction_class = DirectDebitTransaction
7
7
  self.xml_main_tag = 'CstmrDrctDbtInitn'
8
- self.known_schemas = [ PAIN_008_003_02, PAIN_008_002_02, PAIN_008_001_02 ]
8
+ self.known_schemas = [ PAIN_008_001_02, PAIN_008_003_02, PAIN_008_002_02 ]
9
9
 
10
10
  validate do |record|
11
11
  if record.transactions.map(&:local_instrument).uniq.size > 1
@@ -24,7 +24,7 @@ module SEPA
24
24
  }
25
25
  end
26
26
 
27
- def build_payment_informations(builder)
27
+ def build_payment_informations(builder, schema_name)
28
28
  # Build a PmtInf block for every group of transactions
29
29
  grouped_transactions.each do |group, transactions|
30
30
  builder.PmtInf do
@@ -46,7 +46,7 @@ module SEPA
46
46
  builder.Document(xml_schema(schema_name)) do
47
47
  builder.__send__(xml_main_tag) do
48
48
  build_group_header(builder)
49
- build_payment_informations(builder)
49
+ build_payment_informations(builder, schema_name)
50
50
  end
51
51
  end
52
52
  end
@@ -63,9 +63,9 @@ module SEPA
63
63
  raise ArgumentError.new("Schema #{schema_name} is unknown!") unless self.known_schemas.include?(schema_name)
64
64
 
65
65
  case schema_name
66
- when PAIN_001_002_03, PAIN_008_002_02, PAIN_001_001_03, PAIN_001_001_03_CH_02
66
+ when PAIN_001_002_03, PAIN_008_002_02
67
67
  account.bic.present? && transactions.all? { |t| t.schema_compatible?(schema_name) }
68
- when PAIN_001_003_03, PAIN_008_003_02, PAIN_008_001_02
68
+ when PAIN_001_001_03, PAIN_001_001_03_CH_02, PAIN_001_003_03, PAIN_008_003_02, PAIN_008_001_02
69
69
  transactions.all? { |t| t.schema_compatible?(schema_name) }
70
70
  end
71
71
  end
@@ -75,7 +75,7 @@ module SEPA
75
75
  raise ArgumentError.new('message_identification must be a string!') unless value.is_a?(String)
76
76
 
77
77
  regex = /\A([A-Za-z0-9]|[\+|\?|\/|\-|\:|\(|\)|\.|\,|\'|\ ]){1,35}\z/
78
- raise ArgumentError.new("message_identification does not match #{regex}!") unless value.match(regex)
78
+ raise ArgumentError.new("message_identification does not match #{regex}!") unless value.match?(regex)
79
79
 
80
80
  @message_identification = value
81
81
  end
@@ -91,7 +91,7 @@ module SEPA
91
91
  raise ArgumentError.new('creation_date_time must be a string!') unless value.is_a?(String)
92
92
 
93
93
  regex = /[0-9]{4}[-][0-9]{2,2}[-][0-9]{2,2}(?:\s|T)[0-9]{2,2}[:][0-9]{2,2}[:][0-9]{2,2}/
94
- raise ArgumentError.new("creation_date_time does not match #{regex}!") unless value.match(regex)
94
+ raise ArgumentError.new("creation_date_time does not match #{regex}!") unless value.match?(regex)
95
95
 
96
96
  @creation_date_time = value
97
97
  end
@@ -161,7 +161,7 @@ module SEPA
161
161
  end
162
162
 
163
163
  def validate_final_document!(document, schema_name)
164
- xsd = Nokogiri::XML::Schema(File.read(File.expand_path("../../../lib/schema/#{schema_name}.xsd", __FILE__)))
164
+ xsd = Nokogiri::XML::Schema(File.read(File.expand_path("../../lib/schema/#{schema_name}.xsd", __dir__)))
165
165
  errors = xsd.validate(document).map { |error| error.message }
166
166
  raise SEPA::Error.new("Incompatible with schema #{schema_name}: #{errors.join(', ')}") if errors.any?
167
167
  end
@@ -8,7 +8,7 @@ module SEPA
8
8
  field_name = options[:field_name] || :iban
9
9
  value = record.send(field_name).to_s
10
10
 
11
- unless IBANTools::IBAN.valid?(value) && value.match(REGEX)
11
+ unless IBANTools::IBAN.valid?(value) && value.match?(REGEX)
12
12
  record.errors.add(field_name, :invalid, message: options[:message])
13
13
  end
14
14
  end
@@ -23,7 +23,7 @@ module SEPA
23
23
  value = record.send(field_name)
24
24
 
25
25
  if value
26
- unless value.to_s.match(REGEX)
26
+ unless value.to_s.match?(REGEX)
27
27
  record.errors.add(field_name, :invalid, message: options[:message])
28
28
  end
29
29
  end
@@ -31,7 +31,12 @@ module SEPA
31
31
  end
32
32
 
33
33
  class CreditorIdentifierValidator < ActiveModel::Validator
34
- REGEX = /\A[a-zA-Z]{2,2}[0-9]{2,2}([A-Za-z0-9]|[\+|\?|\/|\-|\:|\(|\)|\.|,|']){3,3}([A-Za-z0-9]|[\+|\?|\/|\-|:|\(|\)|\.|,|']){1,28}\z/
34
+ REGEX = %r{\A
35
+ [a-zA-Z]{2} # ISO country code
36
+ [0-9]{2} # Check digits
37
+ [A-Za-z0-9]{3} # Creditor business code
38
+ [A-Za-z0-9+?/:().,'-]{1,28} # National identifier
39
+ \z}x
35
40
 
36
41
  def validate(record)
37
42
  field_name = options[:field_name] || :creditor_identifier
@@ -43,9 +48,9 @@ module SEPA
43
48
  end
44
49
 
45
50
  def valid?(creditor_identifier)
46
- if ok = creditor_identifier.to_s.match(REGEX)
51
+ if ok = creditor_identifier.to_s.match?(REGEX)
47
52
  # In Germany, the identifier has to be exactly 18 chars long
48
- if creditor_identifier[0..1].match(/DE/i)
53
+ if creditor_identifier[0..1].match?(/DE/i)
49
54
  ok = creditor_identifier.length == 18
50
55
  end
51
56
  end
@@ -54,13 +59,13 @@ module SEPA
54
59
  end
55
60
 
56
61
  class MandateIdentifierValidator < ActiveModel::Validator
57
- REGEX = /\A([A-Za-z0-9]|[\+|\?|\/|\-|\:|\(|\)|\.|\,|\']){1,35}\z/
62
+ REGEX = %r{\A[A-Za-z0-9 +?/:().,'-]{1,35}\z}
58
63
 
59
64
  def validate(record)
60
65
  field_name = options[:field_name] || :mandate_id
61
66
  value = record.send(field_name)
62
67
 
63
- unless value.to_s.match(REGEX)
68
+ unless value.to_s.match?(REGEX)
64
69
  record.errors.add(field_name, :invalid, message: options[:message])
65
70
  end
66
71
  end
@@ -1,3 +1,3 @@
1
1
  module SEPA
2
- VERSION = '0.12.0'
2
+ VERSION = '0.14.0'
3
3
  end
data/sepa_king.gemspec CHANGED
@@ -1,5 +1,5 @@
1
1
  # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
2
+ lib = File.expand_path('lib', __dir__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'sepa_king/version'
5
5
 
@@ -7,25 +7,24 @@ Gem::Specification.new do |s|
7
7
  s.name = 'sepa_king'
8
8
  s.version = SEPA::VERSION
9
9
  s.authors = ['Georg Leciejewski', 'Georg Ledermann']
10
- s.email = ['gl@salesking.eu', 'mail@georg-ledermann.de']
11
- s.description = 'Implemention of pain.001.002.03 and pain.008.002.02 (ISO 20022)'
10
+ s.email = ['gl@salesking.eu', 'georg@ledermann.dev']
11
+ s.description = 'Implemention of Payments Initiation (ISO 20022)'
12
12
  s.summary = 'Ruby gem for creating SEPA XML files'
13
- s.homepage = 'http://github.com/salesking/sepa_king'
13
+ s.homepage = 'https://github.com/salesking/sepa_king'
14
14
  s.license = 'MIT'
15
15
 
16
16
  s.files = `git ls-files`.split($/)
17
- s.test_files = s.files.grep(%r{^(test|spec|features)/})
18
17
  s.require_paths = ['lib']
19
18
 
20
- s.required_ruby_version = '>= 2.2'
19
+ s.required_ruby_version = '>= 2.7'
21
20
 
22
- s.add_runtime_dependency 'activemodel', '>= 3.1'
21
+ s.add_runtime_dependency 'activemodel', '>= 4.2'
23
22
  s.add_runtime_dependency 'nokogiri'
24
23
  s.add_runtime_dependency 'iban-tools'
25
24
 
26
25
  s.add_development_dependency 'bundler'
27
26
  s.add_development_dependency 'rspec'
28
- s.add_development_dependency 'coveralls'
27
+ s.add_development_dependency 'coveralls_reborn'
29
28
  s.add_development_dependency 'simplecov'
30
29
  s.add_development_dependency 'rake'
31
30
  end
data/spec/account_spec.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require 'spec_helper'
3
3
 
4
- describe SEPA::Account do
4
+ RSpec.describe SEPA::Account do
5
5
  describe :new do
6
6
  it 'should not accept unknown keys' do
7
7
  expect {
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require 'spec_helper'
3
3
 
4
- describe SEPA::Converter do
4
+ RSpec.describe SEPA::Converter do
5
5
  include SEPA::Converter::InstanceMethods
6
6
 
7
7
  describe :convert_text do
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require 'spec_helper'
3
3
 
4
- describe SEPA::CreditTransfer do
4
+ RSpec.describe SEPA::CreditTransfer do
5
5
  let(:message_id_regex) { /SEPA-KING\/[0-9a-z_]{22}/ }
6
6
  let(:credit_transfer) {
7
7
  SEPA::CreditTransfer.new name: 'Schuldner GmbH',
@@ -38,7 +38,7 @@ describe SEPA::CreditTransfer do
38
38
  it 'should fail' do
39
39
  expect {
40
40
  SEPA::CreditTransfer.new.to_xml
41
- }.to raise_error(SEPA::Error)
41
+ }.to raise_error(SEPA::Error, /Name is too short/)
42
42
  end
43
43
  end
44
44
 
@@ -62,7 +62,7 @@ describe SEPA::CreditTransfer do
62
62
  sct
63
63
  end
64
64
 
65
- it 'should validate against pain.001.003.01' do
65
+ it 'should validate against pain.001.003.03' do
66
66
  expect(subject.to_xml(SEPA::PAIN_001_003_03)).to validate_against('pain.001.003.03.xsd')
67
67
  end
68
68
  end
@@ -90,7 +90,7 @@ describe SEPA::CreditTransfer do
90
90
  sct
91
91
  end
92
92
 
93
- it 'should validate against pain.001.001.01' do
93
+ it 'should validate against pain.001.001.03' do
94
94
  expect(subject.to_xml(SEPA::PAIN_001_001_03)).to validate_against('pain.001.001.03.xsd')
95
95
  end
96
96
  end
@@ -105,26 +105,35 @@ describe SEPA::CreditTransfer do
105
105
  bic: 'PBNKDEFF370',
106
106
  iban: 'DE37112589611964645802',
107
107
  amount: 102.50,
108
+ currency: currency,
108
109
  reference: 'XYZ-1234/123',
109
110
  remittance_information: 'Rechnung vom 22.08.2013'
110
111
 
111
112
  sct
112
113
  end
113
114
 
114
- it 'should create valid XML file' do
115
- expect(subject.to_xml).to validate_against('pain.001.003.03.xsd')
115
+ let(:currency) { nil }
116
+
117
+ it 'should validate against pain.001.003.03' do
118
+ expect(subject.to_xml(SEPA::PAIN_001_003_03)).to validate_against('pain.001.003.03.xsd')
116
119
  end
117
120
 
118
- it 'should fail for pain.001.001.03' do
119
- expect {
120
- subject.to_xml(SEPA::PAIN_001_001_03)
121
- }.to raise_error(SEPA::Error)
121
+ it 'should validate against pain.001.001.03' do
122
+ expect(subject.to_xml(SEPA::PAIN_001_001_03)).to validate_against('pain.001.001.03.xsd')
123
+ end
124
+
125
+ context 'with CHF as currency' do
126
+ let(:currency) { 'CHF' }
127
+
128
+ it 'should validate against pain.001.001.03.ch.02' do
129
+ expect(subject.to_xml(SEPA::PAIN_001_001_03_CH_02)).to validate_against('pain.001.001.03.ch.02.xsd')
130
+ end
122
131
  end
123
132
 
124
133
  it 'should fail for pain.001.002.03' do
125
134
  expect {
126
135
  subject.to_xml(SEPA::PAIN_001_002_03)
127
- }.to raise_error(SEPA::Error)
136
+ }.to raise_error(SEPA::Error, /Incompatible with schema/)
128
137
  end
129
138
  end
130
139
 
@@ -143,7 +152,7 @@ describe SEPA::CreditTransfer do
143
152
  end
144
153
 
145
154
  it 'should validate against pain.001.001.03' do
146
- expect(subject.to_xml('pain.001.001.03')).to validate_against('pain.001.001.03.xsd')
155
+ expect(subject.to_xml).to validate_against('pain.001.001.03.xsd')
147
156
  end
148
157
 
149
158
  it 'should validate against pain.001.002.03' do
@@ -176,7 +185,7 @@ describe SEPA::CreditTransfer do
176
185
  end
177
186
 
178
187
  it 'should create valid XML file' do
179
- expect(subject).to validate_against('pain.001.003.03.xsd')
188
+ expect(subject).to validate_against('pain.001.001.03.xsd')
180
189
  end
181
190
 
182
191
  it 'should have message_identification' do
@@ -344,7 +353,7 @@ describe SEPA::CreditTransfer do
344
353
  end
345
354
 
346
355
  it 'should create valid XML file' do
347
- expect(subject).to validate_against('pain.001.003.03.xsd')
356
+ expect(subject).to validate_against('pain.001.001.03.xsd')
348
357
  end
349
358
 
350
359
  it 'should contain <InstrId>' do
@@ -381,13 +390,13 @@ describe SEPA::CreditTransfer do
381
390
  it 'should fail for pain.001.002.03' do
382
391
  expect {
383
392
  subject.to_xml(SEPA::PAIN_001_002_03)
384
- }.to raise_error(SEPA::Error)
393
+ }.to raise_error(SEPA::Error, /Incompatible with schema/)
385
394
  end
386
395
 
387
396
  it 'should fail for pain.001.003.03' do
388
397
  expect {
389
398
  subject.to_xml(SEPA::PAIN_001_003_03)
390
- }.to raise_error(SEPA::Error)
399
+ }.to raise_error(SEPA::Error, /Incompatible with schema/)
391
400
  end
392
401
  end
393
402
 
@@ -409,7 +418,7 @@ describe SEPA::CreditTransfer do
409
418
  it 'should fail for pain.001.002.03' do
410
419
  expect {
411
420
  subject.to_xml(SEPA::PAIN_001_002_03)
412
- }.to raise_error(SEPA::Error)
421
+ }.to raise_error(SEPA::Error, /Incompatible with schema/)
413
422
  end
414
423
 
415
424
  it 'should validate against pain.001.003.03' do
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require 'spec_helper'
3
3
 
4
- describe SEPA::CreditTransferTransaction do
4
+ RSpec.describe SEPA::CreditTransferTransaction do
5
5
  describe :initialize do
6
6
  it 'should initialize a valid transaction' do
7
7
  expect(
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require 'spec_helper'
3
3
 
4
- describe SEPA::CreditorAccount do
4
+ RSpec.describe SEPA::CreditorAccount do
5
5
  it 'should initialize a new account' do
6
6
  expect(
7
7
  SEPA::CreditorAccount.new name: 'Gläubiger GmbH',
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require 'spec_helper'
3
3
 
4
- describe SEPA::DebtorAccount do
4
+ RSpec.describe SEPA::DebtorAccount do
5
5
  it 'should initialize a new account' do
6
6
  expect(
7
7
  SEPA::DebtorAccount.new name: 'Gläubiger GmbH',
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require 'spec_helper'
3
3
 
4
- describe SEPA::DebtorAddress do
4
+ RSpec.describe SEPA::DebtorAddress do
5
5
  it 'should initialize a new address' do
6
6
  expect(
7
7
  SEPA::DebtorAddress.new country_code: 'CH',
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require 'spec_helper'
3
3
 
4
- describe SEPA::DirectDebit do
4
+ RSpec.describe SEPA::DirectDebit do
5
5
  let(:message_id_regex) { /SEPA-KING\/[0-9a-z_]{22}/ }
6
6
 
7
7
  let(:direct_debit) {
@@ -70,7 +70,7 @@ describe SEPA::DirectDebit do
70
70
  it 'should fail' do
71
71
  expect {
72
72
  SEPA::DirectDebit.new.to_xml
73
- }.to raise_error(SEPA::Error)
73
+ }.to raise_error(SEPA::Error, /Name is too short/)
74
74
  end
75
75
  end
76
76
 
@@ -158,7 +158,7 @@ describe SEPA::DirectDebit do
158
158
  it 'should fail for pain.008.002.02' do
159
159
  expect {
160
160
  subject.to_xml(SEPA::PAIN_008_002_02)
161
- }.to raise_error(SEPA::Error)
161
+ }.to raise_error(SEPA::Error, /Incompatible with schema/)
162
162
  end
163
163
 
164
164
  it 'should validate against pain.008.001.02' do
@@ -256,7 +256,7 @@ describe SEPA::DirectDebit do
256
256
  end
257
257
 
258
258
  it 'should create valid XML file' do
259
- expect(subject).to validate_against('pain.008.003.02.xsd')
259
+ expect(subject).to validate_against('pain.008.001.02.xsd')
260
260
  end
261
261
 
262
262
  it 'should have creditor identifier' do
@@ -385,7 +385,7 @@ describe SEPA::DirectDebit do
385
385
  it 'should raise error on XML generation' do
386
386
  expect {
387
387
  subject.to_xml
388
- }.to raise_error(SEPA::Error)
388
+ }.to raise_error(SEPA::Error, /CORE, COR1 AND B2B must not be mixed in one message/)
389
389
  end
390
390
  end
391
391
 
@@ -516,7 +516,7 @@ describe SEPA::DirectDebit do
516
516
  end
517
517
 
518
518
  it 'should create valid XML file' do
519
- expect(subject).to validate_against('pain.008.003.02.xsd')
519
+ expect(subject).to validate_against('pain.008.001.02.xsd')
520
520
  end
521
521
 
522
522
  it 'should contain <InstrId>' do
@@ -533,7 +533,7 @@ describe SEPA::DirectDebit do
533
533
  end
534
534
 
535
535
  it 'should fail as the payment identification becomes too large' do
536
- expect { subject.to_xml }.to raise_error(SEPA::Error)
536
+ expect { subject.to_xml }.to raise_error(SEPA::Error, /The value has a length of '37'; this exceeds the allowed maximum length of '35'/)
537
537
  end
538
538
  end
539
539
 
@@ -546,7 +546,7 @@ describe SEPA::DirectDebit do
546
546
  sct
547
547
  end
548
548
 
549
- it 'should validate against pain.001.001.03' do
549
+ it 'should validate against pain.008.001.02' do
550
550
  expect(subject.to_xml(SEPA::PAIN_008_001_02)).to validate_against('pain.008.001.02.xsd')
551
551
  end
552
552
 
@@ -562,13 +562,13 @@ describe SEPA::DirectDebit do
562
562
  it 'should fail for pain.008.002.02' do
563
563
  expect {
564
564
  subject.to_xml(SEPA::PAIN_008_002_02)
565
- }.to raise_error(SEPA::Error)
565
+ }.to raise_error(SEPA::Error, /Incompatible with schema/)
566
566
  end
567
567
 
568
568
  it 'should fail for pain.008.003.02' do
569
569
  expect {
570
570
  subject.to_xml(SEPA::PAIN_008_003_02)
571
- }.to raise_error(SEPA::Error)
571
+ }.to raise_error(SEPA::Error, /Incompatible with schema/)
572
572
  end
573
573
  end
574
574
  end
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require 'spec_helper'
3
3
 
4
- describe SEPA::DirectDebitTransaction do
4
+ RSpec.describe SEPA::DirectDebitTransaction do
5
5
  describe :initialize do
6
6
  it 'should create a valid transaction' do
7
7
  expect(
data/spec/message_spec.rb CHANGED
@@ -10,7 +10,7 @@ class DummyMessage < SEPA::Message
10
10
  self.transaction_class = DummyTransaction
11
11
  end
12
12
 
13
- describe SEPA::Message do
13
+ RSpec.describe SEPA::Message do
14
14
  describe :amount_total do
15
15
  subject do
16
16
  message = DummyMessage.new
@@ -86,7 +86,7 @@ describe SEPA::Message do
86
86
  end
87
87
  end
88
88
 
89
- describe :creation_date_time do
89
+ describe :creation_date_time do
90
90
  subject { DummyMessage.new }
91
91
 
92
92
  describe 'getter' do
data/spec/spec_helper.rb CHANGED
@@ -18,12 +18,13 @@ require 'sepa_king'
18
18
 
19
19
  # Requires supporting ruby files with custom matchers and macros, etc,
20
20
  # in spec/support/ and its subdirectories.
21
- Dir[File.expand_path(File.join(File.dirname(__FILE__),'support','**','*.rb'))].each {|f| require f}
21
+ Dir[File.expand_path(File.join(__dir__, 'support', '**', '*.rb'))].each {|f| require f}
22
22
 
23
23
  # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
24
24
  RSpec.configure do |config|
25
25
  config.run_all_when_everything_filtered = true
26
26
  config.filter_run :focus
27
+ config.disable_monkey_patching!
27
28
 
28
29
  # Run specs in random order to surface order dependencies. If you find an
29
30
  # order dependency and want to debug it, you can fix the order by providing
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require 'spec_helper'
3
3
 
4
- describe SEPA::Transaction do
4
+ RSpec.describe SEPA::Transaction do
5
5
  describe :new do
6
6
  it 'should have default for reference' do
7
7
  expect(SEPA::Transaction.new.reference).to eq('NOTPROVIDED')
@@ -26,7 +26,7 @@ describe SEPA::Transaction do
26
26
  end
27
27
  end
28
28
 
29
- context 'Adress' do
29
+ context 'Address' do
30
30
  context 'with address_line' do
31
31
  it 'should accept valid value' do
32
32
  expect(SEPA::Transaction).to accept(SEPA::DebtorAddress.new(
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe 'Credit Transfer Initiation' do
3
+ RSpec.describe 'Credit Transfer Initiation' do
4
4
  it "should validate example file" do
5
5
  expect(File.read('spec/examples/pain.001.002.03.xml')).to validate_against('pain.001.002.03.xsd')
6
6
  expect(File.read('spec/examples/pain.001.003.03.xml')).to validate_against('pain.001.003.03.xsd')
@@ -12,7 +12,7 @@ describe 'Credit Transfer Initiation' do
12
12
  end
13
13
  end
14
14
 
15
- describe 'Direct Debit Initiation' do
15
+ RSpec.describe 'Direct Debit Initiation' do
16
16
  it 'should validate example file' do
17
17
  expect(File.read('spec/examples/pain.008.002.02.xml')).to validate_against('pain.008.002.02.xsd')
18
18
  expect(File.read('spec/examples/pain.008.003.02.xml')).to validate_against('pain.008.003.02.xsd')
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require 'spec_helper'
3
3
 
4
- describe SEPA::IBANValidator do
4
+ RSpec.describe SEPA::IBANValidator do
5
5
  class Validatable
6
6
  include ActiveModel::Model
7
7
  attr_accessor :iban, :iban_the_terrible
@@ -29,7 +29,7 @@ describe SEPA::IBANValidator do
29
29
  end
30
30
  end
31
31
 
32
- describe SEPA::BICValidator do
32
+ RSpec.describe SEPA::BICValidator do
33
33
  class Validatable
34
34
  include ActiveModel::Model
35
35
  attr_accessor :bic, :custom_bic
@@ -52,7 +52,7 @@ describe SEPA::BICValidator do
52
52
  end
53
53
  end
54
54
 
55
- describe SEPA::CreditorIdentifierValidator do
55
+ RSpec.describe SEPA::CreditorIdentifierValidator do
56
56
  class Validatable
57
57
  include ActiveModel::Model
58
58
  attr_accessor :creditor_identifier, :crid
@@ -61,11 +61,29 @@ describe SEPA::CreditorIdentifierValidator do
61
61
  end
62
62
 
63
63
  it 'should accept valid creditor_identifier' do
64
- expect(Validatable).to accept('DE98ZZZ09999999999', 'AT12ZZZ00000000001', 'FR12ZZZ123456', 'NL97ZZZ123456780001', for: [:creditor_identifier, :crid])
64
+ expect(Validatable).to accept(
65
+ 'DE98ZZZ09999999999',
66
+ 'CH0712300000012345',
67
+ 'SE97ZZZ1234567890',
68
+ 'PL97ZZZ0123456789',
69
+ 'NO97ZZZ123456785',
70
+ 'HU74111A12345676',
71
+ 'BG32ZZZ100064095',
72
+ 'AT12ZZZ00000000001',
73
+ 'FR12ZZZ123456',
74
+ 'NL97ZZZ123456780001',
75
+ for: [:creditor_identifier, :crid]
76
+ )
65
77
  end
66
78
 
67
79
  it 'should not accept an invalid creditor_identifier' do
68
- expect(Validatable).not_to accept('', 'xxx', 'DE98ZZZ099999999990', for: [:creditor_identifier, :crid])
80
+ expect(Validatable).not_to accept(
81
+ '',
82
+ 'xxx',
83
+ 'DE98ZZZ099999999990',
84
+ 'DE98---09999999999',
85
+ for: [:creditor_identifier, :crid]
86
+ )
69
87
  end
70
88
 
71
89
  it "should customize error message" do
@@ -75,7 +93,7 @@ describe SEPA::CreditorIdentifierValidator do
75
93
  end
76
94
  end
77
95
 
78
- describe SEPA::MandateIdentifierValidator do
96
+ RSpec.describe SEPA::MandateIdentifierValidator do
79
97
  class Validatable
80
98
  include ActiveModel::Model
81
99
  attr_accessor :mandate_id, :mid
@@ -88,12 +106,12 @@ describe SEPA::MandateIdentifierValidator do
88
106
  end
89
107
 
90
108
  it 'should not accept an invalid mandate_identifier' do
91
- expect(Validatable).not_to accept(nil, '', 'X' * 36, 'ABC 123', '#/*', 'Ümläüt', for: [:mandate_id, :mid])
109
+ expect(Validatable).not_to accept(nil, '', 'X' * 36, '#/*', 'Ümläüt', for: [:mandate_id, :mid])
92
110
  end
93
111
 
94
112
  it "should customize error message" do
95
- v = Validatable.new(:mandate_id => 'ABC 123')
113
+ v = Validatable.new(:mandate_id => '*** 123')
96
114
  v.valid?
97
- expect(v.errors[:mandate_id]).to eq(['ABC 123 seems wrong'])
115
+ expect(v.errors[:mandate_id]).to eq(['*** 123 seems wrong'])
98
116
  end
99
117
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sepa_king
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Georg Leciejewski
8
8
  - Georg Ledermann
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-08-25 00:00:00.000000000 Z
12
+ date: 2022-10-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemodel
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: '3.1'
20
+ version: '4.2'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: '3.1'
27
+ version: '4.2'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: nokogiri
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -82,7 +82,7 @@ dependencies:
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0'
84
84
  - !ruby/object:Gem::Dependency
85
- name: coveralls
85
+ name: coveralls_reborn
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
88
  - - ">="
@@ -123,31 +123,29 @@ dependencies:
123
123
  - - ">="
124
124
  - !ruby/object:Gem::Version
125
125
  version: '0'
126
- description: Implemention of pain.001.002.03 and pain.008.002.02 (ISO 20022)
126
+ description: Implemention of Payments Initiation (ISO 20022)
127
127
  email:
128
128
  - gl@salesking.eu
129
- - mail@georg-ledermann.de
129
+ - georg@ledermann.dev
130
130
  executables: []
131
131
  extensions: []
132
132
  extra_rdoc_files: []
133
133
  files:
134
+ - ".github/workflows/main.yml"
134
135
  - ".gitignore"
135
136
  - ".rspec"
136
- - ".travis.yml"
137
137
  - CONTRIBUTING.md
138
138
  - Gemfile
139
139
  - LICENSE.txt
140
140
  - README.md
141
141
  - Rakefile
142
- - gemfiles/Gemfile-activemodel-3.1.x
143
- - gemfiles/Gemfile-activemodel-3.2.x
144
- - gemfiles/Gemfile-activemodel-4.0.x
145
- - gemfiles/Gemfile-activemodel-4.1.x
146
142
  - gemfiles/Gemfile-activemodel-4.2.x
147
143
  - gemfiles/Gemfile-activemodel-5.0.x
148
144
  - gemfiles/Gemfile-activemodel-5.1.x
149
145
  - gemfiles/Gemfile-activemodel-5.2.x
150
146
  - gemfiles/Gemfile-activemodel-6.0.x
147
+ - gemfiles/Gemfile-activemodel-6.1.x
148
+ - gemfiles/Gemfile-activemodel-7.0.x
151
149
  - lib/schema/pain.001.001.03.ch.02.xsd
152
150
  - lib/schema/pain.001.001.03.xsd
153
151
  - lib/schema/pain.001.002.03.xsd
@@ -189,18 +187,17 @@ files:
189
187
  - spec/examples/pain.008.003.02.xml
190
188
  - spec/message_spec.rb
191
189
  - spec/spec_helper.rb
192
- - spec/support/active_model.rb
193
190
  - spec/support/custom_matcher.rb
194
191
  - spec/support/factories.rb
195
192
  - spec/support/validations.rb
196
193
  - spec/transaction_spec.rb
197
194
  - spec/validation_spec.rb
198
195
  - spec/validator_spec.rb
199
- homepage: http://github.com/salesking/sepa_king
196
+ homepage: https://github.com/salesking/sepa_king
200
197
  licenses:
201
198
  - MIT
202
199
  metadata: {}
203
- post_install_message:
200
+ post_install_message:
204
201
  rdoc_options: []
205
202
  require_paths:
206
203
  - lib
@@ -208,39 +205,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
208
205
  requirements:
209
206
  - - ">="
210
207
  - !ruby/object:Gem::Version
211
- version: '2.2'
208
+ version: '2.7'
212
209
  required_rubygems_version: !ruby/object:Gem::Requirement
213
210
  requirements:
214
211
  - - ">="
215
212
  - !ruby/object:Gem::Version
216
213
  version: '0'
217
214
  requirements: []
218
- rubygems_version: 3.0.6
219
- signing_key:
215
+ rubygems_version: 3.3.23
216
+ signing_key:
220
217
  specification_version: 4
221
218
  summary: Ruby gem for creating SEPA XML files
222
- test_files:
223
- - spec/account_spec.rb
224
- - spec/converter_spec.rb
225
- - spec/credit_transfer_spec.rb
226
- - spec/credit_transfer_transaction_spec.rb
227
- - spec/creditor_account_spec.rb
228
- - spec/debtor_account_spec.rb
229
- - spec/debtor_address_spec.rb
230
- - spec/direct_debit_spec.rb
231
- - spec/direct_debit_transaction_spec.rb
232
- - spec/examples/pain.001.001.03.ch.02.xml
233
- - spec/examples/pain.001.001.03.xml
234
- - spec/examples/pain.001.002.03.xml
235
- - spec/examples/pain.001.003.03.xml
236
- - spec/examples/pain.008.002.02.xml
237
- - spec/examples/pain.008.003.02.xml
238
- - spec/message_spec.rb
239
- - spec/spec_helper.rb
240
- - spec/support/active_model.rb
241
- - spec/support/custom_matcher.rb
242
- - spec/support/factories.rb
243
- - spec/support/validations.rb
244
- - spec/transaction_spec.rb
245
- - spec/validation_spec.rb
246
- - spec/validator_spec.rb
219
+ test_files: []
data/.travis.yml DELETED
@@ -1,37 +0,0 @@
1
- rvm:
2
- - 2.2.10
3
- - 2.3.8
4
- - 2.4.6
5
- - 2.5.5
6
- - 2.6.3
7
- gemfile:
8
- - gemfiles/Gemfile-activemodel-3.1.x
9
- - gemfiles/Gemfile-activemodel-3.2.x
10
- - gemfiles/Gemfile-activemodel-4.0.x
11
- - gemfiles/Gemfile-activemodel-4.1.x
12
- - gemfiles/Gemfile-activemodel-4.2.x
13
- - gemfiles/Gemfile-activemodel-5.0.x
14
- - gemfiles/Gemfile-activemodel-5.1.x
15
- - gemfiles/Gemfile-activemodel-5.2.x
16
- - gemfiles/Gemfile-activemodel-6.0.x
17
- matrix:
18
- exclude:
19
- - rvm: 2.2.10
20
- gemfile: gemfiles/Gemfile-activemodel-6.0.x
21
- - rvm: 2.3.8
22
- gemfile: gemfiles/Gemfile-activemodel-6.0.x
23
- - rvm: 2.4.6
24
- gemfile: gemfiles/Gemfile-activemodel-4.1.x
25
- - rvm: 2.4.6
26
- gemfile: gemfiles/Gemfile-activemodel-4.2.x
27
- - rvm: 2.4.6
28
- gemfile: gemfiles/Gemfile-activemodel-6.0.x
29
- - rvm: 2.5.5
30
- gemfile: gemfiles/Gemfile-activemodel-4.1.x
31
- - rvm: 2.5.5
32
- gemfile: gemfiles/Gemfile-activemodel-4.2.x
33
- - rvm: 2.6.3
34
- gemfile: gemfiles/Gemfile-activemodel-4.1.x
35
- - rvm: 2.6.3
36
- gemfile: gemfiles/Gemfile-activemodel-4.2.x
37
- sudo: false
@@ -1,5 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec path: '..'
4
-
5
- gem 'activemodel', '~>3.2.22.2'
@@ -1,5 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec path: '..'
4
-
5
- gem 'activemodel', '~>4.0.13'
@@ -1,30 +0,0 @@
1
- unless defined?(ActiveModel::Model)
2
- # ActiveModel::Model is available since ActiveModel 4.0 only.
3
- #
4
- # If it's missing, add the code from
5
- # https://github.com/rails/rails/blob/master/activemodel/lib/active_model/model.rb
6
- module ActiveModel
7
- module Model
8
- def self.included(base)
9
- base.class_eval do
10
- extend ActiveModel::Naming
11
- extend ActiveModel::Translation
12
- include ActiveModel::Validations
13
- include ActiveModel::Conversion
14
- end
15
- end
16
-
17
- def initialize(params={})
18
- params.each do |attr, value|
19
- self.public_send("#{attr}=", value)
20
- end if params
21
-
22
- super()
23
- end
24
-
25
- def persisted?
26
- false
27
- end
28
- end
29
- end
30
- end