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.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/bin/hammer +1 -6
  3. data/doc/release_notes.md +15 -0
  4. data/lib/hammer_cli/help/builder.rb +1 -2
  5. data/lib/hammer_cli/i18n/find_task.rb +88 -0
  6. data/lib/hammer_cli/i18n.rb +4 -0
  7. data/lib/hammer_cli/options/normalizers.rb +2 -5
  8. data/lib/hammer_cli/settings.rb +7 -0
  9. data/lib/hammer_cli/task_helper.rb +84 -0
  10. data/lib/hammer_cli/testing/output_matchers.rb +1 -1
  11. data/lib/hammer_cli/utils.rb +1 -1
  12. data/lib/hammer_cli/version.rb +1 -1
  13. data/locale/Makefile.def +29 -7
  14. data/locale/ca/LC_MESSAGES/hammer-cli.mo +0 -0
  15. data/locale/cs_CZ/LC_MESSAGES/hammer-cli.mo +0 -0
  16. data/locale/de/LC_MESSAGES/hammer-cli.mo +0 -0
  17. data/locale/en/LC_MESSAGES/hammer-cli.mo +0 -0
  18. data/locale/en_GB/LC_MESSAGES/hammer-cli.mo +0 -0
  19. data/locale/es/LC_MESSAGES/hammer-cli.mo +0 -0
  20. data/locale/fr/LC_MESSAGES/hammer-cli.mo +0 -0
  21. data/locale/it/LC_MESSAGES/hammer-cli.mo +0 -0
  22. data/locale/ja/LC_MESSAGES/hammer-cli.mo +0 -0
  23. data/locale/ka/LC_MESSAGES/hammer-cli.mo +0 -0
  24. data/locale/ko/LC_MESSAGES/hammer-cli.mo +0 -0
  25. data/locale/pt_BR/LC_MESSAGES/hammer-cli.mo +0 -0
  26. data/locale/ru/LC_MESSAGES/hammer-cli.mo +0 -0
  27. data/locale/zh_CN/LC_MESSAGES/hammer-cli.mo +0 -0
  28. data/locale/zh_TW/LC_MESSAGES/hammer-cli.mo +0 -0
  29. data/man/hammer.1.gz +0 -0
  30. data/test/functional/help_test.rb +1 -1
  31. data/test/test_helper.rb +1 -1
  32. data/test/unit/abstract_test.rb +54 -54
  33. data/test/unit/apipie/command_test.rb +26 -27
  34. data/test/unit/apipie/option_builder_test.rb +28 -28
  35. data/test/unit/apipie/option_definition_test.rb +5 -5
  36. data/test/unit/apipie/test_helper.rb +3 -0
  37. data/test/unit/bash_test.rb +21 -21
  38. data/test/unit/command_extensions_test.rb +68 -68
  39. data/test/unit/completer_test.rb +57 -57
  40. data/test/unit/csv_parser_test.rb +12 -12
  41. data/test/unit/defaults_test.rb +3 -3
  42. data/test/unit/help/builder_test.rb +7 -7
  43. data/test/unit/help/definition/abstract_item_test.rb +2 -2
  44. data/test/unit/help/definition/list_test.rb +2 -2
  45. data/test/unit/help/definition/note_test.rb +2 -2
  46. data/test/unit/help/definition/section_test.rb +2 -2
  47. data/test/unit/help/definition/text_test.rb +2 -2
  48. data/test/unit/help/definition_test.rb +36 -36
  49. data/test/unit/help/text_builder_test.rb +39 -39
  50. data/test/unit/history_test.rb +6 -6
  51. data/test/unit/i18n_test.rb +2 -2
  52. data/test/unit/logger_test.rb +1 -1
  53. data/test/unit/main_test.rb +7 -7
  54. data/test/unit/modules_test.rb +24 -25
  55. data/test/unit/option_builder_test.rb +1 -1
  56. data/test/unit/options/matcher_test.rb +15 -15
  57. data/test/unit/options/normalizers_test.rb +92 -88
  58. data/test/unit/options/option_definition_test.rb +11 -11
  59. data/test/unit/options/option_family_test.rb +7 -7
  60. data/test/unit/options/validators/dsl_test.rb +35 -35
  61. data/test/unit/output/adapter/abstract_test.rb +10 -10
  62. data/test/unit/output/adapter/base_test.rb +36 -36
  63. data/test/unit/output/adapter/csv_test.rb +38 -38
  64. data/test/unit/output/adapter/json_test.rb +38 -38
  65. data/test/unit/output/adapter/table_test.rb +42 -50
  66. data/test/unit/output/adapter/yaml_test.rb +38 -38
  67. data/test/unit/output/definition_test.rb +43 -43
  68. data/test/unit/output/dsl_test.rb +19 -19
  69. data/test/unit/output/field_filter_test.rb +10 -10
  70. data/test/unit/output/fields_test.rb +27 -27
  71. data/test/unit/output/formatters_test.rb +39 -39
  72. data/test/unit/output/output_test.rb +14 -14
  73. data/test/unit/output/record_collection_test.rb +18 -18
  74. data/test/unit/settings_test.rb +35 -35
  75. data/test/unit/utils_test.rb +30 -27
  76. metadata +33 -44
