aba 0.0.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/.rspec +3 -1
- data/.travis.yml +6 -0
- data/README.md +109 -18
- data/aba.gemspec +7 -6
- data/lib/aba.rb +6 -114
- data/lib/aba/batch.rb +224 -0
- data/lib/aba/entry.rb +17 -0
- data/lib/aba/return.rb +72 -0
- data/lib/aba/transaction.rb +99 -35
- data/lib/aba/validations.rb +84 -14
- data/lib/aba/version.rb +1 -1
- data/spec/lib/aba/batch_spec.rb +101 -0
- data/spec/lib/aba/return_spec.rb +47 -0
- data/spec/{transaction_spec.rb → lib/aba/transaction_spec.rb} +6 -5
- data/spec/lib/aba/validations_spec.rb +215 -0
- data/spec/lib/aba_spec.rb +21 -0
- data/spec/spec_helper.rb +2 -0
- metadata +40 -17
- data/spec/aba_spec.rb +0 -40
- data/spec/validations_spec.rb +0 -47
data/spec/aba_spec.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Aba do
|
4
|
-
subject(:aba) do
|
5
|
-
aba = Aba.new(bsb: "123-345", financial_institution: "WPC", user_name: "John Doe",
|
6
|
-
user_id: "466364", description: "Payroll", process_at: Time.new(2014, 12, 01, 10, 22, 0))
|
7
|
-
|
8
|
-
[30, -20].each do |amount|
|
9
|
-
aba.transactions << Aba::Transaction.new(
|
10
|
-
:bsb => "342-342",
|
11
|
-
:account_number => "3244654",
|
12
|
-
:amount => amount,
|
13
|
-
:account_name => "John Doe",
|
14
|
-
:payment_id => "P2345543",
|
15
|
-
:transaction_code => 53,
|
16
|
-
:lodgement_reference => "R435564",
|
17
|
-
:trace_bsb => "453-543",
|
18
|
-
:trace_account_number => "45656733",
|
19
|
-
:name_of_remitter => "Remitter"
|
20
|
-
)
|
21
|
-
end
|
22
|
-
|
23
|
-
aba
|
24
|
-
end
|
25
|
-
|
26
|
-
describe "#to_s" do
|
27
|
-
it "should contain a descriptive record" do
|
28
|
-
expect(subject.to_s).to include("0123-345 01WPC John Doe 466364Payroll 0112141022 \r\n")
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should contain transactions records" do
|
32
|
-
expect(subject.to_s).to include("1342-342 3244654 530000000030John Doe R435564 453-543 45656733Remitter 00000000\r\n")
|
33
|
-
expect(subject.to_s).to include("1342-342 3244654 530000000020John Doe R435564 453-543 45656733Remitter 00000000\r\n")
|
34
|
-
end
|
35
|
-
|
36
|
-
it "should contain a batch control record" do
|
37
|
-
expect(subject.to_s).to include("7999-999 000000001000000000300000000020 000002 ")
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
data/spec/validations_spec.rb
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Aba::Validations do
|
4
|
-
let(:clean_room) do
|
5
|
-
Class.new(Object) do
|
6
|
-
include Aba::Validations
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
subject(:test_instance) { clean_room.new }
|
11
|
-
|
12
|
-
describe "#valid?" do
|
13
|
-
it "should validate presence of attrs" do
|
14
|
-
clean_room.instance_eval do
|
15
|
-
attr_accessor :attr1
|
16
|
-
validates_presence_of :attr1
|
17
|
-
end
|
18
|
-
|
19
|
-
expect(subject.valid?).to eq false
|
20
|
-
expect(subject.errors).to eq ["attr1 is empty"]
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should validate bsb format" do
|
24
|
-
clean_room.instance_eval do
|
25
|
-
attr_accessor :attr1
|
26
|
-
validates_bsb :attr1
|
27
|
-
end
|
28
|
-
|
29
|
-
subject.attr1 = "234456"
|
30
|
-
|
31
|
-
expect(subject.valid?).to eq false
|
32
|
-
expect(subject.errors).to eq ["attr1 format is incorrect"]
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should validate length" do
|
36
|
-
clean_room.instance_eval do
|
37
|
-
attr_accessor :attr1
|
38
|
-
validates_max_length :attr1, 5
|
39
|
-
end
|
40
|
-
|
41
|
-
subject.attr1 = "234456642"
|
42
|
-
|
43
|
-
expect(subject.valid?).to eq false
|
44
|
-
expect(subject.errors).to eq ["attr1 length must not exceed 5 characters"]
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|