hammer_cli 3.7.0 → 3.8.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -5,7 +5,7 @@ describe HammerCLI::Output::Adapter::Table do
5
5
  let(:adapter) { HammerCLI::Output::Adapter::Table.new }
6
6
 
7
7
  it "allows default pagination" do
8
- adapter.paginate_by_default?.must_equal true
8
+ _(adapter.paginate_by_default?).must_equal true
9
9
  end
10
10
 
11
11
  context "print_collection" do
@@ -40,11 +40,11 @@ describe HammerCLI::Output::Adapter::Table do
40
40
  let(:empty_data) { HammerCLI::Output::RecordCollection.new [] }
41
41
 
42
42
  it "should print column name " do
43
- proc { adapter.print_collection(fields, data) }.must_output(/.*NAME.*/, "")
43
+ _{ adapter.print_collection(fields, data) }.must_output(/.*NAME.*/, "")
44
44
  end
45
45
 
46
46
  it "should print field value" do
47
- proc { adapter.print_collection(fields, data) }.must_output(/.*John Doe.*/, "")
47
+ _{ adapter.print_collection(fields, data) }.must_output(/.*John Doe.*/, "")
48
48
  end
49
49
 
50
50
  it "does not print fields which data are missing from api by default" do
@@ -58,7 +58,7 @@ describe HammerCLI::Output::Adapter::Table do
58
58
  ''
59
59
  ].join("\n")
60
60
 
61
- proc { adapter.print_collection(fields, data) }.must_output(expected_output)
61
+ _{ adapter.print_collection(fields, data) }.must_output(expected_output)
62
62
  end
63
63
 
64
64
  it "prints fields which data are missing from api when field has hide_missing flag set to false" do
@@ -72,18 +72,18 @@ describe HammerCLI::Output::Adapter::Table do
72
72
  ''
73
73
  ].join("\n")
74
74
 
75
- proc { adapter.print_collection(fields, data) }.must_output(expected_output)
75
+ _{ adapter.print_collection(fields, data) }.must_output(expected_output)
76
76
  end
77
77
 
78
78
  context "pagination" do
79
79
  it "should print pagination info if data are not complete" do
80
80
  data = HammerCLI::Output::RecordCollection.new([record], { :total => 2, :page => 1, :per_page => 1, :subtotal => 2 })
81
- proc { adapter.print_collection(fields, data) }.must_output(/.*Page 1 of 2 (use --page and --per-page for navigation)*/, "")
81
+ _{ adapter.print_collection(fields, data) }.must_output(/.*Page 1 of 2 (use --page and --per-page for navigation)*/, "")
82
82
  end
83
83
 
84
84
  it "should print pagination info if data are complete" do
85
85
  data = HammerCLI::Output::RecordCollection.new([record], { :total => 1, :page => 1, :per_page => 1, :subtotal => 1 })
86
- proc { adapter.print_collection(fields, data) }.must_output("--------\nNAME \n--------\nJohn Doe\n--------\n", "")
86
+ _{ adapter.print_collection(fields, data) }.must_output("--------\nNAME \n--------\nJohn Doe\n--------\n", "")
87
87
  end
88
88
  end
89
89
 
@@ -95,7 +95,7 @@ describe HammerCLI::Output::Adapter::Table do
95
95
 
96
96
  it "should ommit column of type Id by default" do
97
97
  out, _ = capture_io { adapter.print_collection(fields, data) }
98
- out.wont_match(/.*ID.*/)
98
+ _(out).wont_match(/.*ID.*/)
99
99
  end
100
100
 
101
101
  it "should ommit column of type Id by default but no data" do
@@ -105,13 +105,13 @@ describe HammerCLI::Output::Adapter::Table do
105
105
  "----",
106
106
  ""
107
107
  ].join("\n")
108
- proc { adapter.print_collection(fields, empty_data) }.must_output(expected_output)
108
+ _{ adapter.print_collection(fields, empty_data) }.must_output(expected_output)
109
109
  end
110
110
 
111
111
  it "should print column of type Id when --show-ids is set" do
112
112
  adapter = HammerCLI::Output::Adapter::Table.new( { :show_ids => true } )
113
113
  out, _ = capture_io { adapter.print_collection(fields, data) }
