kosi 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +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
@@ -0,0 +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
@@ -0,0 +1,59 @@
1
+ require 'spec_helper'
2
+ require 'kosi'
3
+
4
+ describe Kosi::HorizontalBorderChar do
5
+ context :value do
6
+ cases = [
7
+ {
8
+ case_no: 1,
9
+ case_title: 'no options case',
10
+ options: {},
11
+ expected: Kosi::HorizontalBorderChar::DEFAULT
12
+ },
13
+ {
14
+ case_no: 2,
15
+ case_title: 'valid horizontal_border_char options case',
16
+ options: { Kosi::OptionKeys::HORIZONTAL_BORDER_CHAR => '@' },
17
+ expected: '@'
18
+ },
19
+ {
20
+ case_no: 3,
21
+ case_title: 'invalid horizontal_border_char options case',
22
+ options: { Kosi::OptionKeys::HORIZONTAL_BORDER_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::HorizontalBorderChar.new(c[:options]) }
35
+ .should raise_error(ArgumentError)
36
+ next
37
+ end
38
+ horizontal_border_char = Kosi::HorizontalBorderChar.new(c[:options])
39
+
40
+ # -- when --
41
+ actual = horizontal_border_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
@@ -0,0 +1,55 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+ require 'kosi'
4
+
5
+ describe Kosi::SeparateEachRow do
6
+ context :value do
7
+ cases = [
8
+ {
9
+ case_no: 1,
10
+ case_title: 'no options case',
11
+ options: {},
12
+ expected: Kosi::SeparateEachRow::DEFAULT
13
+ },
14
+ {
15
+ case_no: 2,
16
+ case_title: 'seprate_each_row options true case',
17
+ options: { Kosi::OptionKeys::SEPARATE_EACH_ROW => true },
18
+ expected: true
19
+ },
20
+ {
21
+ case_no: 3,
22
+ case_title: 'seprate_each_row options false case',
23
+ options: { Kosi::OptionKeys::SEPARATE_EACH_ROW => false },
24
+ expected: false
25
+ }
26
+ ]
27
+
28
+ cases.each do |c|
29
+ it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
30
+ begin
31
+ case_before c
32
+
33
+ # -- given --
34
+ separate_each_row = Kosi::SeparateEachRow.new(c[:options])
35
+
36
+ # -- when --
37
+ actual = separate_each_row.value
38
+
39
+ # -- then --
40
+ expect(actual).to eq(c[:expected])
41
+ ensure
42
+ case_after c
43
+ end
44
+ end
45
+
46
+ def case_before(c)
47
+ # implement each case before
48
+ end
49
+
50
+ def case_after(c)
51
+ # implement each case after
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,56 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+ require 'kosi/validators/each_array_length_validator'
4
+
5
+ describe Kosi::Validators::EachArrayLength do
6
+ context :validate do
7
+ cases = [
8
+ {
9
+ case_no: 1,
10
+ case_title: 'Same Length Array case',
11
+ inputs: [[*1..5], [*6..10]],
12
+ },
13
+ {
14
+ case_no: 2,
15
+ case_title: 'Zero Length Array case',
16
+ inputs: [[], []],
17
+ },
18
+ {
19
+ case_no: 3,
20
+ case_title: 'Different Length Array case',
21
+ inputs: [[*1..5], [*6..11]],
22
+ expect_error: true,
23
+ error_class: ArgumentError
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
+ # nothing
34
+
35
+ # -- when/then --
36
+ if c[:expect_error]
37
+ expect{ Kosi::Validators::EachArrayLength.validate(c[:inputs]) }.to raise_error(c[:error_class])
38
+ next
39
+ else
40
+ expect{ Kosi::Validators::EachArrayLength.validate(c[:inputs]) }.not_to raise_error
41
+ end
42
+ ensure
43
+ case_after c
44
+ end
45
+ end
46
+
47
+ def case_before(c)
48
+ # implement each case before
49
+ end
50
+
51
+ def case_after(c)
52
+ # implement each case after
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,51 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+ require 'kosi/validators/row_type_validator'
4
+
5
+ describe Kosi::Validators::RowType do
6
+ context :validate do
7
+ cases = [
8
+ {
9
+ case_no: 1,
10
+ case_title: 'Array case',
11
+ inputs: ['Array'],
12
+ },
13
+ {
14
+ case_no: 2,
15
+ case_title: 'Not Array case',
16
+ inputs: "not Array",
17
+ expect_error: true,
18
+ error_class: ArgumentError
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
+ # nothing
29
+
30
+ # -- when/then --
31
+ if c[:expect_error]
32
+ expect{ Kosi::Validators::RowType.validate(c[:inputs]) }.to raise_error(c[:error_class])
33
+ next
34
+ else
35
+ expect{ Kosi::Validators::RowType.validate(c[:inputs]) }.not_to raise_error
36
+ end
37
+ ensure
38
+ case_after c
39
+ end
40
+ end
41
+
42
+ def case_before(c)
43
+ # implement each case before
44
+ end
45
+
46
+ def case_after(c)
47
+ # implement each case after
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,59 @@
1
+ require 'spec_helper'
2
+ require 'kosi'
3
+
4
+ describe Kosi::VerticalBorderChar do
5
+ context :value do
6
+ cases = [
7
+ {
8
+ case_no: 1,
9
+ case_title: 'no options case',
10
+ options: {},
11
+ expected: Kosi::VerticalBorderChar::DEFAULT
12
+ },
13
+ {
14
+ case_no: 2,
15
+ case_title: 'valid vertical_border_char options case',
16
+ options: { Kosi::OptionKeys::VERTICAL_BORDER_CHAR => '@' },
17
+ expected: '@'
18
+ },
19
+ {
20
+ case_no: 3,
21
+ case_title: 'invalid vertical_border_char options case',
22
+ options: { Kosi::OptionKeys::VERTICAL_BORDER_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::VerticalBorderChar.new(c[:options]) }
35
+ .should raise_error(ArgumentError)
36
+ next
37
+ end
38
+ vertical_border_char = Kosi::VerticalBorderChar.new(c[:options])
39
+
40
+ # -- when --
41
+ actual = vertical_border_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
@@ -0,0 +1,16 @@
1
+ # encoding: utf-8
2
+ require 'simplecov'
3
+ require 'coveralls'
4
+ Coveralls.wear!
5
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
6
+ SimpleCov::Formatter::HTMLFormatter,
7
+ Coveralls::SimpleCov::Formatter
8
+ ]
9
+ SimpleCov.start do
10
+ add_filter '/spec/'
11
+ end
12
+ RSpec.configure do |config|
13
+ config.treat_symbols_as_metadata_keys_with_true_values = true
14
+ config.run_all_when_everything_filtered = true
15
+ config.filter_run :focus
16
+ end