sepa_king 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,12 +4,12 @@ require 'spec_helper'
4
4
  describe SEPA::CreditTransferTransaction do
5
5
  it 'should initialize a new transaction' do
6
6
  expect(
7
- SEPA::CreditTransferTransaction.new :name => 'Telekomiker AG',
8
- :iban => 'DE37112589611964645802',
9
- :bic => 'PBNKDEFF370',
10
- :amount => 102.50,
11
- :reference => 'XYZ-1234/123',
12
- :remittance_information => 'Rechnung 123 vom 22.08.2013'
7
+ SEPA::CreditTransferTransaction.new name: 'Telekomiker AG',
8
+ iban: 'DE37112589611964645802',
9
+ bic: 'PBNKDEFF370',
10
+ amount: 102.50,
11
+ reference: 'XYZ-1234/123',
12
+ remittance_information: 'Rechnung 123 vom 22.08.2013'
13
13
  ).to be_valid
14
14
  end
15
15
  end
@@ -4,28 +4,20 @@ require 'spec_helper'
4
4
  describe SEPA::CreditorAccount do
5
5
  it 'should initialize a new account' do
6
6
  expect(
7
- SEPA::CreditorAccount.new :name => 'Gläubiger GmbH',
8
- :bic => 'BANKDEFFXXX',
9
- :iban => 'DE87200500001234567890',
10
- :identifier => 'DE98ZZZ09999999999'
7
+ SEPA::CreditorAccount.new name: 'Gläubiger GmbH',
8
+ bic: 'BANKDEFFXXX',
9
+ iban: 'DE87200500001234567890',
10
+ creditor_identifier: 'DE98ZZZ09999999999'
11
11
  ).to be_valid
12
12
  end
13
13
 
14
- describe :identifier do
14
+ describe :creditor_identifier do
15
15
  it 'should accept valid value' do
16
- [ 'DE98ZZZ09999999999' ].each do |value_value|
17
- expect(
18
- SEPA::CreditorAccount.new :identifier => value_value
19
- ).to have(:no).errors_on(:identifier)
20
- end
16
+ SEPA::CreditorAccount.should accept('DE98ZZZ09999999999', 'AT12ZZZ00000000001', 'IT97ZZZA1B2C3D4E5F6G7H8', 'NL97ZZZ123456780001', 'FR12ZZZ123456', for: :creditor_identifier)
21
17
  end
22
18
 
23
19
  it 'should not accept invalid value' do
24
- [ '', 'invalid' ].each do |invalue_value|
25
- expect(
26
- SEPA::CreditorAccount.new :identifier => invalue_value
27
- ).to have_at_least(1).errors_on(:identifier)
28
- end
20
+ SEPA::CreditorAccount.should_not accept('', 'invalid', 'DE98ZZZ099999999990', 'DEAAAAAAAAAAAAAAAA', for: :creditor_identifier)
29
21
  end
30
22
  end
31
23
  end
@@ -4,9 +4,9 @@ require 'spec_helper'
4
4
  describe SEPA::DebtorAccount do
5
5
  it 'should initialize a new account' do
6
6
  expect(
7
- SEPA::DebtorAccount.new :name => 'Gläubiger GmbH',
8
- :bic => 'BANKDEFFXXX',
9
- :iban => 'DE87200500001234567890'
7
+ SEPA::DebtorAccount.new name: 'Gläubiger GmbH',
8
+ bic: 'BANKDEFFXXX',
9
+ iban: 'DE87200500001234567890'
10
10
  ).to be_valid
11
11
  end
12
12
  end
@@ -3,10 +3,10 @@ require 'spec_helper'
3
3
 
4
4
  describe SEPA::DirectDebit do
5
5
  let(:direct_debit) {
6
- SEPA::DirectDebit.new :name => 'Gläubiger GmbH',
7
- :bic => 'BANKDEFFXXX',
8
- :iban => 'DE87200500001234567890',
9
- :identifier => 'DE98ZZZ09999999999'
6
+ SEPA::DirectDebit.new name: 'Gläubiger GmbH',
7
+ bic: 'BANKDEFFXXX',
8
+ iban: 'DE87200500001234567890',
9
+ creditor_identifier: 'DE98ZZZ09999999999'
10
10
  }
11
11
 
12
12
  describe :new do
@@ -19,58 +19,273 @@ describe SEPA::DirectDebit do
19
19
 
20
20
  describe :add_transaction do
21
21
  it 'should add valid transactions' do
22
- 3.times {
23
- direct_debit.add_transaction :name => 'Zahlemann & Söhne GbR',
24
- :bic => 'SPUEDE2UXXX',
25
- :iban => 'DE21500500009876543210',
26
- :amount => 39.99,
27
- :reference => 'XYZ/2013-08-ABO/12345',
28
- :remittance_information => 'Unsere Rechnung vom 10.08.2013',
29
- :mandate_id => 'K-02-2011-12345',
30
- :mandate_date_of_signature => Date.new(2011,1,25)
31
- }
22
+ 3.times do
23
+ direct_debit.add_transaction(direct_debt_transaction)
24
+ end
32
25
 
33
26
  expect(direct_debit).to have(3).transactions
34
27
  end
35
28
 
36
29
  it 'should fail for invalid transaction' do
37
30
  expect {
38
- direct_debit.add_transaction :name => ''
31
+ direct_debit.add_transaction name: ''
39
32
  }.to raise_error(ArgumentError)
40
33
  end
41
34
  end
42
35
 
43
36
  describe :to_xml do
44
- it 'should fail for invalid debtor' do
45
- expect {
46
- SEPA::DirectDebit.new.to_xml
47
- }.to raise_error(RuntimeError)
37
+ context 'for invalid creditor' do
38
+ it 'should fail' do
39
+ expect {
40
+ SEPA::DirectDebit.new.to_xml
41
+ }.to raise_error(RuntimeError)
42
+ end
48
43
  end
49
44
 