@@ -8,7 +8,7 @@ describe HammerCLI::Options::Normalizers do
8
8
  let(:formatter) { HammerCLI::Options::Normalizers::AbstractNormalizer.new }
9
9
 
10
10
  it "should raise exception on format" do
11
- proc { formatter.format(nil) }.must_raise NotImplementedError
11
+ _{ formatter.format(nil) }.must_raise NotImplementedError
12
12
  end
13
13
 
14
14
  end
@@ -18,19 +18,19 @@ describe HammerCLI::Options::Normalizers do
18
18
  let(:formatter) { HammerCLI::Options::Normalizers::Default.new }
19
19
 
20
20
  it "should not change any value" do
21
- formatter.format('value').must_equal 'value'
21
+ _(formatter.format('value')).must_equal 'value'
22
22
  end
23
23
 
24
24
  it "should not change nil value" do
25
- formatter.format(nil).must_be_nil
25
+ _(formatter.format(nil)).must_be_nil
26
26
  end
27
27
 
28
28
  it "has empty description" do
29
- formatter.description.must_equal ''
29
+ _(formatter.description).must_equal ''
30
30
  end
31
31
 
32
32
  it "has empty completion" do
33
- formatter.complete('test').must_equal []
33
+ _(formatter.complete('test')).must_equal []
34
34
  end
35
35
  end
36
36
 
@@ -39,44 +39,44 @@ describe HammerCLI::Options::Normalizers do
39
39
  let(:formatter) { HammerCLI::Options::Normalizers::List.new }
40
40
 
41
41
  it "should return empty array on nil" do
42
- formatter.format(nil).must_equal []
42
+ _(formatter.format(nil)).must_equal []
43
43
  end
44
44
 
45
45
  it "should return empty array on empty string" do
46
- formatter.format("").must_equal []
46
+ _(formatter.format("")).must_equal []
47
47
  end
48
48
 
49
49
  it "should parse a string" do
50
- formatter.format("a").must_equal ['a']
50
+ _(formatter.format("a")).must_equal ['a']
51
51
  end
52
52
 
53
53
  it "should parse a number" do
54
- formatter.format("2").must_equal [2]
54
+ _(formatter.format("2")).must_equal [2]
55
55
  end
56
56
 
57
57
  it "should parse a comma separated string" do
58
- formatter.format("a,b,c").must_equal ['a', 'b', 'c']
58
+ _(formatter.format("a,b,c")).must_equal ['a', 'b', 'c']
59
59
  end
60
60
 
61
61
  it "should parse a comma separated string with values including comma" do
62
- formatter.format('a,b,"c,d"').must_equal ['a', 'b', 'c,d']
62
+ _(formatter.format('a,b,"c,d"')).must_equal ['a', 'b', 'c,d']
63
63
  end
64
64
 
65
65
  it "should parse a comma separated string with values including comma (doublequotes)" do
66
- formatter.format("a,b,'c,d'").must_equal ['a', 'b', 'c,d']
66
+ _(formatter.format("a,b,'c,d'")).must_equal ['a', 'b', 'c,d']
67
67
  end
68
68
 
69
69
  it "should parse a comma separated string containig double quotes" do
70
- formatter.format('a,b,\"c\"').must_equal ['a', 'b', '"c"']
70
+ _(formatter.format('a,b,\"c\"')).must_equal ['a', 'b', '"c"']
71
71
  end
72
72
 
73
73
  it "should catch quoting errors" do
74
- proc { formatter.format('1,"3,4""s') }.must_raise ArgumentError
74
+ _{ formatter.format('1,"3,4""s') }.must_raise ArgumentError
75
75
  end
76
76
 
77
77
  it "should accept and parse JSON" do
78
78
  value = {'name' => 'bla', 'value' => 1}
79
- formatter.format(value.to_json).must_equal([value])
79
+ _(formatter.format(value.to_json)).must_equal([value])
80
80
  end
81
81
  end
82
82
 
@@ -102,19 +102,19 @@ describe HammerCLI::Options::Normalizers do
102
102
  let(:formatter) { HammerCLI::Options::Normalizers::ListNested.new(param.params) }
103
103
 
