ci_power 0.0.31 → 0.0.32

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.
@@ -19,7 +19,7 @@ module CiPower
19
19
 
20
20
  private
21
21
  def _fill_up(data)
22
- line = ""
22
+ line = ''
23
23
  if data.is_a? Hash
24
24
  data.each do |method_name, length|
25
25
  field = method(method_name).call
@@ -27,10 +27,10 @@ module CiPower
27
27
  # Workaround for special characters problem
28
28
  given_field_size = field.scan(/./mu).size
29
29
  # truncate if field is too long
30
- if given_field_size > field.size
31
- field = truncate(field, field.size)
30
+ if given_field_size > length
31
+ field = truncate(field, length)
32
32
  end
33
- if given_field_size < field.size
33
+ if given_field_size < length
34
34
  length = adjust_length(field, length)
35
35
  end
36
36
  line << field.ljust(length)
@@ -1,3 +1,3 @@
1
1
  module CiPower
2
- VERSION = "0.0.31"
2
+ VERSION = '0.0.32'
3
3
  end
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ module CiPower
4
+ describe Record do
5
+ let(:record) { Record.new }
6
+
7
+ describe '#_fill_up' do
8
+ context 'when data is a hash' do
9
+ context 'when attribute value is too long' do
10
+ it 'should truncate the attribute length' do
11
+ record.record_type = 'TästTöstTüst'
12
+ record.send(:_fill_up, {:record_type => 10}).should == 'TästTöstTü'
13
+ end
14
+ end
15
+ end
16
+ context 'when attribute value is too short' do
17
+ it 'should fill up attribute value with spaces' do
18
+ record.record_type = 'Täst'
19
+ record.send(:_fill_up, {:record_type => 10}).should == 'Täst '
20
+ end
21
+ end
22
+ end
23
+
24
+ describe '#adjust_length' do
25
+
26
+ end
27
+
28
+ describe '#truncate' do
29
+ context 'when string size is longer than length' do
30
+ it 'should truncate string to given length' do
31
+ record.send(:truncate, 'TestTestTest', 4).should == 'Test'
32
+ end
33
+ end
34
+ context 'when string size is shorter than length' do
35
+ it 'should not truncate string' do
36
+ record.send(:truncate, 'TestTestTest', 20).should == 'TestTestTest'
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: ci_power
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.31
5
+ version: 0.0.32
6
6
  platform: ruby
7
7
  authors:
8
8
  - Maik Duff
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2013-02-28 00:00:00 +01:00
13
+ date: 2013-03-05 00:00:00 +01:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -75,6 +75,7 @@ files:
75
75
  - spec/spec_helper.rb
76
76
  - spec/ci_power/export_spec.rb
77
77
  - spec/ci_power/installment_plan_spec.rb
78
+ - spec/ci_power/record_spec.rb
78
79
  has_rdoc: true
79
80
  homepage: http://www.impac.ch
80
81
  licenses: []
@@ -107,3 +108,4 @@ test_files:
107
108
  - spec/spec_helper.rb
108
109
  - spec/ci_power/export_spec.rb
109
110
  - spec/ci_power/installment_plan_spec.rb
111
+ - spec/ci_power/record_spec.rb