50
- it 'should create valid XML file' do
51
- dd = direct_debit
52
-
53
- dd.add_transaction :name => 'Zahlemann & Söhne GbR',
54
- :bic => 'SPUEDE2UXXX',
55
- :iban => 'DE21500500009876543210',
56
- :amount => 39.99,
57
- :reference => 'XYZ/2013-08-ABO/12345',
58
- :remittance_information => 'Unsere Rechnung vom 10.08.2013',
59
- :mandate_id => 'K-02-2011-12345',
60
- :mandate_date_of_signature => Date.new(2011,1,25)
61
-
62
- dd.add_transaction :name => 'Meier & Schulze oHG',
63
- :bic => 'GENODEF1JEV',
64
- :iban => 'DE68210501700012345678',
65
- :amount => 750.00,
66
- :reference => 'XYZ/2013-08-ABO/6789',
67
- :remittance_information => 'Vielen Dank für Ihren Einkauf!',
68
- :mandate_id => 'K-08-2010-42123',
69
- :mandate_date_of_signature => Date.new(2010,7,25)
70
-
71
- expect(
72
- XML::Document.string(dd.to_xml)
73
- ).to validate_against('pain.008.002.02.xsd')
45
+ context 'for valid creditor' do
46
+ context 'without requested_date given' do
47
+ subject do
48
+ sdd = direct_debit
49
+
50
+ sdd.add_transaction name: 'Zahlemann & Söhne GbR',
51
+ bic: 'SPUEDE2UXXX',
52
+ iban: 'DE21500500009876543210',
53
+ amount: 39.99,
54
+ reference: 'XYZ/2013-08-ABO/12345',
55
+ remittance_information: 'Unsere Rechnung vom 10.08.2013',
56
+ mandate_id: 'K-02-2011-12345',
57
+ mandate_date_of_signature: Date.new(2011,1,25)
58
+
59
+ sdd.add_transaction name: 'Meier & Schulze oHG',
60
+ bic: 'GENODEF1JEV',
61
+ iban: 'DE68210501700012345678',
62
+ amount: 750.00,
63
+ reference: 'XYZ/2013-08-ABO/6789',
64
+ remittance_information: 'Vielen Dank für Ihren Einkauf!',
65
+ mandate_id: 'K-08-2010-42123',
66
+ mandate_date_of_signature: Date.new(2010,7,25)
67
+
68
+ sdd.to_xml
69
+ end
70
+
71
+ it 'should create valid XML file' do
72
+ expect(subject).to validate_against('pain.008.002.02.xsd')
73
+ end
74
+
75
+ it 'should contain <ReqdColltnDt>' do
76
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf/ReqdColltnDt', Date.today.next.iso8601)
77
+ end
78
+
79
+ it 'should contain <PmtMtd>' do
80
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf/PmtMtd', 'DD')
81
+ end
82
+
83
+ it 'should contain <BtchBookg>' do
84
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf/BtchBookg', 'true')
85
+ end
86
+
87
+ it 'should contain <NbOfTxs>' do
88
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf/NbOfTxs', '2')
89
+ end
90
+
91
+ it 'should contain <CtrlSum>' do
92
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf/CtrlSum', '789.99')
93
+ end
94
+
95
+ it 'should contain <Cdtr>' do
96
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf/Cdtr/Nm', 'Glaeubiger GmbH')
97
+ end
98
+
99
+ it 'should contain <CdtrAcct>' do
100
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf/CdtrAcct/Id/IBAN', 'DE87200500001234567890')
101
+ end
102
+
103
+ it 'should contain <CdtrAgt>' do
104
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf/CdtrAgt/FinInstnId/BIC', 'BANKDEFFXXX')
105
+ end
106
+
107
+ it 'should contain <CdtrAgt>' do
108
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf/CdtrSchmeId/Id/PrvtId/Othr/Id', 'DE98ZZZ09999999999')
109
+ end
110
+
111
+ it 'should contain <EndToEndId>' do
112
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[1]/PmtId/EndToEndId', 'XYZ/2013-08-ABO/12345')
113
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[2]/PmtId/EndToEndId', 'XYZ/2013-08-ABO/6789')
114
+ end
115
+
116
+ it 'should contain <InstdAmt>' do
117
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[1]/InstdAmt', '39.99')
118
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[2]/InstdAmt', '750.00')
119
+ end
120
+
121
+ it 'should contain <MndtId>' do
122
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[1]/DrctDbtTx/MndtRltdInf/MndtId', 'K-02-2011-12345')
123
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[2]/DrctDbtTx/MndtRltdInf/MndtId', 'K-08-2010-42123')
124
+ end
125
+
126
+ it 'should contain <DtOfSgntr>' do
127
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[1]/DrctDbtTx/MndtRltdInf/DtOfSgntr', '2011-01-25')
128
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[2]/DrctDbtTx/MndtRltdInf/DtOfSgntr', '2010-07-25')
129
+ end
130
+
131
+ it 'should contain <DbtrAgt>' do
132
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[1]/DbtrAgt/FinInstnId/BIC', 'SPUEDE2UXXX')
133
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[2]/DbtrAgt/FinInstnId/BIC', 'GENODEF1JEV')
134
+ end
135
+
136
+ it 'should contain <Dbtr>' do
137
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[1]/Dbtr/Nm', 'Zahlemann Soehne GbR')
138
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[2]/Dbtr/Nm', 'Meier Schulze oHG')
139
+ end
140
+
141
+ it 'should contain <DbtrAcct>' do
142
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[1]/DbtrAcct/Id/IBAN', 'DE21500500009876543210')
143
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[2]/DbtrAcct/Id/IBAN', 'DE68210501700012345678')
144
+ end
145
+
146
+ it 'should contain <RmtInf>' do
147
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[1]/RmtInf/Ustrd', 'Unsere Rechnung vom 10.08.2013')
148
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[2]/RmtInf/Ustrd', 'Vielen Dank fuer Ihren Einkauf')
149
+ end
150
+ end
151
+
152
+ context 'with different requested_date given' do
153
+ subject do
154
+ sdd = direct_debit
155
+
156
+ sdd.add_transaction(direct_debt_transaction.merge requested_date: Date.today + 1)
157
+ sdd.add_transaction(direct_debt_transaction.merge requested_date: Date.today + 2)
158
+ sdd.add_transaction(direct_debt_transaction.merge requested_date: Date.today + 2)
159
+
160
+ sdd.to_xml
161
+ end
162
+
163
+ it 'should contain two payment_informations with <ReqdColltnDt>' do
164
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[1]/ReqdColltnDt', (Date.today + 1).iso8601)
165
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[2]/ReqdColltnDt', (Date.today + 2).iso8601)
166
+
167
+ subject.should_not have_xml('//Document/CstmrDrctDbtInitn/PmtInf[3]')
168
+ end
169
+ end
170
+
171
+ context 'with different local_instrument given' do
172
+ subject do
173
+ sdd = direct_debit
174
+
175
+ sdd.add_transaction(direct_debt_transaction.merge local_instrument: 'CORE')
176
+ sdd.add_transaction(direct_debt_transaction.merge local_instrument: 'B2B')
177
+ sdd.add_transaction(direct_debt_transaction.merge local_instrument: 'B2B')
178
+
179
+ sdd.to_xml
180
+ end
181
+
182
+ it 'should contain two payment_informations with <LclInstrm>' do
183
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[1]/PmtTpInf/LclInstrm/Cd', 'CORE')
184
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[2]/PmtTpInf/LclInstrm/Cd', 'B2B')
185
+
186
+ subject.should_not have_xml('//Document/CstmrDrctDbtInitn/PmtInf[3]')
187
+ end
188
+ end
189
+
190
+ context 'with different sequence_type given' do
191
+ subject do
192
+ sdd = direct_debit
193
+
194
+ sdd.add_transaction(direct_debt_transaction.merge sequence_type: 'OOFF')
195
+ sdd.add_transaction(direct_debt_transaction.merge sequence_type: 'FRST')
196
+ sdd.add_transaction(direct_debt_transaction.merge sequence_type: 'FRST')
197
+
198
+ sdd.to_xml
199
+ end
200
+
201
+ it 'should contain two payment_informations with <LclInstrm>' do
202
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[1]/PmtTpInf/SeqTp', 'OOFF')
203
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[2]/PmtTpInf/SeqTp', 'FRST')
204
+
205
+ subject.should_not have_xml('//Document/CstmrDrctDbtInitn/PmtInf[3]')
206
+ end
207
+ end
208
+
209
+ context 'with different batch_booking given' do
210
+ subject do
211
+ sdd = direct_debit
212
+
213
+ sdd.add_transaction(direct_debt_transaction.merge batch_booking: false)
214
+ sdd.add_transaction(direct_debt_transaction.merge batch_booking: true)
215
+ sdd.add_transaction(direct_debt_transaction.merge batch_booking: true)
216
+
217
+ sdd.to_xml
218
+ end
219
+
220
+ it 'should contain two payment_informations with <BtchBookg>' do
221
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[1]/BtchBookg', 'false')
222
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[2]/BtchBookg', 'true')
223
+
224
+ subject.should_not have_xml('//Document/CstmrDrctDbtInitn/PmtInf[3]')
225
+ end
226
+ end
227
+
228
+ context 'with transactions containing different group criteria' do
229
+ subject do
230
+ sdd = direct_debit
231
+
232
+ sdd.add_transaction(direct_debt_transaction.merge requested_date: Date.today + 1, local_instrument: 'CORE', sequence_type: 'OOFF', amount: 1)
233
+ sdd.add_transaction(direct_debt_transaction.merge requested_date: Date.today + 1, local_instrument: 'CORE', sequence_type: 'FNAL', amount: 2)
234
+ sdd.add_transaction(direct_debt_transaction.merge requested_date: Date.today + 1, local_instrument: 'B2B', sequence_type: 'OOFF', amount: 4)
235
+ sdd.add_transaction(direct_debt_transaction.merge requested_date: Date.today + 1, local_instrument: 'B2B', sequence_type: 'FNAL', amount: 8)
236
+ sdd.add_transaction(direct_debt_transaction.merge requested_date: Date.today + 2, local_instrument: 'CORE', sequence_type: 'OOFF', amount: 16)
237
+ sdd.add_transaction(direct_debt_transaction.merge requested_date: Date.today + 2, local_instrument: 'CORE', sequence_type: 'FNAL', amount: 32)
238
+ sdd.add_transaction(direct_debt_transaction.merge requested_date: Date.today + 2, local_instrument: 'B2B', sequence_type: 'OOFF', amount: 64)
239
+ sdd.add_transaction(direct_debt_transaction.merge requested_date: Date.today + 2, local_instrument: 'B2B', sequence_type: 'FNAL', amount: 128)
240
+
241
+ sdd.to_xml
242
+ end
243
+
244
+ it 'should contain multiple payment_informations' do
245
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[1]/ReqdColltnDt', (Date.today + 1).iso8601)
246
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[1]/PmtTpInf/LclInstrm/Cd', 'CORE')
247
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[1]/PmtTpInf/SeqTp', 'OOFF')
248
+
249
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[2]/ReqdColltnDt', (Date.today + 1).iso8601)
250
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[2]/PmtTpInf/LclInstrm/Cd', 'CORE')
251
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[2]/PmtTpInf/SeqTp', 'FNAL')
252
+
253
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[3]/ReqdColltnDt', (Date.today + 1).iso8601)
254
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[3]/PmtTpInf/LclInstrm/Cd', 'B2B')
255
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[3]/PmtTpInf/SeqTp', 'OOFF')
256
+
257
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[4]/ReqdColltnDt', (Date.today + 1).iso8601)
258
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[4]/PmtTpInf/LclInstrm/Cd', 'B2B')
259
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[4]/PmtTpInf/SeqTp', 'FNAL')
260
+
261
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[5]/ReqdColltnDt', (Date.today + 2).iso8601)
262
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[5]/PmtTpInf/LclInstrm/Cd', 'CORE')
263
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[5]/PmtTpInf/SeqTp', 'OOFF')
264
+
265
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[6]/ReqdColltnDt', (Date.today + 2).iso8601)
266
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[6]/PmtTpInf/LclInstrm/Cd', 'CORE')
267
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[6]/PmtTpInf/SeqTp', 'FNAL')
268
+
269
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[7]/ReqdColltnDt', (Date.today + 2).iso8601)
270
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[7]/PmtTpInf/LclInstrm/Cd', 'B2B')
271
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[7]/PmtTpInf/SeqTp', 'OOFF')
272
+
273
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[8]/ReqdColltnDt', (Date.today + 2).iso8601)
274
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[8]/PmtTpInf/LclInstrm/Cd', 'B2B')
275
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[8]/PmtTpInf/SeqTp', 'FNAL')
276
+ end
277
+
278
+ it 'should have multiple control sums' do
279
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[1]/CtrlSum', '1.00')
280
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[2]/CtrlSum', '2.00')
281
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[3]/CtrlSum', '4.00')
282
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[4]/CtrlSum', '8.00')
283
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[5]/CtrlSum', '16.00')
284
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[6]/CtrlSum', '32.00')
285
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[7]/CtrlSum', '64.00')
286
+ subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[8]/CtrlSum', '128.00')
287
+ end
288
+ end
74
289
  end
