lsv-plus 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,62 @@
1
+ require 'lsv_plus/record'
2
+
3
+ RSpec.describe LSVplus::Record do
4
+ let(:attributes) do
5
+ {
6
+ processing_date: Date.today + 1,
7
+ creditor_bank_clearing_number: 1337,
8
+ amount: BigDecimal.new('1337.42'),
9
+ debitor_bank_clearing_number: 42,
10
+ creditor_iban: 'CH9300762011623852957',
11
+ creditor_address: ['Fancy AG', 'Funnystreet 42'],
12
+ debitor_account: '123.456-78XY',
13
+ debitor_address: ['Debit AG', 'Other Street 1337', 'Somewhere City'],
14
+ message: ['Invoice 133 via BDD'],
15
+ reference_type: 'A',
16
+ reference: '200002000000004443332000061',
17
+ esr_member_id: '133742',
18
+ }
19
+ end
20
+ let(:instance) { LSVplus::Record.new(attributes) }
21
+
22
+ describe 'defaults' do
23
+ it 'has a type of 875' do
24
+ expect(instance.type).to eq('875')
25
+ end
26
+
27
+ it 'has a version of 0' do
28
+ expect(instance.version).to eq('0')
29
+ end
30
+ end
31
+
32
+ describe 'validations' do
33
+ describe '#processing_date' do
34
+ it 'it prevents 31 days in future' do
35
+ attributes[:processing_date] = Date.today + 31
36
+ expect { instance }.to raise_error(LSVplus::Record::InvalidProcessingDate)
37
+ end
38
+
39
+ it 'allows 30 days in future' do
40
+ attributes[:processing_date] = Date.today + 30
41
+ expect { instance }.to_not raise_error
42
+ end
43
+
44
+ it 'prevents 11 days in past' do
45
+ attributes[:processing_date] = Date.today - 11
46
+ expect { instance }.to raise_error(LSVplus::Record::InvalidProcessingDate)
47
+ end
48
+
49
+ it 'allows 10 days in past' do
50
+ attributes[:processing_date] = Date.today - 10
51
+ expect { instance }.to_not raise_error
52
+ end
53
+ end
54
+
55
+ describe '#amount' do
56
+ it "prevents amounts higher than 99'999'999.99" do
57
+ attributes[:amount] = BigDecimal.new('99_999_999.99') + BigDecimal.new('0.01')
58
+ expect { instance }.to raise_error(LSVplus::Record::InvalidAmount)
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,24 @@
1
+ require 'coveralls'
2
+ Coveralls.wear!
3
+
4
+ RSpec.configure do |config|
5
+ config.expect_with :rspec do |expectations|
6
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
7
+ end
8
+
9
+ config.mock_with :rspec do |mocks|
10
+ mocks.verify_partial_doubles = true
11
+ end
12
+
13
+ config.filter_run :focus
14
+ config.run_all_when_everything_filtered = true
15
+ config.example_status_persistence_file_path = 'spec/examples.txt'
16
+
17
+ config.disable_monkey_patching!
18
+ if config.files_to_run.one?
19
+ config.default_formatter = 'doc'
20
+ end
21
+
22
+ config.order = :random
23
+ Kernel.srand config.seed
24
+ end
@@ -0,0 +1,90 @@
1
+ require 'lsv_plus/total_record_formatter'
2
+
3
+ RSpec.describe LSVplus::TotalRecordFormatter do
4
+ let(:file) do
5
+ LSVplus::File.new(
6
+ creator_identification: 'YOLO1',
7
+ currency: 'CHF',
8
+ processing_type: 'P',
9
+ creation_date: Date.new(2016, 1, 5),
10
+ lsv_identification: 'YOLO1',
11
+ )
12
+ end
13
+ let(:instance) { LSVplus::TotalRecordFormatter.new(file) }
14
+
15
+ describe '.call' do
16
+ let(:total_record_formatter_double) { instance_double(LSVplus::TotalRecordFormatter) }
17
+
18
+ it 'initializes a new instance and calls `#call`' do
19
+ expect(LSVplus::TotalRecordFormatter).
20
+ to receive(:new).with(file).and_return(total_record_formatter_double)
21
+ expect(total_record_formatter_double).to receive(:call)
22
+ LSVplus::TotalRecordFormatter.call(file)
23
+ end
24
+ end
25
+
26
+ describe '#call' do
27
+ it 'returns all the formatted fields as string' do
28
+ %i(creation_date creator_identification record_number currency total_amount).each do |meth|
29
+ expect(instance).to receive(meth).with(no_args).and_call_original.ordered
30
+ end
31
+ expect(instance.call).to be_a(String)
32
+ end
33
+ end
34
+
35
+ describe '#creation_date' do
36
+ let(:value) { Date.today }
37
+ before do
38
+ allow(file).to receive(:creation_date).and_return(value)
39
+ end
40
+
41
+ it 'calls file.creation_date' do
42
+ expect(file).to receive(:creation_date).and_return(value)
43
+ instance.creation_date
44
+ end
45
+
46
+ it 'uses LSVplus::FormattingHelper to format it' do
47
+ expect(LSVplus::FormattingHelper).to receive(:date).with(value).and_return('value')
48
+ expect(instance.creation_date).to eq('value')
49
+ end
50
+ end
51
+
52
+ describe '#creator_identification' do
53
+ it 'calls file.creator_identification' do
54
+ expect(file).to receive(:creator_identification).and_return('value')
55
+ expect(instance.creator_identification).to eq('value')
56
+ end
57
+ end
58
+
59
+ describe '#record_number' do
60
+ it 'uses LSVplus::FormattingHelper to format it' do
61
+ allow(file).to receive(:records).and_return([1, 2, 3])
62
+ expect(LSVplus::FormattingHelper).to receive(:index).with(3).and_return('value')
63
+ expect(instance.record_number).to eq('value')
64
+ end
65
+ end
66
+
67
+ describe '#currency' do
68
+ it 'calls file.currency' do
69
+ expect(file).to receive(:currency).and_return('value')
70
+ expect(instance.currency).to eq('value')
71
+ end
72
+ end
73
+
74
+ describe '#total_amount' do
75
+ let(:value) { 1234 }
76
+ before do
77
+ allow(file).to receive(:total).and_return(value)
78
+ end
79
+
80
+ it 'calls file.total_amount' do
81
+ expect(file).to receive(:total).and_return(value)
82
+ instance.total_amount
83
+ end
84
+
85
+ it 'uses LSVplus::FormattingHelper to format it' do
86
+ expect(LSVplus::FormattingHelper).to receive(:amount).with(value).and_return('value')
87
+ expect(instance.total_amount).to eq('value')
88
+ end
89
+ end
90
+ end
metadata ADDED
@@ -0,0 +1,134 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lsv-plus
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Raffael Schmid
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-01-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '10.4'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '10.4'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.4'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.4'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec_junit_formatter
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.2'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.2'
55
+ - !ruby/object:Gem::Dependency
56
+ name: coveralls
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.8'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.8'
69
+ description: Create a LSV+ file which can be uploaded to your bank.
70
+ email:
71
+ - raffael.schmid@welltravel.com
72
+ executables:
73
+ - lsv-plus
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - ".rspec"
79
+ - ".ruby-version"
80
+ - Gemfile
81
+ - Gemfile.lock
82
+ - README.md
83
+ - bin/lsv-plus
84
+ - lib/lsv-plus.rb
85
+ - lib/lsv_plus.rb
86
+ - lib/lsv_plus/base_container.rb
87
+ - lib/lsv_plus/errors.rb
88
+ - lib/lsv_plus/file.rb
89
+ - lib/lsv_plus/formatting_helper.rb
90
+ - lib/lsv_plus/record.rb
91
+ - lib/lsv_plus/record_formatter.rb
92
+ - lib/lsv_plus/total_record_formatter.rb
93
+ - lib/lsv_plus/version.rb
94
+ - lsv-plus.gemspec
95
+ - spec/file_spec.rb
96
+ - spec/formatting_helper_spec.rb
97
+ - spec/integration/simple_spec.rb
98
+ - spec/record_formatter_spec.rb
99
+ - spec/record_spec.rb
100
+ - spec/spec_helper.rb
101
+ - spec/total_record_formatter_spec.rb
102
+ homepage: https://github.com/wtag/lsv-plus
103
+ licenses:
104
+ - MIT
105
+ metadata: {}
106
+ post_install_message:
107
+ rdoc_options: []
108
+ require_paths:
109
+ - lib
110
+ required_ruby_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ required_rubygems_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ requirements: []
121
+ rubyforge_project:
122
+ rubygems_version: 2.4.5.1
123
+ signing_key:
124
+ specification_version: 4
125
+ summary: Gem to create LSV+ files
126
+ test_files:
127
+ - spec/file_spec.rb
128
+ - spec/formatting_helper_spec.rb
129
+ - spec/integration/simple_spec.rb
130
+ - spec/record_formatter_spec.rb
131
+ - spec/record_spec.rb
132
+ - spec/spec_helper.rb
133
+ - spec/total_record_formatter_spec.rb
134
+ has_rdoc: