hammer_cli 3.7.0 → 3.8.0
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.
- checksums.yaml +4 -4
- data/bin/hammer +1 -6
- data/doc/release_notes.md +15 -0
- data/lib/hammer_cli/help/builder.rb +1 -2
- data/lib/hammer_cli/i18n/find_task.rb +88 -0
- data/lib/hammer_cli/i18n.rb +4 -0
- data/lib/hammer_cli/options/normalizers.rb +2 -5
- data/lib/hammer_cli/settings.rb +7 -0
- data/lib/hammer_cli/task_helper.rb +84 -0
- data/lib/hammer_cli/testing/output_matchers.rb +1 -1
- data/lib/hammer_cli/utils.rb +1 -1
- data/lib/hammer_cli/version.rb +1 -1
- data/locale/Makefile.def +29 -7
- data/locale/ca/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/cs_CZ/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/de/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/en/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/en_GB/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/es/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/fr/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/it/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/ja/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/ka/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/ko/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/pt_BR/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/ru/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/zh_CN/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/zh_TW/LC_MESSAGES/hammer-cli.mo +0 -0
- data/man/hammer.1.gz +0 -0
- data/test/functional/help_test.rb +1 -1
- data/test/test_helper.rb +1 -1
- data/test/unit/abstract_test.rb +54 -54
- data/test/unit/apipie/command_test.rb +26 -27
- data/test/unit/apipie/option_builder_test.rb +28 -28
- data/test/unit/apipie/option_definition_test.rb +5 -5
- data/test/unit/apipie/test_helper.rb +3 -0
- data/test/unit/bash_test.rb +21 -21
- data/test/unit/command_extensions_test.rb +68 -68
- data/test/unit/completer_test.rb +57 -57
- data/test/unit/csv_parser_test.rb +12 -12
- data/test/unit/defaults_test.rb +3 -3
- data/test/unit/help/builder_test.rb +7 -7
- data/test/unit/help/definition/abstract_item_test.rb +2 -2
- data/test/unit/help/definition/list_test.rb +2 -2
- data/test/unit/help/definition/note_test.rb +2 -2
- data/test/unit/help/definition/section_test.rb +2 -2
- data/test/unit/help/definition/text_test.rb +2 -2
- data/test/unit/help/definition_test.rb +36 -36
- data/test/unit/help/text_builder_test.rb +39 -39
- data/test/unit/history_test.rb +6 -6
- data/test/unit/i18n_test.rb +2 -2
- data/test/unit/logger_test.rb +1 -1
- data/test/unit/main_test.rb +7 -7
- data/test/unit/modules_test.rb +24 -25
- data/test/unit/option_builder_test.rb +1 -1
- data/test/unit/options/matcher_test.rb +15 -15
- data/test/unit/options/normalizers_test.rb +92 -88
- data/test/unit/options/option_definition_test.rb +11 -11
- data/test/unit/options/option_family_test.rb +7 -7
- data/test/unit/options/validators/dsl_test.rb +35 -35
- data/test/unit/output/adapter/abstract_test.rb +10 -10
- data/test/unit/output/adapter/base_test.rb +36 -36
- data/test/unit/output/adapter/csv_test.rb +38 -38
- data/test/unit/output/adapter/json_test.rb +38 -38
- data/test/unit/output/adapter/table_test.rb +42 -50
- data/test/unit/output/adapter/yaml_test.rb +38 -38
- data/test/unit/output/definition_test.rb +43 -43
- data/test/unit/output/dsl_test.rb +19 -19
- data/test/unit/output/field_filter_test.rb +10 -10
- data/test/unit/output/fields_test.rb +27 -27
- data/test/unit/output/formatters_test.rb +39 -39
- data/test/unit/output/output_test.rb +14 -14
- data/test/unit/output/record_collection_test.rb +18 -18
- data/test/unit/settings_test.rb +35 -35
- data/test/unit/utils_test.rb +30 -27
- metadata +33 -44
@@ -9,13 +9,13 @@ describe HammerCLI::Help::Definition do
|
|
9
9
|
describe 'text' do
|
10
10
|
it 'prints text via definition' do
|
11
11
|
definition << HammerCLI::Help::Text.new('Lorem ipsum')
|
12
|
-
definition.build_string.must_equal "Lorem ipsum\n"
|
12
|
+
_(definition.build_string).must_equal "Lorem ipsum\n"
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'prints multiple blocks with spaces via definition' do
|
16
16
|
definition << HammerCLI::Help::Text.new('Lorem ipsum')
|
17
17
|
definition << HammerCLI::Help::Text.new('Dolor sit amet')
|
18
|
-
definition.build_string.must_equal [
|
18
|
+
_(definition.build_string).must_equal [
|
19
19
|
'Lorem ipsum',
|
20
20
|
'',
|
21
21
|
'Dolor sit amet',
|
@@ -27,7 +27,7 @@ describe HammerCLI::Help::Definition do
|
|
27
27
|
describe 'section' do
|
28
28
|
it 'prints section heading via definition' do
|
29
29
|
definition << HammerCLI::Help::Section.new('Heading')
|
30
|
-
definition.build_string.must_equal "Heading:\n\n"
|
30
|
+
_(definition.build_string).must_equal "Heading:\n\n"
|
31
31
|
end
|
32
32
|
|
33
33
|
it 'indents section content via definition' do
|
@@ -35,7 +35,7 @@ describe HammerCLI::Help::Definition do
|
|
35
35
|
sub_definition << HammerCLI::Help::Text.new('Lorem ipsum')
|
36
36
|
sub_definition << HammerCLI::Help::Text.new('Dolor sit amet')
|
37
37
|
definition << HammerCLI::Help::Section.new('Heading', sub_definition)
|
38
|
-
definition.build_string.must_equal [
|
38
|
+
_(definition.build_string).must_equal [
|
39
39
|
'Heading:',
|
40
40
|
' Lorem ipsum',
|
41
41
|
'',
|
@@ -49,7 +49,7 @@ describe HammerCLI::Help::Definition do
|
|
49
49
|
it 'prints empty list via definition' do
|
50
50
|
builder = HammerCLI::Help::TextBuilder.new
|
51
51
|
builder.list([])
|
52
|
-
builder.definition.build_string.must_equal ''
|
52
|
+
_(builder.definition.build_string).must_equal ''
|
53
53
|
end
|
54
54
|
|
55
55
|
it 'prints single column list' do
|
@@ -58,7 +58,7 @@ describe HammerCLI::Help::Definition do
|
|
58
58
|
:bb,
|
59
59
|
:ccc
|
60
60
|
])
|
61
|
-
definition.build_string.must_equal [
|
61
|
+
_(definition.build_string).must_equal [
|
62
62
|
'a',
|
63
63
|
'bb',
|
64
64
|
'ccc',
|
@@ -72,7 +72,7 @@ describe HammerCLI::Help::Definition do
|
|
72
72
|
[:bb, 'This is line B'],
|
73
73
|
[:ccc]
|
74
74
|
])
|
75
|
-
definition.build_string.must_equal [
|
75
|
+
_(definition.build_string).must_equal [
|
76
76
|
'a This is line A',
|
77
77
|
'bb This is line B',
|
78
78
|
'ccc',
|
@@ -86,7 +86,7 @@ describe HammerCLI::Help::Definition do
|
|
86
86
|
[:bb, 'This is line B'],
|
87
87
|
[:ccc, 'This is line C']
|
88
88
|
])
|
89
|
-
definition.build_string.must_equal [
|
89
|
+
_(definition.build_string).must_equal [
|
90
90
|
'a This is line A',
|
91
91
|
' This is line A part two',
|
92
92
|
'bb This is line B',
|
@@ -101,7 +101,7 @@ describe HammerCLI::Help::Definition do
|
|
101
101
|
['This line B is too long for the first column', 'This is line B'],
|
102
102
|
['ccc', 'This is line C']
|
103
103
|
])
|
104
|
-
definition.build_string.must_equal [
|
104
|
+
_(definition.build_string).must_equal [
|
105
105
|
'a This is line A',
|
106
106
|
'This line B is too long for the first column This is line B',
|
107
107
|
'ccc This is line C',
|
@@ -115,7 +115,7 @@ describe HammerCLI::Help::Definition do
|
|
115
115
|
it 'finds an item' do
|
116
116
|
definition << old_text_item
|
117
117
|
definition << new_text_item
|
118
|
-
definition.find_item(:new).must_equal new_text_item
|
118
|
+
_(definition.find_item(:new)).must_equal new_text_item
|
119
119
|
end
|
120
120
|
end
|
121
121
|
|
@@ -127,22 +127,22 @@ describe HammerCLI::Help::Definition do
|
|
127
127
|
it 'should insert new help item before the old one' do
|
128
128
|
definition << old_text_item
|
129
129
|
definition.insert_definition(:before, :old, new_text_item.definition)
|
130
|
-
definition.first.id.must_equal new_text_item.id
|
131
|
-
definition.count.must_equal 2
|
130
|
+
_(definition.first.id).must_equal new_text_item.id
|
131
|
+
_(definition.count).must_equal 2
|
132
132
|
end
|
133
133
|
|
134
134
|
it 'should insert multiple items before old item' do
|
135
135
|
definition << old_text_item
|
136
136
|
definition.insert_definition(:before, :old, new_definition)
|
137
|
-
definition.first.id.must_equal new_text_item.id
|
138
|
-
definition.count.must_equal 3
|
137
|
+
_(definition.first.id).must_equal new_text_item.id
|
138
|
+
_(definition.count).must_equal 3
|
139
139
|
end
|
140
140
|
|
141
141
|
it 'should work with labels' do
|
142
142
|
definition << section_item
|
143
143
|
definition.insert_definition(:before, 'section', new_definition)
|
144
|
-
definition.first.id.must_equal new_text_item.id
|
145
|
-
definition.count.must_equal 3
|
144
|
+
_(definition.first.id).must_equal new_text_item.id
|
145
|
+
_(definition.count).must_equal 3
|
146
146
|
end
|
147
147
|
end
|
148
148
|
|
@@ -150,25 +150,25 @@ describe HammerCLI::Help::Definition do
|
|
150
150
|
it 'should insert new help item after the old one' do
|
151
151
|
definition << old_text_item
|
152
152
|
definition.insert_definition(:after, :old, new_text_item.definition)
|
153
|
-
definition[0].id.must_equal old_text_item.id
|
154
|
-
definition[1].id.must_equal new_text_item.id
|
155
|
-
definition.count.must_equal 2
|
153
|
+
_(definition[0].id).must_equal old_text_item.id
|
154
|
+
_(definition[1].id).must_equal new_text_item.id
|
155
|
+
_(definition.count).must_equal 2
|
156
156
|
end
|
157
157
|
|
158
158
|
it 'should insert multiple items after old item' do
|
159
159
|
definition << old_text_item
|
160
160
|
definition.insert_definition(:after, :old, new_definition)
|
161
|
-
definition[0].id.must_equal old_text_item.id
|
162
|
-
definition[1].id.must_equal new_text_item.id
|
163
|
-
definition[2].id.must_equal new_text_item.id
|
164
|
-
definition.count.must_equal 3
|
161
|
+
_(definition[0].id).must_equal old_text_item.id
|
162
|
+
_(definition[1].id).must_equal new_text_item.id
|
163
|
+
_(definition[2].id).must_equal new_text_item.id
|
164
|
+
_(definition.count).must_equal 3
|
165
165
|
end
|
166
166
|
|
167
167
|
it 'should work with labels' do
|
168
168
|
definition << section_item
|
169
169
|
definition.insert_definition(:after, 'section', new_text_item.definition)
|
170
|
-
definition[1].id.must_equal new_text_item.id
|
171
|
-
definition.count.must_equal 2
|
170
|
+
_(definition[1].id).must_equal new_text_item.id
|
171
|
+
_(definition.count).must_equal 2
|
172
172
|
end
|
173
173
|
end
|
174
174
|
|
@@ -176,23 +176,23 @@ describe HammerCLI::Help::Definition do
|
|
176
176
|
it 'should replace the old help item with new one' do
|
177
177
|
definition << old_text_item
|
178
178
|
definition.insert_definition(:replace, :old, new_text_item.definition)
|
179
|
-
definition.first.id.must_equal new_text_item.id
|
180
|
-
definition.count.must_equal 1
|
179
|
+
_(definition.first.id).must_equal new_text_item.id
|
180
|
+
_(definition.count).must_equal 1
|
181
181
|
end
|
182
182
|
|
183
183
|
it 'should replace the old help item with new ones' do
|
184
184
|
definition << old_text_item
|
185
185
|
definition.insert_definition(:replace, :old, new_definition)
|
186
|
-
definition[0].id.must_equal new_text_item.id
|
187
|
-
definition[1].id.must_equal new_text_item.id
|
188
|
-
definition.count.must_equal 2
|
186
|
+
_(definition[0].id).must_equal new_text_item.id
|
187
|
+
_(definition[1].id).must_equal new_text_item.id
|
188
|
+
_(definition.count).must_equal 2
|
189
189
|
end
|
190
190
|
|
191
191
|
it 'should work with labels' do
|
192
192
|
definition << section_item
|
193
193
|
definition.insert_definition(:replace, 'section', new_text_item.definition)
|
194
|
-
definition.first.id.must_equal new_text_item.id
|
195
|
-
definition.count.must_equal 1
|
194
|
+
_(definition.first.id).must_equal new_text_item.id
|
195
|
+
_(definition.count).must_equal 1
|
196
196
|
end
|
197
197
|
end
|
198
198
|
end
|
@@ -201,7 +201,7 @@ describe HammerCLI::Help::Definition do
|
|
201
201
|
it 'should return self if path is empty' do
|
202
202
|
definition << old_text_item
|
203
203
|
definition.at([]) do |h|
|
204
|
-
h.definition.first.id.must_equal old_text_item.id
|
204
|
+
_(h.definition.first.id).must_equal old_text_item.id
|
205
205
|
end
|
206
206
|
end
|
207
207
|
|
@@ -209,7 +209,7 @@ describe HammerCLI::Help::Definition do
|
|
209
209
|
definition << old_text_item
|
210
210
|
definition << new_text_item
|
211
211
|
definition.at(1) do |h|
|
212
|
-
h.definition.first.id.must_equal new_text_item.id
|
212
|
+
_(h.definition.first.id).must_equal new_text_item.id
|
213
213
|
end
|
214
214
|
end
|
215
215
|
|
@@ -220,7 +220,7 @@ describe HammerCLI::Help::Definition do
|
|
220
220
|
definition << HammerCLI::Help::Section.new('first', sub_definition, id: :first_section)
|
221
221
|
definition << HammerCLI::Help::Section.new('second', sub_definition, id: :second_section)
|
222
222
|
definition.at(:first_section).definition << HammerCLI::Help::Section.new('nested', sub_definition, id: :nested_section)
|
223
|
-
definition.at([:first_section, :nested_section]).definition.first.id.must_equal old_text_item.id
|
223
|
+
_(definition.at([:first_section, :nested_section]).definition.first.id).must_equal old_text_item.id
|
224
224
|
end
|
225
225
|
|
226
226
|
it 'should work with labels' do
|
@@ -230,7 +230,7 @@ describe HammerCLI::Help::Definition do
|
|
230
230
|
definition << HammerCLI::Help::Section.new('first', sub_definition)
|
231
231
|
definition << HammerCLI::Help::Section.new('second', sub_definition)
|
232
232
|
definition.at('first').definition << HammerCLI::Help::Section.new('nested', sub_definition)
|
233
|
-
definition.at(['first', 'nested']).definition.first.id.must_equal old_text_item.id
|
233
|
+
_(definition.at(['first', 'nested']).definition.first.id).must_equal old_text_item.id
|
234
234
|
end
|
235
235
|
end
|
236
236
|
end
|
@@ -6,13 +6,13 @@ describe HammerCLI::Help::TextBuilder do
|
|
6
6
|
describe '#text' do
|
7
7
|
it 'prints text' do
|
8
8
|
help.text('Lorem ipsum')
|
9
|
-
help.string.must_equal "Lorem ipsum\n"
|
9
|
+
_(help.string).must_equal "Lorem ipsum\n"
|
10
10
|
end
|
11
11
|
|
12
12
|
it 'prints multiple blocks with spaces' do
|
13
13
|
help.text('Lorem ipsum')
|
14
14
|
help.text('Dolor sit amet')
|
15
|
-
help.string.must_equal [
|
15
|
+
_(help.string).must_equal [
|
16
16
|
'Lorem ipsum',
|
17
17
|
'',
|
18
18
|
'Dolor sit amet',
|
@@ -24,7 +24,7 @@ describe HammerCLI::Help::TextBuilder do
|
|
24
24
|
describe '#section' do
|
25
25
|
it 'prints section heading' do
|
26
26
|
help.section('Heading')
|
27
|
-
help.string.must_equal "Heading:\n\n"
|
27
|
+
_(help.string).must_equal "Heading:\n\n"
|
28
28
|
end
|
29
29
|
|
30
30
|
it 'indents section content' do
|
@@ -32,7 +32,7 @@ describe HammerCLI::Help::TextBuilder do
|
|
32
32
|
h.text('Lorem ipsum')
|
33
33
|
h.text('Dolor sit amet')
|
34
34
|
end
|
35
|
-
help.string.must_equal [
|
35
|
+
_(help.string).must_equal [
|
36
36
|
'Heading:',
|
37
37
|
' Lorem ipsum',
|
38
38
|
'',
|
@@ -45,7 +45,7 @@ describe HammerCLI::Help::TextBuilder do
|
|
45
45
|
describe '#list' do
|
46
46
|
it 'prints empty list' do
|
47
47
|
help.list([])
|
48
|
-
help.string.must_equal ""
|
48
|
+
_(help.string).must_equal ""
|
49
49
|
end
|
50
50
|
|
51
51
|
it 'prints single column list' do
|
@@ -54,7 +54,7 @@ describe HammerCLI::Help::TextBuilder do
|
|
54
54
|
:bb,
|
55
55
|
:ccc
|
56
56
|
])
|
57
|
-
help.string.must_equal [
|
57
|
+
_(help.string).must_equal [
|
58
58
|
'a',
|
59
59
|
'bb',
|
60
60
|
'ccc',
|
@@ -68,7 +68,7 @@ describe HammerCLI::Help::TextBuilder do
|
|
68
68
|
[:bb, 'This is line B'],
|
69
69
|
[:ccc]
|
70
70
|
])
|
71
|
-
help.string.must_equal [
|
71
|
+
_(help.string).must_equal [
|
72
72
|
'a This is line A',
|
73
73
|
'bb This is line B',
|
74
74
|
'ccc',
|
@@ -82,7 +82,7 @@ describe HammerCLI::Help::TextBuilder do
|
|
82
82
|
[:bb, 'This is line B'],
|
83
83
|
[:ccc, 'This is line C']
|
84
84
|
])
|
85
|
-
help.string.must_equal [
|
85
|
+
_(help.string).must_equal [
|
86
86
|
'a This is line A',
|
87
87
|
' This is line A part two',
|
88
88
|
'bb This is line B',
|
@@ -97,7 +97,7 @@ describe HammerCLI::Help::TextBuilder do
|
|
97
97
|
['This line B is too long for the first column', 'This is line B'],
|
98
98
|
['ccc', 'This is line C']
|
99
99
|
])
|
100
|
-
help.string.must_equal [
|
100
|
+
_(help.string).must_equal [
|
101
101
|
'a This is line A',
|
102
102
|
'This line B is too long for the first column This is line B',
|
103
103
|
'ccc This is line C',
|
@@ -123,7 +123,7 @@ describe HammerCLI::Help::TextBuilder do
|
|
123
123
|
'',
|
124
124
|
' C'
|
125
125
|
].join("\n")
|
126
|
-
help.indent(text).must_equal(expected_result)
|
126
|
+
_(help.indent(text)).must_equal(expected_result)
|
127
127
|
end
|
128
128
|
|
129
129
|
it 'indents text with custom padding' do
|
@@ -133,7 +133,7 @@ describe HammerCLI::Help::TextBuilder do
|
|
133
133
|
'**',
|
134
134
|
'** C'
|
135
135
|
].join("\n")
|
136
|
-
help.indent(text, '**').must_equal(expected_result)
|
136
|
+
_(help.indent(text, '**')).must_equal(expected_result)
|
137
137
|
end
|
138
138
|
end
|
139
139
|
|
@@ -141,7 +141,7 @@ describe HammerCLI::Help::TextBuilder do
|
|
141
141
|
it 'finds an item' do
|
142
142
|
help.text('Lorem ipsum', id: :lorem)
|
143
143
|
help.text('Dolor sit amet', id: :dolor)
|
144
|
-
help.find_item(:dolor).id.must_equal :dolor
|
144
|
+
_(help.find_item(:dolor).id).must_equal :dolor
|
145
145
|
end
|
146
146
|
|
147
147
|
it 'finds a nested item' do
|
@@ -150,7 +150,7 @@ describe HammerCLI::Help::TextBuilder do
|
|
150
150
|
h.text('Dolor sit amet', id: :dolor)
|
151
151
|
end
|
152
152
|
help.at('Heading') do |h|
|
153
|
-
h.find_item(:dolor).id.must_equal :dolor
|
153
|
+
_(h.find_item(:dolor).id).must_equal :dolor
|
154
154
|
end
|
155
155
|
end
|
156
156
|
end
|
@@ -162,8 +162,8 @@ describe HammerCLI::Help::TextBuilder do
|
|
162
162
|
help.insert(:before, :old) do |h|
|
163
163
|
h.text('new', id: :new)
|
164
164
|
end
|
165
|
-
help.definition.first.id.must_equal :new
|
166
|
-
help.definition.count.must_equal 2
|
165
|
+
_(help.definition.first.id).must_equal :new
|
166
|
+
_(help.definition.count).must_equal 2
|
167
167
|
end
|
168
168
|
|
169
169
|
it 'should insert multiple items before old item' do
|
@@ -172,8 +172,8 @@ describe HammerCLI::Help::TextBuilder do
|
|
172
172
|
h.text('new', id: :new)
|
173
173
|
h.text('new2', id: :new2)
|
174
174
|
end
|
175
|
-
help.definition.first.id.must_equal :new
|
176
|
-
help.definition.count.must_equal 3
|
175
|
+
_(help.definition.first.id).must_equal :new
|
176
|
+
_(help.definition.count).must_equal 3
|
177
177
|
end
|
178
178
|
|
179
179
|
it 'should work with labels' do
|
@@ -183,8 +183,8 @@ describe HammerCLI::Help::TextBuilder do
|
|
183
183
|
help.insert(:before, 'section') do |h|
|
184
184
|
h.text('text before section', id: :before_section)
|
185
185
|
end
|
186
|
-
help.definition.first.id.must_equal :before_section
|
187
|
-
help.definition.count.must_equal 2
|
186
|
+
_(help.definition.first.id).must_equal :before_section
|
187
|
+
_(help.definition.count).must_equal 2
|
188
188
|
end
|
189
189
|
end
|
190
190
|
|
@@ -194,9 +194,9 @@ describe HammerCLI::Help::TextBuilder do
|
|
194
194
|
help.insert(:after, :old) do |h|
|
195
195
|
h.text('new', id: :new)
|
196
196
|
end
|
197
|
-
help.definition[0].id.must_equal :old
|
198
|
-
help.definition[1].id.must_equal :new
|
199
|
-
help.definition.count.must_equal 2
|
197
|
+
_(help.definition[0].id).must_equal :old
|
198
|
+
_(help.definition[1].id).must_equal :new
|
199
|
+
_(help.definition.count).must_equal 2
|
200
200
|
end
|
201
201
|
|
202
202
|
it 'should insert multiple items after old item' do
|
@@ -205,10 +205,10 @@ describe HammerCLI::Help::TextBuilder do
|
|
205
205
|
h.text('new', id: :new)
|
206
206
|
h.text('new2', id: :new2)
|
207
207
|
end
|
208
|
-
help.definition[0].id.must_equal :old
|
209
|
-
help.definition[1].id.must_equal :new
|
210
|
-
help.definition[2].id.must_equal :new2
|
211
|
-
help.definition.count.must_equal 3
|
208
|
+
_(help.definition[0].id).must_equal :old
|
209
|
+
_(help.definition[1].id).must_equal :new
|
210
|
+
_(help.definition[2].id).must_equal :new2
|
211
|
+
_(help.definition.count).must_equal 3
|
212
212
|
end
|
213
213
|
|
214
214
|
it 'should work with labels' do
|
@@ -218,8 +218,8 @@ describe HammerCLI::Help::TextBuilder do
|
|
218
218
|
help.insert(:after, 'section') do |h|
|
219
219
|
h.text('text before section', id: :after_section)
|
220
220
|
end
|
221
|
-
help.definition[1].id.must_equal :after_section
|
222
|
-
help.definition.count.must_equal 2
|
221
|
+
_(help.definition[1].id).must_equal :after_section
|
222
|
+
_(help.definition.count).must_equal 2
|
223
223
|
end
|
224
224
|
end
|
225
225
|
|
@@ -229,8 +229,8 @@ describe HammerCLI::Help::TextBuilder do
|
|
229
229
|
help.insert(:replace, :old) do |h|
|
230
230
|
h.text('new', id: :new)
|
231
231
|
end
|
232
|
-
help.definition.first.id.must_equal :new
|
233
|
-
help.definition.count.must_equal 1
|
232
|
+
_(help.definition.first.id).must_equal :new
|
233
|
+
_(help.definition.count).must_equal 1
|
234
234
|
end
|
235
235
|
|
236
236
|
it 'should replace the old help item with new ones' do
|
@@ -239,9 +239,9 @@ describe HammerCLI::Help::TextBuilder do
|
|
239
239
|
h.text('new', id: :new)
|
240
240
|
h.text('new2', id: :new2)
|
241
241
|
end
|
242
|
-
help.definition[0].id.must_equal :new
|
243
|
-
help.definition[1].id.must_equal :new2
|
244
|
-
help.definition.count.must_equal 2
|
242
|
+
_(help.definition[0].id).must_equal :new
|
243
|
+
_(help.definition[1].id).must_equal :new2
|
244
|
+
_(help.definition.count).must_equal 2
|
245
245
|
end
|
246
246
|
|
247
247
|
it 'should work with labels' do
|
@@ -251,8 +251,8 @@ describe HammerCLI::Help::TextBuilder do
|
|
251
251
|
help.insert(:replace, 'section') do |h|
|
252
252
|
h.text('text instead of section', id: :instead_of_section)
|
253
253
|
end
|
254
|
-
help.definition.first.id.must_equal :instead_of_section
|
255
|
-
help.definition.count.must_equal 1
|
254
|
+
_(help.definition.first.id).must_equal :instead_of_section
|
255
|
+
_(help.definition.count).must_equal 1
|
256
256
|
end
|
257
257
|
end
|
258
258
|
end
|
@@ -261,10 +261,10 @@ describe HammerCLI::Help::TextBuilder do
|
|
261
261
|
it 'should return self if path is empty' do
|
262
262
|
help.text('foo', id: :foo)
|
263
263
|
help.at([]) do |h|
|
264
|
-
h.definition.first.id.must_equal :foo
|
264
|
+
_(h.definition.first.id).must_equal :foo
|
265
265
|
end
|
266
266
|
help.at do |h|
|
267
|
-
h.definition.first.id.must_equal :foo
|
267
|
+
_(h.definition.first.id).must_equal :foo
|
268
268
|
end
|
269
269
|
end
|
270
270
|
|
@@ -283,7 +283,7 @@ describe HammerCLI::Help::TextBuilder do
|
|
283
283
|
end
|
284
284
|
end
|
285
285
|
help.at([:first_section, :nested_section]) do |h|
|
286
|
-
h.definition.first.id.must_equal :nested_text
|
286
|
+
_(h.definition.first.id).must_equal :nested_text
|
287
287
|
end
|
288
288
|
end
|
289
289
|
|
@@ -302,7 +302,7 @@ describe HammerCLI::Help::TextBuilder do
|
|
302
302
|
end
|
303
303
|
end
|
304
304
|
help.at(['first', 'nested section']) do |h|
|
305
|
-
h.definition.first.id.must_equal :nested_text
|
305
|
+
_(h.definition.first.id).must_equal :nested_text
|
306
306
|
end
|
307
307
|
end
|
308
308
|
end
|
data/test/unit/history_test.rb
CHANGED
@@ -22,13 +22,13 @@ describe HammerCLI::ShellHistory do
|
|
22
22
|
it "skips loading if the file does not exist" do
|
23
23
|
HammerCLI::ShellHistory.new(new_file.path)
|
24
24
|
|
25
|
-
Readline::HISTORY.to_a.must_equal []
|
25
|
+
_(Readline::HISTORY.to_a).must_equal []
|
26
26
|
end
|
27
27
|
|
28
28
|
it "preseeds readline's history" do
|
29
29
|
HammerCLI::ShellHistory.new(history_file.path)
|
30
30
|
|
31
|
-
Readline::HISTORY.to_a.must_equal ["line 1", "line 2"]
|
31
|
+
_(Readline::HISTORY.to_a).must_equal ["line 1", "line 2"]
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
@@ -37,7 +37,7 @@ describe HammerCLI::ShellHistory do
|
|
37
37
|
history = HammerCLI::ShellHistory.new(new_file.path)
|
38
38
|
history.push("some command ")
|
39
39
|
|
40
|
-
File.exist?(new_file.path).must_equal true
|
40
|
+
_(File.exist?(new_file.path)).must_equal true
|
41
41
|
end
|
42
42
|
|
43
43
|
it "appends history to the given file" do
|
@@ -45,21 +45,21 @@ describe HammerCLI::ShellHistory do
|
|
45
45
|
history.push("some command ")
|
46
46
|
history.push("another command ")
|
47
47
|
|
48
|
-
new_file.read.must_equal "some command\nanother command\n"
|
48
|
+
_(new_file.read).must_equal "some command\nanother command\n"
|
49
49
|
end
|
50
50
|
|
51
51
|
it "appends to readline's history" do
|
52
52
|
history = HammerCLI::ShellHistory.new(history_file.path)
|
53
53
|
history.push("line 3")
|
54
54
|
|
55
|
-
Readline::HISTORY.to_a.must_equal ["line 1", "line 2", "line 3"]
|
55
|
+
_(Readline::HISTORY.to_a).must_equal ["line 1", "line 2", "line 3"]
|
56
56
|
end
|
57
57
|
|
58
58
|
it "doesn't save exit command" do
|
59
59
|
history = HammerCLI::ShellHistory.new(history_file.path)
|
60
60
|
history.push("exit ")
|
61
61
|
|
62
|
-
Readline::HISTORY.to_a.must_equal ["line 1", "line 2"]
|
62
|
+
_(Readline::HISTORY.to_a).must_equal ["line 1", "line 2"]
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
data/test/unit/i18n_test.rb
CHANGED
@@ -42,7 +42,7 @@ describe HammerCLI::I18n do
|
|
42
42
|
|
43
43
|
describe 'with fast_gettext >= 1.2.0' do
|
44
44
|
it 'creates base merge repository' do
|
45
|
-
HammerCLI::I18n.translation_repository.class.must_equal FastGettext::TranslationRepository::Merge
|
45
|
+
_(HammerCLI::I18n.translation_repository.class).must_equal FastGettext::TranslationRepository::Merge
|
46
46
|
end
|
47
47
|
|
48
48
|
it 'registers available domains at gettext' do
|
@@ -60,7 +60,7 @@ describe HammerCLI::I18n do
|
|
60
60
|
HammerCLI::I18n.add_domain(domain1)
|
61
61
|
HammerCLI::I18n.add_domain(domain2)
|
62
62
|
HammerCLI::I18n.add_domain(unavailable_domain)
|
63
|
-
HammerCLI::I18n.domains.must_equal [domain1, domain2]
|
63
|
+
_(HammerCLI::I18n.domains).must_equal [domain1, domain2]
|
64
64
|
end
|
65
65
|
end
|
66
66
|
end
|
data/test/unit/logger_test.rb
CHANGED
@@ -31,7 +31,7 @@ describe Logging::LogEvent do
|
|
31
31
|
Logging::LogEvent.add_data_filter(/pat/, 'mat')
|
32
32
|
Logging.logger.root.debug "pat"
|
33
33
|
Logging::LogEvent.data_filters.pop # clean the last filter
|
34
|
-
@log_output.read.must_include 'mat'
|
34
|
+
_(@log_output.read).must_include 'mat'
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
data/test/unit/main_test.rb
CHANGED
@@ -15,12 +15,12 @@ describe HammerCLI::MainCommand do
|
|
15
15
|
|
16
16
|
it "should prioritize parameter" do
|
17
17
|
cmd.run(["-uuser"])
|
18
|
-
context[:username].must_equal "user"
|
18
|
+
_(context[:username]).must_equal "user"
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should prioritize parameter 2" do
|
22
22
|
cmd.run([])
|
23
|
-
context[:username]
|
23
|
+
assert_nil context[:username]
|
24
24
|
end
|
25
25
|
|
26
26
|
end
|
@@ -30,12 +30,12 @@ describe HammerCLI::MainCommand do
|
|
30
30
|
|
31
31
|
it "should prioritize parameter" do
|
32
32
|
cmd.run(["-ppassword"])
|
33
|
-
context[:password].must_equal "password"
|
33
|
+
_(context[:password]).must_equal "password"
|
34
34
|
end
|
35
35
|
|
36
36
|
it "should prioritize parameter" do
|
37
37
|
cmd.run([])
|
38
|
-
context[:password]
|
38
|
+
assert_nil context[:password]
|
39
39
|
end
|
40
40
|
|
41
41
|
end
|
@@ -44,11 +44,11 @@ describe HammerCLI::MainCommand do
|
|
44
44
|
describe 'verbose' do
|
45
45
|
it 'stores verbosity level into context' do
|
46
46
|
cmd.run(['-v'])
|
47
|
-
context[:verbosity].must_equal HammerCLI::V_VERBOSE
|
47
|
+
_(context[:verbosity]).must_equal HammerCLI::V_VERBOSE
|
48
48
|
cmd.run(['--no-verbose'])
|
49
|
-
context[:verbosity].must_equal HammerCLI::V_UNIX
|
49
|
+
_(context[:verbosity]).must_equal HammerCLI::V_UNIX
|
50
50
|
cmd.run(['--quiet'])
|
51
|
-
context[:verbosity].must_equal HammerCLI::V_QUIET
|
51
|
+
_(context[:verbosity]).must_equal HammerCLI::V_QUIET
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|