75
290
  end
76
291
  end
@@ -4,50 +4,34 @@ require 'spec_helper'
4
4
  describe SEPA::DirectDebitTransaction do
5
5
  it 'should initialize a new transaction' do
6
6
  expect(
7
- SEPA::DirectDebitTransaction.new :name => 'Zahlemann & Söhne Gbr',
8
- :bic => 'SPUEDE2UXXX',
9
- :iban => 'DE21500500009876543210',
10
- :amount => 39.99,
11
- :reference => 'XYZ-1234/123',
12
- :remittance_information => 'Vielen Dank für Ihren Einkauf!',
13
- :mandate_id => 'K-02-2011-12345',
14
- :mandate_date_of_signature => Date.new(2011,1,25)
7
+ SEPA::DirectDebitTransaction.new name: 'Zahlemann & Söhne Gbr',
8
+ bic: 'SPUEDE2UXXX',
9
+ iban: 'DE21500500009876543210',
10
+ amount: 39.99,
11
+ reference: 'XYZ-1234/123',
12
+ remittance_information: 'Vielen Dank für Ihren Einkauf!',
13
+ mandate_id: 'K-02-2011-12345',
14
+ mandate_date_of_signature: Date.new(2011,1,25)
15
15
  ).to be_valid
16
16
  end