114
- out.must_match(/.*ID.*/)
114
+ _(out).must_match(/.*ID.*/)
115
115
  end
116
116
 
117
117
  it "should print column of type ID when --show-ids is set but no data" do
@@ -122,19 +122,19 @@ describe HammerCLI::Output::Adapter::Table do
122
122
  "",
123
123
  ].join("\n")
124
124
  adapter = HammerCLI::Output::Adapter::Table.new( { :show_ids => true } )
125
- proc { adapter.print_collection(fields, empty_data) }.must_output(expected_output)
125
+ _{ adapter.print_collection(fields, empty_data) }.must_output(expected_output)
126
126
  end
127
127
  end
128
128
 
129
129
  context "handle headers" do
130
130
  it "should print headers by default" do
131
131
  out, _ = capture_io { adapter.print_collection(fields, data) }
132
- out.must_match(/.*NAME.*/)
132
+ _(out).must_match(/.*NAME.*/)
133
133
  end
134
134
 
135
135
  it "should print headers by default even if there is no data" do
136
136
  out, _ = capture_io { adapter.print_collection(fields, empty_data) }
137
- out.must_match(/.*NAME.*/)
137
+ _(out).must_match(/.*NAME.*/)
138
138
  end
139
139
 
140
140
  it "should print data only when --no-headers is set" do
@@ -143,13 +143,13 @@ describe HammerCLI::Output::Adapter::Table do
143
143
  "",
144
144
  ].join("\n")
145
145
  adapter = HammerCLI::Output::Adapter::Table.new( { :no_headers => true } )
146
- proc { adapter.print_collection(fields, data) }.must_output(expected_output)
146
+ _{ adapter.print_collection(fields, data) }.must_output(expected_output)
147
147
  end
148
148
 
149
149
  it "should print nothing when --no-headers is set but no data" do
150
150
  expected_output = ""
151
151
  adapter = HammerCLI::Output::Adapter::Table.new( { :no_headers => true } )
152
- proc { adapter.print_collection(fields, empty_data) }.must_output(expected_output)
152
+ _{ adapter.print_collection(fields, empty_data) }.must_output(expected_output)
153
153
  end
154
154
  end
155
155
 
@@ -168,7 +168,7 @@ describe HammerCLI::Output::Adapter::Table do
168
168
  ""
169
169
  ].join("\n")
170
170
 
171
- proc { adapter.print_collection(fields, data) }.must_output(expected_output)
171
+ _{ adapter.print_collection(fields, data) }.must_output(expected_output)
172
172
  end
173
173
 
174
174
  it "calculates correct width of czech characters" do
@@ -184,7 +184,7 @@ describe HammerCLI::Output::Adapter::Table do
184
184
  ""
185
185
  ].join("\n")
186
186
 
187
- proc { adapter.print_collection(fields, data) }.must_output(expected_output)
187
+ _{ adapter.print_collection(fields, data) }.must_output(expected_output)
188
188
  end
189
189
 
190
190
  it "calculates correct width of colorized strings" do
@@ -200,7 +200,7 @@ describe HammerCLI::Output::Adapter::Table do
200
200
  ""
201
201
  ].join("\n").gsub('John', "#{red}John#{reset}")
202
202
 
203
- proc { adapter.print_collection(fields, data) }.must_output(expected_output)
203
+ _{ adapter.print_collection(fields, data) }.must_output(expected_output)
204
204
  end
205
205
 
206
206
  it "truncates two-column characters when it exceeds maximum width" do
@@ -216,7 +216,7 @@ describe HammerCLI::Output::Adapter::Table do
216
216
  ""
217
217
  ].join("\n")
218
218
 
219
- proc { adapter.print_collection(fields, data) }.must_output(expected_output)
219
+ _{ adapter.print_collection(fields, data) }.must_output(expected_output)
220
220
  end
221
221
 
222
222
  it "truncates colorized string string when it exceeds maximum width" do
@@ -232,7 +232,7 @@ describe HammerCLI::Output::Adapter::Table do
232
232
  ""
233
233
  ].join("\n").gsub('SomeVer', "#{red}SomeVer#{reset}")
234
234
 
