kosi 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,77 +1,77 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
- require 'kosi'
4
-
5
- describe Kosi::Align do
6
- context :apply do
7
- cases = [
8
- {
9
- case_no: 1,
10
- case_title: 'no options case',
11
- options: {},
12
- text: 'h',
13
- max_value: 3,
14
- diff: 0,
15
- expected: Kosi::Align::TYPE::LEFT,
16
- expected: 'h '
17
- },
18
- {
19
- case_no: 2,
20
- case_title: 'align options right case',
21
- options: { Kosi::OptionKeys::ALIGN => Kosi::Align::TYPE::RIGHT },
22
- text: 'h',
23
- max_value: 3,
24
- diff: 0,
25
- expected_option: Kosi::Align::TYPE::RIGHT,
26
- expected: ' h'
27
- },
28
- {
29
- case_no: 3,
30
- case_title: 'align options left case',
31
- options: { Kosi::OptionKeys::ALIGN => Kosi::Align::TYPE::LEFT },
32
- text: 'h',
33
- max_value: 3,
34
- diff: 0,
35
- expected_option: Kosi::Align::TYPE::LEFT,
36
- expected: 'h '
37
- },
38
- {
39
- case_no: 4,
40
- case_title: 'align options center case',
41
- options: { Kosi::OptionKeys::ALIGN => Kosi::Align::TYPE::CENTER },
42
- text: 'h',
43
- max_value: 3,
44
- diff: 0,
45
- expected_option: Kosi::Align::TYPE::CENTER,
46
- expected: ' h '
47
- }
48
- ]
49
-
50
- cases.each do |c|
51
- it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
52
- begin
53
- case_before c
54
-
55
- # -- given --
56
- header = Kosi::Align.new(c[:options])
57
-
58
- # -- when --
59
- actual = header.apply(c[:text], c[:max_value], c[:diff])
60
-
61
- # -- then --
62
- expect(actual).to eq(c[:expected])
63
- ensure
64
- case_after c
65
- end
66
- end
67
-
68
- def case_before(c)
69
- # implement each case before
70
- end
71
-
72
- def case_after(c)
73
- # implement each case after
74
- end
75
- end
76
- end
77
- end
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+ require 'kosi'
4
+
5
+ describe Kosi::Align do
6
+ context :apply do
7
+ cases = [
8
+ {
9
+ case_no: 1,
10
+ case_title: 'no options case',
11
+ options: {},
12
+ text: 'h',
13
+ max_value: 3,
14
+ diff: 0,
15
+ expected: Kosi::Align::TYPE::LEFT,
16
+ expected: 'h '
17
+ },
18
+ {
19
+ case_no: 2,
20
+ case_title: 'align options right case',
21
+ options: { Kosi::OptionKeys::ALIGN => Kosi::Align::TYPE::RIGHT },
22
+ text: 'h',
23
+ max_value: 3,
24
+ diff: 0,
25
+ expected_option: Kosi::Align::TYPE::RIGHT,
26
+ expected: ' h'
27
+ },
28
+ {
29
+ case_no: 3,
30
+ case_title: 'align options left case',
31
+ options: { Kosi::OptionKeys::ALIGN => Kosi::Align::TYPE::LEFT },
32
+ text: 'h',
33
+ max_value: 3,
34
+ diff: 0,
35
+ expected_option: Kosi::Align::TYPE::LEFT,
36
+ expected: 'h '
37
+ },
38
+ {
39
+ case_no: 4,
40
+ case_title: 'align options center case',
41
+ options: { Kosi::OptionKeys::ALIGN => Kosi::Align::TYPE::CENTER },
42
+ text: 'h',
43
+ max_value: 3,
44
+ diff: 0,
45
+ expected_option: Kosi::Align::TYPE::CENTER,
46
+ expected: ' h '
47
+ }
48
+ ]
49
+
50
+ cases.each do |c|
51
+ it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
52
+ begin
53
+ case_before c
54
+
55
+ # -- given --
56
+ header = Kosi::Align.new(c[:options])
57
+
58
+ # -- when --
59
+ actual = header.apply(c[:text], c[:max_value], c[:diff])
60
+
61
+ # -- then --
62
+ expect(actual).to eq(c[:expected])
63
+ ensure
64
+ case_after c
65
+ end
66
+ end
67
+
68
+ def case_before(c)
69
+ # implement each case before
70
+ end
71
+
72
+ def case_after(c)
73
+ # implement each case after
74
+ end
75
+ end
76
+ end
77
+ end
@@ -1,59 +1,59 @@
1
- require 'spec_helper'
2
- require 'kosi'
3
-
4
- describe Kosi::ConnectorChar do
5
- context :value do
6
- cases = [
7
- {
8
- case_no: 1,
9
- case_title: 'no options case',
10
- options: {},
11
- expected: Kosi::ConnectorChar::DEFAULT
12
- },
13
- {
14
- case_no: 2,
15
- case_title: 'valid connector char options case',
16
- options: { Kosi::OptionKeys::CONNECTOR_CHAR => '@' },
17
- expected: '@'
18
- },
19
- {
20
- case_no: 3,
21
- case_title: 'invalid connector char options case',
22
- options: { Kosi::OptionKeys::CONNECTOR_CHAR => '++' },
23
- expect_error: true
24
- }
25
- ]
26
-
27
- cases.each do |c|
28
- it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
29
- begin
30
- case_before c
31
-
32
- # -- given --
33
- if c[:expect_error]
34
- -> { Kosi::ConnectorChar.new(c[:options]) }
35
- .should raise_error(ArgumentError)
36
- next
37
- end
38
- connector_char = Kosi::ConnectorChar.new(c[:options])
39
-
40
- # -- when --
41
- actual = connector_char.value
42
-
43
- # -- then --
44
- expect(actual).to eq(c[:expected])
45
- ensure
46
- case_after c
47
- end
48
- end
49
-
50
- def case_before(c)
51
- # implement each case before
52
- end
53
-
54
- def case_after(c)
55
- # implement each case after
56
- end
57
- end
58
- end
59
- end
1
+ require 'spec_helper'
2
+ require 'kosi'
3
+
4
+ describe Kosi::ConnectorChar do
5
+ context :value do
6
+ cases = [
7
+ {
8
+ case_no: 1,
9
+ case_title: 'no options case',
10
+ options: {},
11
+ expected: Kosi::ConnectorChar::DEFAULT
12
+ },
13
+ {
14
+ case_no: 2,
15
+ case_title: 'valid connector char options case',
16
+ options: { Kosi::OptionKeys::CONNECTOR_CHAR => '@' },
17
+ expected: '@'
18
+ },
19
+ {
20
+ case_no: 3,
21
+ case_title: 'invalid connector char options case',
22
+ options: { Kosi::OptionKeys::CONNECTOR_CHAR => '++' },
23
+ expect_error: true
24
+ }
25
+ ]
26
+
27
+ cases.each do |c|
28
+ it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
29
+ begin
30
+ case_before c
31
+
32
+ # -- given --
33
+ if c[:expect_error]
34
+ -> { Kosi::ConnectorChar.new(c[:options]) }
35
+ .should raise_error(ArgumentError)
36
+ next
37
+ end
38
+ connector_char = Kosi::ConnectorChar.new(c[:options])
39
+
40
+ # -- when --
41
+ actual = connector_char.value
42
+
43
+ # -- then --
44
+ expect(actual).to eq(c[:expected])
45
+ ensure
46
+ case_after c
47
+ end
48
+ end
49
+
50
+ def case_before(c)
51
+ # implement each case before
52
+ end
53
+
54
+ def case_after(c)
55
+ # implement each case after
56
+ end
57
+ end
58
+ end
59
+ end
@@ -1,93 +1,93 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
- require 'kosi'
4
-
5
- describe Kosi::Header do
6
- context :value do
7
- cases = [
8
- {
9
- case_no: 1,
10
- case_title: 'no options case',
11
- options: {},
12
- expected: nil
13
- },
14
- {
15
- case_no: 2,
16
- case_title: 'align options left case',
17
- options: { Kosi::OptionKeys::HEADER => %w(header1 header2) },
18
- expected: %w(header1 header2)
19
- }
20
- ]
21
-
22
- cases.each do |c|
23
- it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
24
- begin
25
- case_before c
26
-
27
- # -- given --
28
- header = Kosi::Header.new(c[:options])
29
-
30
- # -- when --
31
- actual = header.value
32
-
33
- # -- then --
34
- expect(actual).to eq(c[:expected])
35
- ensure
36
- case_after c
37
- end
38
- end
39
-
40
- def case_before(c)
41
- # implement each case before
42
- end
43
-
44
- def case_after(c)
45
- # implement each case after
46
- end
47
- end
48
- end
49
-
50
- context :empty? do
51
- cases = [
52
- {
53
- case_no: 1,
54
- case_title: 'no options case',
55
- options: {},
56
- expected: true
57
- },
58
- {
59
- case_no: 2,
60
- case_title: 'align options left case',
61
- options: { Kosi::OptionKeys::HEADER => %w(header1 header2) },
62
- expected: false
63
- }
64
- ]
65
-
66
- cases.each do |c|
67
- it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
68
- begin
69
- case_before c
70
-
71
- # -- given --
72
- header = Kosi::Header.new(c[:options])
73
-
74
- # -- when --
75
- actual = header.empty?
76
-
77
- # -- then --
78
- expect(actual).to eq(c[:expected])
79
- ensure
80
- case_after c
81
- end
82
- end
83
-
84
- def case_before(c)
85
- # implement each case before
86
- end
87
-
88
- def case_after(c)
89
- # implement each case after
90
- end
91
- end
92
- end
93
- end
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+ require 'kosi'
4
+
5
+ describe Kosi::Header do
6
+ context :value do
7
+ cases = [
8
+ {
9
+ case_no: 1,
10
+ case_title: 'no options case',
11
+ options: {},
12
+ expected: nil
13
+ },
14
+ {
15
+ case_no: 2,
16
+ case_title: 'align options left case',
17
+ options: { Kosi::OptionKeys::HEADER => %w(header1 header2) },
18
+ expected: %w(header1 header2)
19
+ }
20
+ ]
21
+
22
+ cases.each do |c|
23
+ it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
24
+ begin
25
+ case_before c
26
+
27
+ # -- given --
28
+ header = Kosi::Header.new(c[:options])
29
+
30
+ # -- when --
31
+ actual = header.value
32
+
33
+ # -- then --
34
+ expect(actual).to eq(c[:expected])
35
+ ensure
36
+ case_after c
37
+ end
38
+ end
39
+
40
+ def case_before(c)
41
+ # implement each case before
42
+ end
43
+
44
+ def case_after(c)
45
+ # implement each case after
46
+ end
47
+ end
48
+ end
49
+
50
+ context :empty? do
51
+ cases = [
52
+ {
53
+ case_no: 1,
54
+ case_title: 'no options case',
55
+ options: {},
56
+ expected: true
57
+ },
58
+ {
59
+ case_no: 2,
60
+ case_title: 'align options left case',
61
+ options: { Kosi::OptionKeys::HEADER => %w(header1 header2) },
62
+ expected: false
63
+ }
64
+ ]
65
+
66
+ cases.each do |c|
67
+ it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
68
+ begin
69
+ case_before c
70
+
71
+ # -- given --
72
+ header = Kosi::Header.new(c[:options])
73
+
74
+ # -- when --
75
+ actual = header.empty?
76
+
77
+ # -- then --
78
+ expect(actual).to eq(c[:expected])
79
+ ensure
80
+ case_after c
81
+ end
82
+ end
83
+
84
+ def case_before(c)
85
+ # implement each case before
86
+ end
87
+
88
+ def case_after(c)
89
+ # implement each case after
90
+ end
91
+ end
92
+ end
93
+ end