17
17
 
18
18
  context 'Mandate Date of Signature' do
19
- it 'should allow valid value' do
20
- [ Date.today, Date.today - 1 ].each do |valid_value|
21
- expect(
22
- SEPA::DirectDebitTransaction.new :mandate_date_of_signature => valid_value
23
- ).to have(:no).errors_on(:mandate_date_of_signature)
24
- end
19
+ it 'should accept valid value' do
20
+ SEPA::DirectDebitTransaction.should accept(Date.today, Date.today - 1, for: :mandate_date_of_signature)
25
21
  end
26
22
 
27
- it 'should not allow invalid value' do
28
- [ nil, '2010-12-01', Date.today + 1 ].each do |invalid_value|
29
- expect(
30
- SEPA::DirectDebitTransaction.new :mandate_date_of_signature => invalid_value
31
- ).to have_at_least(1).errors_on(:mandate_date_of_signature)
32
- end
23
+ it 'should not accept invalid value' do
24
+ SEPA::DirectDebitTransaction.should_not accept(nil, '2010-12-01', Date.today + 1, for: :mandate_date_of_signature)
33
25
  end
34
26
  end
35
27
 
36
28
  context 'Mandate ID' do
37
29
  it 'should allow valid value' do
38
- [ 'XYZ-123', 'X' * 35 ].each do |valid_value|
39
- expect(
40
- SEPA::DirectDebitTransaction.new :mandate_id => valid_value
41
- ).to have(:no).errors_on(:mandate_id)
42
- end
30
+ SEPA::DirectDebitTransaction.should accept('XYZ-123', 'X' * 35, for: :mandate_id)
43
31
  end
44
32
 
45
33
  it 'should not allow invalid value' do
46
- [ nil, '', 'X' * 36 ].each do |invalid_value|
47
- expect(
48
- SEPA::DirectDebitTransaction.new :mandate_id => invalid_value
49
- ).to have_at_least(1).errors_on(:mandate_id)
50
- end
34
+ SEPA::DirectDebitTransaction.should_not accept(nil, '', 'X' * 36, for: :mandate_id)
51
35
  end
52
36
  end
53
37
  end