235
- proc { adapter.print_collection(fields, data) }.must_output(expected_output)
235
+ _{ adapter.print_collection(fields, data) }.must_output(expected_output)
236
236
  end
237
237
 
238
238
  it "truncates string when it exceeds maximum width" do
@@ -248,7 +248,7 @@ describe HammerCLI::Output::Adapter::Table do
248
248
  ""
249
249
  ].join("\n")
250
250
 
251
- proc { adapter.print_collection(fields, data) }.must_output(expected_output)
251
+ _{ adapter.print_collection(fields, data) }.must_output(expected_output)
252
252
  end
253
253
 
254
254
  it "truncates string when it exceeds width" do
@@ -264,7 +264,7 @@ describe HammerCLI::Output::Adapter::Table do
264
264
  ""
265
265
  ].join("\n")
266
266
 
267
- proc { adapter.print_collection(fields, data) }.must_output(expected_output)
267
+ _{ adapter.print_collection(fields, data) }.must_output(expected_output)
268
268
  end
269
269
 
270
270
  it "sets width to the longest column name when no data" do
@@ -277,7 +277,7 @@ describe HammerCLI::Output::Adapter::Table do
277
277
  "------------------------|---------",
278
278
  ""
279
279
  ].join("\n")
280
- proc { adapter.print_collection(fields, empty_data) }.must_output(expected_output)
280
+ _{ adapter.print_collection(fields, empty_data) }.must_output(expected_output)
281
281
  end
282
282
 
283
283
  it "sets certain width" do
@@ -293,7 +293,7 @@ describe HammerCLI::Output::Adapter::Table do
293
293
  ""
294
294
  ].join("\n")
295
295
 
296
- proc { adapter.print_collection(fields, data) }.must_output(expected_output)
296
+ _{ adapter.print_collection(fields, data) }.must_output(expected_output)
297
297
  end
298
298
 
299
299
  it "sets certain width when no data" do
@@ -307,7 +307,7 @@ describe HammerCLI::Output::Adapter::Table do
307
307
  ""
308
308
  ].join("\n")
309
309
 
310
- proc { adapter.print_collection(fields, empty_data) }.must_output(expected_output)
310
+ _{ adapter.print_collection(fields, empty_data) }.must_output(expected_output)
311
311
  end
312
312
 
313
313
 
@@ -324,7 +324,7 @@ describe HammerCLI::Output::Adapter::Table do
324
324
  ""
325
325
  ].join("\n")
326
326
 
327
- proc { adapter.print_collection(fields, data) }.must_output(expected_output)
327
+ _{ adapter.print_collection(fields, data) }.must_output(expected_output)
328
328
  end
329
329
 
330
330
  it "gives preference to width over maximal width when no data" do
@@ -338,7 +338,7 @@ describe HammerCLI::Output::Adapter::Table do
338
338
  ""
339
339
  ].join("\n")
340
340
 
341
- proc { adapter.print_collection(fields, empty_data) }.must_output(expected_output)
341
+ _{ adapter.print_collection(fields, empty_data) }.must_output(expected_output)
342
342
  end
343
343
 
344
344
 
@@ -354,7 +354,7 @@ describe HammerCLI::Output::Adapter::Table do
354
354
 
355
355
  adapter = HammerCLI::Output::Adapter::Table.new({}, { :Field => [ DotFormatter.new ]})
356
356
  out, _ = capture_io { adapter.print_collection(fields, data) }
357
- out.must_match(/.*-DOT-.*/)
357
+ _(out).must_match(/.*-DOT-.*/)
358
358
  end
359
359
 
360
360
  it "should not break formatting" do
@@ -375,7 +375,7 @@ describe HammerCLI::Output::Adapter::Table do
375
375
  ""
376
376
  ].join("\n")
377
377
 
378
- proc { adapter.print_collection([field_long], data) }.must_output(expected_output)
378
+ _{ adapter.print_collection([field_long], data) }.must_output(expected_output)
379
379
  end
380
380
 
381
381
  end
@@ -401,9 +401,7 @@ describe HammerCLI::Output::Adapter::Table do
401
401
  "---|------------",
402
402
  ).join("\n") + "\n---|------------\n"
403
403
 