104
104
  it "should accept and parse JSON" do
105
- formatter.format("{\"name\":\"bla\", \"value\":1}").must_equal(
105
+ _(formatter.format("{\"name\":\"bla\", \"value\":1}")).must_equal(
106
106
  JSON.parse("{\"name\":\"bla\", \"value\":1}")
107
107
  )
108
108
  end
109
109
 
110
110
  it "should parse simple input" do
111
- formatter.format("name=test\\,value=1,name=other\\,value=2").must_equal(
111
+ _(formatter.format("name=test\\,value=1,name=other\\,value=2")).must_equal(
112
112
  [{'name' => 'test', 'value' => '1'}, {'name' => 'other', 'value' => '2'}]
113
113
  )
114
114
  end
115
115
 
116
116
  it "should parse unexpected input" do
117
- formatter.format("name=test\\,value=1,name=other\\,value=2,unexp=doe").must_equal(
117
+ _(formatter.format("name=test\\,value=1,name=other\\,value=2,unexp=doe")).must_equal(
118
118
  [
119
119
  {'name' => 'test', 'value' => '1'}, {'name' => 'other', 'value' => '2'},
120
120
  {'unexp' => 'doe'}
@@ -123,15 +123,15 @@ describe HammerCLI::Options::Normalizers do
123
123
  end
124
124
 
125
125
  it "should accept arrays" do
126
- formatter.format("name=test\\,value=1,name=other\\,value=[1\\,2\\,3]").must_equal(
126
+ _(formatter.format("name=test\\,value=1,name=other\\,value=[1\\,2\\,3]")).must_equal(
127
127
  [{'name' => 'test', 'value' => '1'}, {'name' => 'other', 'value' => ['1', '2', '3']}]
128
128
  )
129
129
  end
130
130
 
131
131
  it "should accept hashes" do
132
- formatter.format(
132
+ _(formatter.format(
133
133
  "name=test\\,value={key=key1\\,value=1},name=other\\,value={key=key2\\,value=2}"
134
- ).must_equal(
134
+ )).must_equal(
135
135
  [
136
136
  {'name' => 'test', 'value' => {'key' => 'key1', 'value' => '1'}},
137
137
  {'name' => 'other', 'value' => {'key' => 'key2', 'value' => '2'}},
@@ -140,10 +140,10 @@ describe HammerCLI::Options::Normalizers do
140
140
  end
141
141
 
142
142
  it "should accept combined input" do
143
- formatter.format(
143
+ _(formatter.format(
144
144
  "name=foo\\,value=1\\,adds=[1\\,2\\,3]\\,cpu={name=ddd\\,type=abc}," \
145
145
  "name=bar\\,value=2\\,adds=[2\\,2\\,2]\\,cpu={name=ccc\\,type=cba}"
146
- ).must_equal(
146
+ )).must_equal(
147
147
  [
148
148
  {'name' => 'foo', 'value' => '1', 'adds' => ['1','2','3'], 'cpu' => {'name' => 'ddd', 'type' => 'abc'}},
149
149
  {'name' => 'bar', 'value' => '2', 'adds' => ['2','2','2'], 'cpu' => {'name' => 'ccc', 'type' => 'cba'}}
@@ -157,100 +157,104 @@ describe HammerCLI::Options::Normalizers do
157
157
  let(:formatter) { HammerCLI::Options::Normalizers::KeyValueList.new }
158
158
 
159
159
  it "should return empty array on nil" do
160
- formatter.format(nil).must_equal({})
160
+ _(formatter.format(nil)).must_equal({})
161
161
  end
162
162
 
163
163
  it "should return empty array on empty string" do
164
- formatter.format("").must_equal({})
164
+ _(formatter.format("")).must_equal({})
165
165
  end
166
166
 
167
167
  it "should parse a string" do
168
- proc { formatter.format("a") }.must_raise ArgumentError
168
+ _{ formatter.format("a") }.must_raise ArgumentError
169
169
  end
170
170
 
171
171
  describe 'key=value format' do
172
+ it 'should parse values with commas' do
173
+ _(formatter.format('a=1,2,b=3,4')).must_equal({ 'a' => '1,2', 'b' => '3,4'})
174
+ end
175
+
172
176
  it "should parse a comma separated string" do
173
- formatter.format("a=1,b=2,c=3").must_equal({'a' => '1', 'b' => '2', 'c' => '3'})
177
+ _(formatter.format("a=1,b=2,c=3")).must_equal({'a' => '1', 'b' => '2', 'c' => '3'})
174
178
  end
175
179
 
176
180
  it "should parse a comma separated string with spaces" do
177
- formatter.format("a= 1 , b = 2 ,c =3").must_equal({'a' => '1', 'b' => '2', 'c' => '3'})
181
+ _(formatter.format("a= 1 , b = 2 ,c =3")).must_equal({'a' => '1', 'b' => '2', 'c' => '3'})
178
182
  end
179
183
 
180
184
  it 'should parse a comma separated string with spaces using single quotes' do
181
- formatter.format("a= ' 1 ' , b =' 2',c ='3'").must_equal({ 'a' => "' 1 '", 'b' => "' 2'", 'c' => "'3'" })
185
+ _(formatter.format("a= ' 1 ' , b =' 2',c ='3'")).must_equal({ 'a' => "' 1 '", 'b' => "' 2'", 'c' => "'3'" })
182
186
  end
183
187
 
184
188
  it 'should parse a comma separated string with spaces using double quotes' do
185
- formatter.format('a= " 1 " , b =" 2",c ="3"').must_equal({ 'a' => '" 1 "', 'b' => '" 2"', 'c' => '"3"' })
189
+ _(formatter.format('a= " 1 " , b =" 2",c ="3"')).must_equal({ 'a' => '" 1 "', 'b' => '" 2"', 'c' => '"3"' })
186
190
  end
187
191
 
188
192
  it 'should deal with equal sign in string value' do
189
- formatter.format("a=1,b='2=2',c=3").must_equal({ 'a' => '1', 'b' => "'2=2'", 'c' => '3' })
193
+ _(formatter.format("a=1,b='2=2',c=3")).must_equal({ 'a' => '1', 'b' => "'2=2'", 'c' => '3' })
190
194
  end
191
195
 
192
196
  it 'should deal with equal sign in value' do
193
- formatter.format('a=1,b=2=2,c=3').must_equal({ 'a' => '1', 'b' => '2=2', 'c' => '3' })
197
+ _(formatter.format('a=1,b=2=2,c=3')).must_equal({ 'a' => '1', 'b' => '2=2', 'c' => '3' })
194
198
  end
195
199
 
196
200
  it "should parse arrays" do
197
- formatter.format("a=1,b=[1,2,3],c=3").must_equal({'a' => '1', 'b' => ['1', '2', '3'], 'c' => '3'})
201
+ _(formatter.format("a=1,b=[1,2,3],c=3")).must_equal({'a' => '1', 'b' => ['1', '2', '3'], 'c' => '3'})
198
202
  end
199
203
 
200
204
  it "should parse arrays with spaces" do
201
- formatter.format("a=1,b=[1, 2, 3],c=3").must_equal({'a' => '1', 'b' => ['1', '2', '3'], 'c' => '3'})
205
+ _(formatter.format("a=1,b=[1, 2, 3],c=3")).must_equal({'a' => '1', 'b' => ['1', '2', '3'], 'c' => '3'})
202
206
  end
203
207
 
204
208
  it 'should parse arrays with spaces using by single quotes' do
205
- formatter.format("a=1,b=['1 1', ' 2 ', ' 3 3'],c=3").must_equal(
209
+ _(formatter.format("a=1,b=['1 1', ' 2 ', ' 3 3'],c=3")).must_equal(
206
210
  { 'a' => '1', 'b' => ["'1 1'", "' 2 '", "' 3 3'"], 'c' => '3' }
207
211
  )
208
212
  end
209
213
 
210
214
  it 'should parse arrays with spaces using by double quotes' do
211
- formatter.format('a=1,b=["1 1", " 2 ", " 3 3"],c=3').must_equal(
215
+ _(formatter.format('a=1,b=["1 1", " 2 ", " 3 3"],c=3')).must_equal(
212
216
  { 'a' => '1', 'b' => ['"1 1"', '" 2 "', '" 3 3"'], 'c' => '3' }
213
217
  )
214
218
  end
215
219
 
216
220
  it 'should parse arrays with spaces' do
217
- formatter.format('a=1,b=[1 1, 2 , 3 3],c=3').must_equal({ 'a' => '1', 'b' => ['1 1', '2', '3 3'], 'c' => '3' })
221
+ _(formatter.format('a=1,b=[1 1, 2 , 3 3],c=3')).must_equal({ 'a' => '1', 'b' => ['1 1', '2', '3 3'], 'c' => '3' })
218
222
  end
219
223
 
220
224
  it "should parse array with one item" do
221
- formatter.format("a=1,b=[abc],c=3").must_equal({'a' => '1', 'b' => ['abc'], 'c' => '3'})
225
+ _(formatter.format("a=1,b=[abc],c=3")).must_equal({'a' => '1', 'b' => ['abc'], 'c' => '3'})
222
226
  end
223
227
 
224
228
  it "should parse empty array" do
225
- formatter.format("a=1,b=[],c=3").must_equal({'a' => '1', 'b' => [], 'c' => '3'})
229
+ _(formatter.format("a=1,b=[],c=3")).must_equal({'a' => '1', 'b' => [], 'c' => '3'})
226
230
  end
227
231
 
228
232
  it "should parse hash with one item" do
229
- formatter.format("a=1,b={key=abc,value=abc},c=3").must_equal(
233
+ _(formatter.format("a=1,b={key=abc,value=abc},c=3")).must_equal(
230
234
  {'a' => '1', 'b' => {'key' => 'abc', 'value' => 'abc'}, 'c' => '3'}
231
235
  )
232
236
  end
233
237
 
234
238
  it "should parse empty hash" do
235
- formatter.format("a=1,b={},c=3").must_equal({'a' => '1', 'b' => {}, 'c' => '3'})
239
+ _(formatter.format("a=1,b={},c=3")).must_equal({'a' => '1', 'b' => {}, 'c' => '3'})
236
240
  end
237
241
 
238
242
  it "should parse a comma separated string 2" do
239
- proc { formatter.format("a=1,b,c=3") }.must_raise ArgumentError
243
+ _(formatter.format("a=1,b,c=3")).must_equal({ 'a' => '1,b', 'c' => '3' })
240
244
  end
241
245
 
242
246
  it 'should parse explicit strings' do
243
- formatter.format('name="*"').must_equal({ 'name' => '"*"' })
247
+ _(formatter.format('name="*"')).must_equal({ 'name' => '"*"' })
244
248
  end
245
249
  end
246
250
 
247
251
  describe 'json format' do
248
252
  it 'parses arrays' do
249
- formatter.format('["a", "b", 1]').must_equal(['a', 'b', 1])
253
+ _(formatter.format('["a", "b", 1]')).must_equal(['a', 'b', 1])
250
254
  end
251
255
 
252
256
  it 'parses objects' do
253
- formatter.format('{"a": ["b", 1]}').must_equal({'a' => ['b', 1]})
257
+ _(formatter.format('{"a": ["b", 1]}')).must_equal({'a' => ['b', 1]})
254
258
  end
255
259
  end
256
260
  end
@@ -259,11 +263,11 @@ describe HammerCLI::Options::Normalizers do
259
263
  let(:formatter) { HammerCLI::Options::Normalizers::Number.new }
260
264
 
261
265
  it "should return number on numeric values" do
262
- formatter.format("1").must_equal 1
266
+ _(formatter.format("1")).must_equal 1
263
267
  end
264
268
 
265
269
  it "should raise ArgumentError on non-numeric values" do
266
- proc { formatter.format("a") }.must_raise ArgumentError
270
+ _{ formatter.format("a") }.must_raise ArgumentError
267
271
  end
268
272
  end
269
273
 
@@ -272,59 +276,59 @@ describe HammerCLI::Options::Normalizers do
272
276
  let(:formatter) { HammerCLI::Options::Normalizers::Bool.new }
273
277
 
274
278
  it "should return true on true" do
275
- formatter.format("true").must_equal(true)
276
- formatter.format("TRUE").must_equal(true)
279
+ _(formatter.format("true")).must_equal(true)
280
+ _(formatter.format("TRUE")).must_equal(true)
277
281
  end
278
282
 
279
283
  it "should return true on t" do
280
- formatter.format("t").must_equal(true)
281
- formatter.format("T").must_equal(true)
284
+ _(formatter.format("t")).must_equal(true)
285
+ _(formatter.format("T")).must_equal(true)
282
286
  end
283
287
 
284
288
  it "should return true on yes" do
285
- formatter.format("yes").must_equal(true)
286
- formatter.format("YES").must_equal(true)
289
+ _(formatter.format("yes")).must_equal(true)
290
+ _(formatter.format("YES")).must_equal(true)
287
291
  end
288
292
 
289
293
  it "should return true on y" do
290
- formatter.format("y").must_equal(true)
291
- formatter.format("Y").must_equal(true)
294
+ _(formatter.format("y")).must_equal(true)
295
+ _(formatter.format("Y")).must_equal(true)
292
296
  end
293
297
 
294
298
  it "should return true on 1" do
295
- formatter.format("1").must_equal(true)
299
+ _(formatter.format("1")).must_equal(true)
296
300
  end
297
301
 
298
302
  it "should return false on false" do
299
- formatter.format("false").must_equal(false)
300
- formatter.format("FALSE").must_equal(false)
303
+ _(formatter.format("false")).must_equal(false)
304
+ _(formatter.format("FALSE")).must_equal(false)
301
305
  end
302
306
 
303
307
  it "should return false on f" do
304
- formatter.format("f").must_equal(false)
305
- formatter.format("F").must_equal(false)
308
+ _(formatter.format("f")).must_equal(false)
309
+ _(formatter.format("F")).must_equal(false)
306
310
  end
307
311
 
308
312
  it "should return false on no" do
309
- formatter.format("no").must_equal(false)
310
- formatter.format("NO").must_equal(false)
313
+ _(formatter.format("no")).must_equal(false)
314
+ _(formatter.format("NO")).must_equal(false)
311
315
  end
312
316
 
313
317
  it "should return false on n" do
314
- formatter.format("n").must_equal(false)
315
- formatter.format("N").must_equal(false)
318
+ _(formatter.format("n")).must_equal(false)
319
+ _(formatter.format("N")).must_equal(false)
316
320
  end
317
321
 
318
322
  it "should return false on 0" do
319
- formatter.format("0").must_equal(false)
323
+ _(formatter.format("0")).must_equal(false)
320
324
  end
321
325
 
322
326
  it "should raise exception on nil" do
323
- proc { formatter.format(nil) }.must_raise ArgumentError
327
+ _{ formatter.format(nil) }.must_raise ArgumentError
324
328
  end
325
329
 
326
330
  it "should raise exception on other values" do
327
- proc { formatter.format('unknown') }.must_raise ArgumentError
331
+ _{ formatter.format('unknown') }.must_raise ArgumentError
328
332
  end
329
333
  end
330
334
 
@@ -333,24 +337,24 @@ describe HammerCLI::Options::Normalizers do
333
337
 
334
338
  it "should return a hash on valid json file" do
335
339
  file = File.join(File.dirname(__FILE__), '../fixtures/json_input/valid.json')
336
- formatter.format(file).must_equal({ "units" => [ { "name" => "zip", "version" => "10.0" },
340
+ _(formatter.format(file)).must_equal({ "units" => [ { "name" => "zip", "version" => "10.0" },
337
341
  { "name" => "zap", "version" => "9.0" }] })
338
342
  end
339
343
 
340
344
  it "should raise exception on invalid json file contents" do
341
345
  file = File.join(File.dirname(__FILE__), '../fixtures/json_input/invalid.json')
342
- proc { formatter.format(file) }.must_raise ArgumentError
346
+ _{ formatter.format(file) }.must_raise ArgumentError
343
347
  end
344
348
 
345
349
  it "should return a hash on valid json string" do
346
350
  json_string = '{ "units":[{ "name":"zip", "version":"10.0" }, { "name":"zap", "version":"9.0" }] }'
347
- formatter.format(json_string).must_equal({ "units" => [ { "name" => "zip", "version" => "10.0" },
351
+ _(formatter.format(json_string)).must_equal({ "units" => [ { "name" => "zip", "version" => "10.0" },
348
352
  { "name" => "zap", "version" => "9.0" }] })
349
353
  end
350
354
 
351
355
  it "should raise exception on invalid json string" do
352
356
  json_string = "{ units:[{ name:zip, version:10.0 }, { name:zap, version:9.0 }] }"
353
- proc { formatter.format(json_string) }.must_raise ArgumentError
357
+ _{ formatter.format(json_string) }.must_raise ArgumentError
354
358
  end
355
359
 
356
360
  end
@@ -360,19 +364,19 @@ describe HammerCLI::Options::Normalizers do
360
364
  let(:formatter) { HammerCLI::Options::Normalizers::Enum.new ['a', 'b'] }
361
365
 
362
366
  it "should return return value when in the list" do
363
- formatter.format("a").must_equal("a")
367
+ _(formatter.format("a")).must_equal("a")
364
368
  end
365
369
 
366
370
  it "should rise argument error when the value is nil" do
367
- proc { formatter.format(nil) }.must_raise ArgumentError
371
+ _{ formatter.format(nil) }.must_raise ArgumentError
368
372
  end
369
373
 
370
374
  it "should rise argument error when the value is not in the list" do
371
- proc { formatter.format("c") }.must_raise ArgumentError
375
+ _{ formatter.format("c") }.must_raise ArgumentError
372
376
  end
373
377
 
374
378
  it "should list allowed values in description" do
375
- formatter.description.must_equal("Possible value(s): 'a', 'b'")
379
+ _(formatter.description).must_equal("Possible value(s): 'a', 'b'")
376
380
  end
377
381
 
378
382
  end
@@ -382,32 +386,32 @@ describe HammerCLI::Options::Normalizers do
382
386
  let (:formatter) { HammerCLI::Options::Normalizers::EnumList.new ['1', '2', 'a', 'b'] }
383
387
 
384
388
  it "should return array of values when the values are allowed" do
385
- formatter.format("a,b,1").must_equal(['a', 'b', '1'])
389
+ _(formatter.format("a,b,1")).must_equal(['a', 'b', '1'])
386
390
  end
387
391
 
388
392
  it "should raise argument error when any of the values isn't in the list" do
389
- proc { formatter.format("c,d") }.must_raise ArgumentError
390
- proc { formatter.format('1,x') }.must_raise ArgumentError
393
+ _{ formatter.format("c,d") }.must_raise ArgumentError
394
+ _{ formatter.format('1,x') }.must_raise ArgumentError
391
395
  end
392
396
 
393
397
  it "should remove duplicate values" do
394
- formatter.format("a,a,a,a,a").must_equal ['a']
398
+ _(formatter.format("a,a,a,a,a")).must_equal ['a']
395
399
  end
396
400
 
397
401
  it "should not change order of the values" do
398
- formatter.format("a,b,2,1").must_equal ['a', 'b', '2', '1']
402
+ _(formatter.format("a,b,2,1")).must_equal ['a', 'b', '2', '1']
399
403
  end
400
404
 
401
405
  it "should return empty array on nil" do
402
- formatter.format(nil).must_equal []
406
+ _(formatter.format(nil)).must_equal []
403
407
  end
404
408
 
405
409
  it "should return empty array on empty string" do
406
- formatter.format("").must_equal []
410
+ _(formatter.format("")).must_equal []
407
411
  end
408
412
 
409
413
  it "should list allowed values in description" do
410
- formatter.description.must_equal("Any combination (comma separated list) of ''1', '2', 'a', 'b''")
414
+ _(formatter.description).must_equal("Any combination (comma separated list) of ''1', '2', 'a', 'b''")
411
415
  end
412
416
 
413
417
  end
@@ -417,23 +421,23 @@ describe HammerCLI::Options::Normalizers do
417
421
  let(:formatter) { HammerCLI::Options::Normalizers::DateTime.new }
418
422
 
419
423
  it "should raise argument error when the value is nil" do
420
- proc { formatter.format(nil) }.must_raise ArgumentError
424
+ _{ formatter.format(nil) }.must_raise ArgumentError
421
425
  end
422
426
 
423
427
  it "should raise argument error when the value is not a date" do
424
- proc { formatter.format("not a date") }.must_raise ArgumentError
428
+ _{ formatter.format("not a date") }.must_raise ArgumentError
425
429
  end
426
430
 
427
431
  it "should accept and parse iso8601" do
428
- formatter.format("1986-01-01T08:30:20").must_equal("1986-01-01T08:30:20+00:00")
432
+ _(formatter.format("1986-01-01T08:30:20")).must_equal("1986-01-01T08:30:20+00:00")
429
433
  end
430
434
 
431
435
  it "should accept and parse YYYY-MM-DD HH:MM:SS" do
432
- formatter.format("1986-01-01 08:30:20").must_equal("1986-01-01T08:30:20+00:00")
436
+ _(formatter.format("1986-01-01 08:30:20")).must_equal("1986-01-01T08:30:20+00:00")
433
437
  end
434
438
 
435
439
  it "should accept and parse YYYY/MM/DD HH:MM:SS" do
436
- formatter.format("1986/01/01 08:30:20").must_equal("1986-01-01T08:30:20+00:00")
440
+ _(formatter.format("1986/01/01 08:30:20")).must_equal("1986-01-01T08:30:20+00:00")
437
441
  end
438
442
 
439
443
  end
@@ -41,7 +41,7 @@ describe HammerCLI::Options::OptionDefinition do
41
41
  opt = TestOptionFormattersCmd.find_option("--test-format")
42
42
 
43
43
  opt_instance = opt.of(TestOptionFormattersCmd.new([]))
44
- opt_instance.read.must_equal '>>>A<<<'
44
+ _(opt_instance.read).must_equal '>>>A<<<'
45
45
  end
46
46
 
47
47
  it "should use formatter as a conversion block" do
@@ -54,7 +54,7 @@ describe HammerCLI::Options::OptionDefinition do
54
54
  else
55
55
  opt_instance.take('B')
56
56
  end
57
- opt_instance.read.must_equal '>>>B<<<'
57
+ _(opt_instance.read).must_equal '>>>B<<<'
58
58
  end
59
59
  end
60
60
 
@@ -64,8 +64,8 @@ describe HammerCLI::Options::OptionDefinition do
64
64
  cmd = TestDeprecatedOptionCmd.new("", context)
65
65
 
66
66
  _, err = capture_io { cmd.run(["--another-deprecated=VALUE"]) }
67
- err.must_match(/Warning: Option --another-deprecated is deprecated. It is going to be removed/)
68
- context[:old_option].must_equal "VALUE"
67
+ _(err).must_match(/Warning: Option --another-deprecated is deprecated. It is going to be removed/)
68
+ _(context[:old_option]).must_equal "VALUE"
69
69
  end
70
70
 
71
71
  it "prints deprecation warning (extended version)" do
@@ -73,8 +73,8 @@ describe HammerCLI::Options::OptionDefinition do
73
73
  cmd = TestDeprecatedOptionCmd.new("", context)
74
74
 
75
75
  _, err = capture_io { cmd.run(["--deprecated=VALUE"]) }
76
- err.must_match(/Warning: Option --deprecated is deprecated. Use --test-option instead/)
77
- context[:test_option].must_equal "VALUE"
76
+ _(err).must_match(/Warning: Option --deprecated is deprecated. Use --test-option instead/)
77
+ _(context[:test_option]).must_equal "VALUE"
78
78
  end
79
79
 
80
80
  it "doesn't print deprecation warning if the option is not used" do
@@ -82,22 +82,22 @@ describe HammerCLI::Options::OptionDefinition do
82
82
  cmd = TestDeprecatedOptionCmd.new('', context)
83
83
  cmd.find_option('--deprecated')
84
84
  _out, err = capture_io { cmd.run([]) }
85
- err.must_equal ''
85
+ _(err).must_equal ''
86
86
  end
87
87
 
88
88
  it 'shows depracated message in help' do
89
89
  opt = opt_with_deprecation("Use --better-switch instead")
90
- opt.description.must_equal "Test option (Deprecated: Use --better-switch instead)"
90
+ _(opt.description).must_equal "Test option (Deprecated: Use --better-switch instead)"
91
91
  end
92
92
 
93
93
  it 'shows flag specific depracated message in help' do
94
94
  opt = opt_with_deprecation('--test-option' => "Use --better-switch instead")
95
- opt.description.must_equal "Test option (--test-option is deprecated: Use --better-switch instead)"
95
+ _(opt.description).must_equal "Test option (--test-option is deprecated: Use --better-switch instead)"
96
96
  end
97
97
 
98
98
  it 'shows multiple flag specific depracated messages in help' do
99
99
  opt = opt_with_deprecation('--test-option' => "Use --better-switch instead", '--test-option2' => 'This is deprecated too')
100
- opt.description.must_equal "Test option (--test-option is deprecated: Use --better-switch instead, --test-option2 is deprecated: This is deprecated too)"
100
+ _(opt.description).must_equal "Test option (--test-option is deprecated: Use --better-switch instead, --test-option2 is deprecated: This is deprecated too)"
101
101
  end
102
102
  end
103
103
 
@@ -106,7 +106,7 @@ describe HammerCLI::Options::OptionDefinition do
106
106
  context = {}
107
107
  cmd = TestOptionFormattersCmd.new("", context)
108
108
  cmd.run(["--test-context=VALUE"])
109
- context[:test_option].must_equal "VALUE"
109
+ _(context[:test_option]).must_equal "VALUE"
110
110
  end
111
111
  end
112
112
  end
@@ -15,34 +15,34 @@ describe HammerCLI::Options::OptionFamily do
15
15
 
16
16
  describe 'switch' do
17
17
  it 'returns nil if family is empty' do
18
- family.switch.must_be_nil
18
+ _(family.switch).must_be_nil
19
19
  end
20
20
 
21
21
  it 'returns parent switch if family has no children' do
22
22
  family.parent('--test-one', '', '')
23
- family.switch.must_equal '--test-one'
23
+ _(family.switch).must_equal '--test-one'
24
24
  end
25
25
 
26
26
  it 'returns switch based on members' do
27
- full_family.switch.must_equal '--test[-two|-one]'
27
+ _(full_family.switch).must_equal '--test[-two|-one]'
28
28
  end
29
29
  end
30
30
 
31
31
  describe 'description' do
32
32
  it 'returns parent description if nothing passed to initializer' do
33
- full_family.description.must_equal full_family.head.help[1]
33
+ _(full_family.description).must_equal full_family.head.help[1]
34
34
  end
35
35
 
36
36
  it 'returns description with deprecation message' do
37
- full_family.description.must_equal 'Test (--test-one is deprecated: Use --test-two instead)'
37
+ _(full_family.description).must_equal 'Test (--test-one is deprecated: Use --test-two instead)'
38
38
  end
39
39
  end
40
40
 
41
41
  describe 'adopt' do
42
42
  it 'appends an option to children' do
43
43
  full_family.adopt(third_option)
44
- full_family.children.size.must_equal 2
45
- third_option.family.must_equal full_family
44
+ _(full_family.children.size).must_equal 2
45
+ _(third_option.family).must_equal full_family
46
46
  end
47
47
  end
48
48
  end