404
- proc do
405
- adapter.print_collection(fields, collection_data)
406
- end.must_output(expected_output)
404
+ _{adapter.print_collection(fields, collection_data)}.must_output(expected_output)
407
405
  end
408
406
 
409
407
  it 'prints first chunk' do
@@ -417,11 +415,9 @@ describe HammerCLI::Output::Adapter::Table do
417
415
  "---|-----------",
418
416
  ).join("\n") + "\n"
419
417
 
420
- proc do
421
- adapter.print_collection(
422
- fields, collection_data[0...10], current_chunk: :first
423
- )
424
- end.must_output(expected_output)
418
+ _{adapter.print_collection(
419
+ fields, collection_data[0...10], current_chunk: :first
420
+ )}.must_output(expected_output)
425
421
  end
426
422
 
427
423
  it 'prints another chunk' do
@@ -429,11 +425,9 @@ describe HammerCLI::Output::Adapter::Table do
429
425
  r << ["#{t} | John Doe #{t}"]
430
426
  end.flatten(1).join("\n") + "\n"
431
427
 
432
- proc do
433
- adapter.print_collection(
434
- fields, collection_data[10...20], current_chunk: :another
435
- )
436
- end.must_output(expected_output)
428
+ _{adapter.print_collection(
429
+ fields, collection_data[10...20], current_chunk: :another
430
+ )}.must_output(expected_output)
437
431
  end
438
432
  #
439
433
  it 'prints last chunk' do
@@ -441,11 +435,9 @@ describe HammerCLI::Output::Adapter::Table do
441
435
  r << ["#{t} | John Doe #{t}"]
442
436
  end.flatten(1).join("\n") + "\n---|------------\n"
443
437
 
444
- proc do
445
- adapter.print_collection(
446
- fields, collection_data[20...30], current_chunk: :last
447
- )
448
- end.must_output(expected_output)
438
+ _{adapter.print_collection(
439
+ fields, collection_data[20...30], current_chunk: :last
440
+ )}.must_output(expected_output)
449
441
  end
450
442
  end
451
443
 
@@ -458,7 +450,7 @@ describe HammerCLI::Output::Adapter::Table do
458
450
  it "should not print to stdout when --output-file is set" do
459
451
  fields = [field_firstname]
460
452
 
461
- proc { adapter.print_collection(fields, data) }.must_output("")
453
+ _{ adapter.print_collection(fields, data) }.must_output("")
462
454
  end
463
455
 
464
456
  it "should print to file if --output-file is set" do
@@ -474,14 +466,14 @@ describe HammerCLI::Output::Adapter::Table do
474
466
 
475
467
  adapter.print_collection(fields, data)
476
468
  tempfile.close
477
- IO.read(tempfile.path).must_equal(expected_output)
469
+ _(IO.read(tempfile.path)).must_equal(expected_output)
478
470
  end
479
471
 
480
472
  end
481
473
 
482
474
  context 'print_message' do
483
475
  it 'should print message with nil params' do
484
- proc { adapter.print_message('MESSAGE', nil) }.must_output(/.*MESSAGE.*/, '')
476
+ _{ adapter.print_message('MESSAGE', nil) }.must_output(/.*MESSAGE.*/, '')
485
477
  end
486
478
  end
487
479
  end
@@ -6,7 +6,7 @@ describe HammerCLI::Output::Adapter::Yaml do
6
6
  let(:adapter) { HammerCLI::Output::Adapter::Yaml.new(context, HammerCLI::Output::Output.formatters) }
7
7
 
8
8
  it "forbids default pagination" do
9
- adapter.paginate_by_default?.must_equal false
9
+ _(adapter.paginate_by_default?).must_equal false
10
10
  end
11
11
 
12
12
  context "print_message" do
@@ -19,7 +19,7 @@ describe HammerCLI::Output::Adapter::Yaml do
19
19
  ''
20
20
  ].join("\n")
21
21
 
22
- proc { adapter.print_message(msg, params) }.must_output(expected_output)
22
+ _{ adapter.print_message(msg, params) }.must_output(expected_output)
23
23
  end
24
24
 
25
25
  it "prints the message with name and id" do
@@ -33,7 +33,7 @@ describe HammerCLI::Output::Adapter::Yaml do
33
33
  ''
34
34
  ].join("\n")
35
35
 
36
- proc { adapter.print_message(msg, params) }.must_output(expected_output)
36
+ _{ adapter.print_message(msg, params) }.must_output(expected_output)
37
37
  end
38
38
 
39
39
  it 'prints the message with nil params' do
@@ -44,14 +44,14 @@ describe HammerCLI::Output::Adapter::Yaml do
44
44
  ':message: MESSAGE',
45
45
  ''
46
46
  ].join("\n")
47
- proc { adapter.print_message(msg, params) }.must_output(expected_output)
47
+ _{ adapter.print_message(msg, params) }.must_output(expected_output)
48
48
  end
49
49
  end
50
50
 
51
51
  context "print_collection" do
52
52
 
53
53
  let(:id) { Fields::Id.new(:path => [:id], :label => "Id") }
54
- let(:name) { Fields::Field.new(:path => [:name], :label => "Name") }
54
+ let(:firstname) { Fields::Field.new(:path => [:name], :label => "Name") }
55
55
  let(:unlabeled) { Fields::Field.new(:path => [:name]) }
56
56
  let(:surname) { Fields::Field.new(:path => [:surname], :label => "Surname") }
57
57
  let(:address_city) { Fields::Field.new(:path => [:address, :city], :label => "City") }
@@ -106,15 +106,15 @@ describe HammerCLI::Output::Adapter::Yaml do
106
106
  }]}
107
107
 
108
108
  it "should print one field" do
109
- fields = [name]
109
+ fields = [firstname]
110
110
  expected_output = YAML.dump([{ 'Name' => 'John' }])
111
- proc { adapter.print_collection(fields, data) }.must_output(expected_output)
111
+ _{ adapter.print_collection(fields, data) }.must_output(expected_output)
112
112
  end
113
113
 
114
114
  it "should field with nested data" do
115
115
  fields = [address_city]
116
116
  expected_output = YAML.dump([{ 'City' => 'New York' }])
117
- proc { adapter.print_collection(fields, data) }.must_output(expected_output)
117
+ _{ adapter.print_collection(fields, data) }.must_output(expected_output)
118
118
  end
119
119
 
120
120
  it "should print labeled fields" do
@@ -126,7 +126,7 @@ describe HammerCLI::Output::Adapter::Yaml do
126
126
  }
127
127
  }]
128
128
  expected_output = YAML.dump(hash)
129
- proc { adapter.print_collection(fields, data) }.must_output(expected_output)
129
+ _{ adapter.print_collection(fields, data) }.must_output(expected_output)
130
130
  end
131
131
 
132
132
  it "should print collection" do
@@ -146,7 +146,7 @@ describe HammerCLI::Output::Adapter::Yaml do
146
146
  }]
147
147
 
148
148
  expected_output = YAML.dump(hash)
149
- proc { adapter.print_collection(fields, data) }.must_output(expected_output)
149
+ _{ adapter.print_collection(fields, data) }.must_output(expected_output)
150
150
  end
151
151
 
152
152
  it "should print collection with one element" do
@@ -162,7 +162,7 @@ describe HammerCLI::Output::Adapter::Yaml do
162
162
  }]
163
163
 
164
164
  expected_output = YAML.dump(hash)
165
- proc { adapter.print_collection(fields, data) }.must_output(expected_output)
165
+ _{ adapter.print_collection(fields, data) }.must_output(expected_output)
166
166
  end
167
167
 
168
168
  it "should print unnumbered collection" do
@@ -181,7 +181,7 @@ describe HammerCLI::Output::Adapter::Yaml do
181
181
  }]
182
182
 
183
183
  expected_output = YAML.dump(hash)
184
- proc { adapter.print_collection(fields, data) }.must_output(expected_output)
184
+ _{ adapter.print_collection(fields, data) }.must_output(expected_output)
185
185
  end
186
186
 
187
187
  it "should print unnumbered collection with one element" do
@@ -196,24 +196,24 @@ describe HammerCLI::Output::Adapter::Yaml do
196
196
  }]
197
197
 
198
198
  expected_output = YAML.dump(hash)
199
- proc { adapter.print_collection(fields, data) }.must_output(expected_output)
199
+ _{ adapter.print_collection(fields, data) }.must_output(expected_output)
200
200
  end
201
201
 
202
202
 
203
203
  it "hides ids by default" do
204
- fields = [id, name]
204
+ fields = [id, firstname]
205
205
  hash = [{'Name' => 'John'}]
206
206
  expected_output = YAML.dump(hash)
207
207
 
208
- proc { adapter.print_collection(fields, data) }.must_output(expected_output)
208
+ _{ adapter.print_collection(fields, data) }.must_output(expected_output)
209
209
  end
210
210
 
211
211
  it "skips blank values" do
212
- fields = [name, blank]
212
+ fields = [firstname, blank]
213
213
  hash = [{'Name' => 'John'}]
214
214
  expected_output = YAML.dump(hash)
215
215
 
216
- proc { adapter.print_collection(fields, data) }.must_output(expected_output)
216
+ _{ adapter.print_collection(fields, data) }.must_output(expected_output)
217
217
  end
218
218
 
219
219
  it "does not print fields which data are missing from api by default" do
@@ -221,7 +221,7 @@ describe HammerCLI::Output::Adapter::Yaml do
221
221
  hash = [{ 'Surname' => 'Doe' }]
222
222
  expected_output = YAML.dump(hash)
223
223
 
224
- proc { adapter.print_collection(fields, data) }.must_output(expected_output)
224
+ _{ adapter.print_collection(fields, data) }.must_output(expected_output)
225
225
  end
226
226
 
227
227
  it "prints fields which data are missing from api when field has hide_missing flag set to false" do
@@ -229,7 +229,7 @@ describe HammerCLI::Output::Adapter::Yaml do
229
229
  hash = [{ 'Surname' => 'Doe', 'Missing' => HammerCLI::Output::DataMissing.new }]
230
230
  expected_output = YAML.dump(hash)
231
231
 
232
- proc { adapter.print_collection(fields, data) }.must_output(expected_output)
232
+ _{ adapter.print_collection(fields, data) }.must_output(expected_output)
233
233
  end
234
234
 
235
235
  it "should print key -> value" do
@@ -250,11 +250,11 @@ describe HammerCLI::Output::Adapter::Yaml do
250
250
  }]
251
251
  expected_output = YAML.dump(hash)
252
252
 
253
- proc { adapter.print_collection(fields, data) }.must_output(expected_output)
253
+ _{ adapter.print_collection(fields, data) }.must_output(expected_output)
254
254
  end
255
255
 
256
256
  context 'capitalization' do
257
- let(:fields) { [name, surname] }
257
+ let(:fields) { [firstname, surname] }
258
258
  let(:raw_hash) { { 'Name' => 'John', 'Surname' => 'Doe' } }
259
259
  let(:settings) { HammerCLI::Settings }
260
260
  let(:context) { { :capitalization => HammerCLI.capitalization } }
@@ -266,7 +266,7 @@ describe HammerCLI::Output::Adapter::Yaml do
266
266
  out, = capture_io do
267
267
  adapter.print_collection(fields, data)
268
268
  end
269
- out.must_equal(expected_output)
269
+ _(out).must_equal(expected_output)
270
270
  end
271
271
 
272
272
  it 'should respect selected capitalize capitalization' do
@@ -276,7 +276,7 @@ describe HammerCLI::Output::Adapter::Yaml do
276
276
  out, = capture_io do
277
277
  adapter.print_collection(fields, data)
278
278
  end
279
- out.must_equal(expected_output)
279
+ _(out).must_equal(expected_output)
280
280
  end
281
281
 
282
282
  it 'should respect selected upcase capitalization' do
@@ -286,7 +286,7 @@ describe HammerCLI::Output::Adapter::Yaml do
286
286
  out, = capture_io do
287
287
  adapter.print_collection(fields, data)
288
288
  end
289
- out.must_equal(expected_output)
289
+ _(out).must_equal(expected_output)
290
290
  end
291
291
 
292
292
  it 'should print a warn for not supported capitalization' do
@@ -297,8 +297,8 @@ describe HammerCLI::Output::Adapter::Yaml do
297
297
  out, err = capture_io do
298
298
  adapter.print_collection(fields, data)
299
299
  end
300
- out.must_equal(expected_output)
301
- err.must_equal(expected_error)
300
+ _(out).must_equal(expected_output)
301
+ _(err).must_equal(expected_error)
302
302
  end
303
303
 
304
304
  it "shouldn't change capitalization if wasn't selected" do
@@ -308,7 +308,7 @@ describe HammerCLI::Output::Adapter::Yaml do
308
308
  out, = capture_io do
309
309
  adapter.print_collection(fields, data)
310
310
  end
311
- out.must_equal(expected_output)
311
+ _(out).must_equal(expected_output)
312
312
  end
313
313
  end
314
314
 
@@ -326,7 +326,7 @@ describe HammerCLI::Output::Adapter::Yaml do
326
326
  let(:collection_data) do
327
327
  HammerCLI::Output::RecordCollection.new(collection)
328
328
  end
329
- let(:fields) { [id, name] }
329
+ let(:fields) { [id, firstname] }
330
330
 
331
331
  it 'prints single chunk' do
332
332
  expected_output = YAML.dump(prepared_collection)
@@ -334,7 +334,7 @@ describe HammerCLI::Output::Adapter::Yaml do
334
334
  out, _err = capture_io do
335
335
  adapter.print_collection(fields, collection_data)
336
336
  end
337
- out.must_equal(expected_output)
337
+ _(out).must_equal(expected_output)
338
338
  end
339
339
 
340
340
  it 'prints first chunk' do
@@ -345,7 +345,7 @@ describe HammerCLI::Output::Adapter::Yaml do
345
345
  fields, collection_data[0...10], current_chunk: :first
346
346
  )
347
347
  end
348
- out.must_equal(expected_output)
348
+ _(out).must_equal(expected_output)
349
349
  end
350
350
 
351
351
  it 'prints another chunk' do
@@ -356,7 +356,7 @@ describe HammerCLI::Output::Adapter::Yaml do
356
356
  fields, collection_data[10...20], current_chunk: :another
357
357
  )
358
358
  end
359
- out.must_equal(expected_output)
359
+ _(out).must_equal(expected_output)
360
360
  end
361
361
 
362
362
  it 'prints last chunk' do
@@ -367,7 +367,7 @@ describe HammerCLI::Output::Adapter::Yaml do
367
367
  fields, collection_data[20...30], current_chunk: :last
368
368
  )
369
369
  end
370
- out.must_equal(expected_output)
370
+ _(out).must_equal(expected_output)
371
371
  end
372
372
  end
373
373
 
@@ -376,13 +376,13 @@ describe HammerCLI::Output::Adapter::Yaml do
376
376
  let(:context) { {:show_ids => true} }
377
377
 
378
378
  it "shows ids if it's required in the context" do
379
- fields = [id, name]
379
+ fields = [id, firstname]
380
380
  hash = [{
381
381
  'Id' => 112,
382
382
  'Name' => 'John'
383
383
  }]
384
384
  expected_output = YAML.dump(hash)
385
- proc { adapter.print_collection(fields, data) }.must_output(expected_output)
385
+ _{ adapter.print_collection(fields, data) }.must_output(expected_output)
386
386
  end
387
387
 
388
388
  end
@@ -393,13 +393,13 @@ describe HammerCLI::Output::Adapter::Yaml do
393
393
  let(:context) { {:output_file => tempfile} }
394
394
 
395
395
  it "should not print to stdout when --output-file is set" do
396
- fields = [name]
396
+ fields = [firstname]
397
397
 
398
- proc { adapter.print_collection(fields, data) }.must_output("")
398
+ _{ adapter.print_collection(fields, data) }.must_output("")
399
399
  end
400
400
 
401
401
  it "should print to file if --output-file is set" do
402
- fields = [name]
402
+ fields = [firstname]
403
403
  hash = [{
404
404
  'Name' => 'John'
405
405
  }]
@@ -407,7 +407,7 @@ describe HammerCLI::Output::Adapter::Yaml do
407
407
 
408
408
  adapter.print_collection(fields, data)
409
409
  tempfile.close
410
- IO.read(tempfile.path).must_equal(expected_output)
410
+ _(IO.read(tempfile.path)).must_equal(expected_output)
411
411
  end
412
412
 
413
413
  end