hammer_cli 0.15.1 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/doc/commands_modification.md +82 -0
  3. data/doc/creating_commands.md +78 -38
  4. data/doc/developer_docs.md +2 -0
  5. data/doc/help_modification.md +119 -0
  6. data/doc/i18n.md +2 -2
  7. data/doc/installation_rpm.md +3 -3
  8. data/doc/release_notes.md +9 -1
  9. data/lib/hammer_cli.rb +0 -1
  10. data/lib/hammer_cli/abstract.rb +44 -13
  11. data/lib/hammer_cli/exception_handler.rb +1 -1
  12. data/lib/hammer_cli/help/definition.rb +55 -0
  13. data/lib/hammer_cli/help/definition/abstract_item.rb +38 -0
  14. data/lib/hammer_cli/help/definition/list.rb +53 -0
  15. data/lib/hammer_cli/help/definition/section.rb +36 -0
  16. data/lib/hammer_cli/help/definition/text.rb +21 -0
  17. data/lib/hammer_cli/help/text_builder.rb +26 -49
  18. data/lib/hammer_cli/i18n.rb +0 -1
  19. data/lib/hammer_cli/options/option_collector.rb +12 -9
  20. data/lib/hammer_cli/options/option_processor.rb +17 -0
  21. data/lib/hammer_cli/options/processor_list.rb +37 -0
  22. data/lib/hammer_cli/options/sources/base.rb +17 -0
  23. data/lib/hammer_cli/options/sources/command_line.rb +3 -1
  24. data/lib/hammer_cli/options/sources/saved_defaults.rb +3 -1
  25. data/lib/hammer_cli/options/validators/base.rb +20 -0
  26. data/lib/hammer_cli/options/validators/dsl.rb +160 -0
  27. data/lib/hammer_cli/options/validators/dsl_block_validator.rb +19 -0
  28. data/lib/hammer_cli/output/adapter/csv.rb +11 -11
  29. data/lib/hammer_cli/output/adapter/tree_structure.rb +5 -3
  30. data/lib/hammer_cli/output/definition.rb +42 -4
  31. data/lib/hammer_cli/output/dsl.rb +4 -2
  32. data/lib/hammer_cli/output/fields.rb +9 -2
  33. data/lib/hammer_cli/testing/messages.rb +6 -6
  34. data/lib/hammer_cli/utils.rb +15 -0
  35. data/lib/hammer_cli/version.rb +1 -1
  36. data/locale/ca/LC_MESSAGES/hammer-cli.mo +0 -0
  37. data/locale/de/LC_MESSAGES/hammer-cli.mo +0 -0
  38. data/locale/en/LC_MESSAGES/hammer-cli.mo +0 -0
  39. data/locale/en_GB/LC_MESSAGES/hammer-cli.mo +0 -0
  40. data/locale/es/LC_MESSAGES/hammer-cli.mo +0 -0
  41. data/locale/fr/LC_MESSAGES/hammer-cli.mo +0 -0
  42. data/locale/it/LC_MESSAGES/hammer-cli.mo +0 -0
  43. data/locale/ja/LC_MESSAGES/hammer-cli.mo +0 -0
  44. data/locale/ko/LC_MESSAGES/hammer-cli.mo +0 -0
  45. data/locale/pt_BR/LC_MESSAGES/hammer-cli.mo +0 -0
  46. data/locale/ru/LC_MESSAGES/hammer-cli.mo +0 -0
  47. data/locale/zh_CN/LC_MESSAGES/hammer-cli.mo +0 -0
  48. data/locale/zh_TW/LC_MESSAGES/hammer-cli.mo +0 -0
  49. data/test/unit/abstract_test.rb +70 -5
  50. data/test/unit/exception_handler_test.rb +1 -1
  51. data/test/unit/help/definition/abstract_item_test.rb +33 -0
  52. data/test/unit/help/definition/list_test.rb +17 -0
  53. data/test/unit/help/definition/section_test.rb +25 -0
  54. data/test/unit/help/definition/text_test.rb +11 -0
  55. data/test/unit/help/definition_test.rb +236 -0
  56. data/test/unit/help/text_builder_test.rb +170 -1
  57. data/test/unit/options/option_collector_test.rb +18 -9
  58. data/test/unit/options/processor_list_test.rb +70 -0
  59. data/test/unit/{validator_test.rb → options/validators/dsl_test.rb} +57 -93
  60. data/test/unit/output/adapter/abstract_test.rb +3 -0
  61. data/test/unit/output/adapter/base_test.rb +5 -0
  62. data/test/unit/output/adapter/csv_test.rb +3 -0
  63. data/test/unit/output/adapter/json_test.rb +12 -0
  64. data/test/unit/output/adapter/table_test.rb +5 -0
  65. data/test/unit/output/adapter/yaml_test.rb +11 -0
  66. data/test/unit/output/definition_test.rb +221 -1
  67. data/test/unit/utils_test.rb +23 -0
  68. metadata +31 -5
  69. data/lib/hammer_cli/validator.rb +0 -172
@@ -2,17 +2,17 @@ require_relative '../test_helper'
2
2
 
3
3
  describe HammerCLI::Options::OptionCollector do
4
4
  before do
5
- recognised_options = [mock, mock]
6
- source1_result = {:option1 => 1, :option2 => nil, :option4 => HammerCLI::NilValue}
7
- source2_result = source1_result.merge({:option3 => 3})
5
+ @recognised_options = [mock('Option1'), mock('Option2')]
6
+ @source1_result = {:option1 => 1, :option2 => nil, :option4 => HammerCLI::NilValue}
7
+ @source2_result = @source1_result.merge({:option3 => 3})
8
8
 
9
- source1 = mock
10
- source1.expects(:get_options).with(recognised_options, {}).returns(source1_result)
9
+ @source1 = mock('Source1')
10
+ @source1.expects(:process).with(@recognised_options, {}).returns(@source1_result)
11
11
 
12
- source2 = mock
13
- source2.expects(:get_options).with(recognised_options, source1_result).returns(source2_result)
12
+ @source2 = mock('Source2')
13
+ @source2.expects(:process).with(@recognised_options, @source1_result).returns(@source2_result)
14
14
 
15
- @collector = HammerCLI::Options::OptionCollector.new(recognised_options, [source1, source2])
15
+ @collector = HammerCLI::Options::OptionCollector.new(@recognised_options, [@source1, @source2])
16
16
  end
17
17
 
18
18
  describe '#options' do
@@ -26,10 +26,19 @@ describe HammerCLI::Options::OptionCollector do
26
26
  assert_equal({:option1 => 1, :option2 => nil, :option3 => 3, :option4 => nil}, @collector.all_options)
27
27
  end
28
28
  end
29
-
29
+
30
30
  describe '#all_options_raw' do
31
31
  it 'returns all options with NIL values untranslated' do
32
32
  assert_equal({:option1 => 1, :option2 => nil, :option3 => 3, :option4 => HammerCLI::NilValue}, @collector.all_options_raw)
33
33
  end
34
+
35
+ it 'can process validations' do
36
+ validator = mock('Validator')
37
+ validator.expects(:process).with(@recognised_options, @source1_result).returns(@source1_result)
38
+
39
+ collector = HammerCLI::Options::OptionCollector.new(@recognised_options, [@source1, validator, @source2])
40
+
41
+ assert_equal({:option1 => 1, :option2 => nil, :option3 => 3, :option4 => HammerCLI::NilValue}, collector.all_options_raw)
42
+ end
34
43
  end
35
44
  end
@@ -0,0 +1,70 @@
1
+ require_relative '../test_helper'
2
+
3
+ describe HammerCLI::Options::ProcessorList do
4
+ let(:processor1) { stub('Processor1', :name => 'P1') }
5
+ let(:processor2) { stub('Processor2', :name => 'P2') }
6
+ let(:processor3) { stub('Processor3', :name => 'P3') }
7
+ let(:new_processor) { stub('NewProcessor', :name => 'NewP') }
8
+
9
+ let(:pl) { HammerCLI::Options::ProcessorList.new([processor1, processor2, processor3], name: 'TheProcessor') }
10
+
11
+ describe '#name' do
12
+ it 'returns the given name' do
13
+ assert_equal 'TheProcessor', pl.name
14
+ end
15
+ end
16
+
17
+ describe '#insert_relative' do
18
+ it 'appends' do
19
+ pl.insert_relative(:append, nil, new_processor)
20
+ assert_equal pl.map(&:name), ['P1', 'P2', 'P3', 'NewP']
21
+ end
22
+
23
+ it 'prepends' do
24
+ pl.insert_relative(:prepend, nil, new_processor)
25
+ assert_equal pl.map(&:name), ['NewP', 'P1', 'P2', 'P3']
26
+ end
27
+
28
+ it 'inserts after' do
29
+ pl.insert_relative(:after, 'P2', new_processor)
30
+ assert_equal pl.map(&:name), ['P1', 'P2', 'NewP', 'P3']
31
+ end
32
+
33
+ it 'inserts before' do
34
+ pl.insert_relative(:before, 'P2', new_processor)
35
+ assert_equal pl.map(&:name), ['P1', 'NewP', 'P2', 'P3']
36
+ end
37
+
38
+ it 'raises an exception when the processor was not found' do
39
+ ex = assert_raises ArgumentError do
40
+ pl.insert_relative(:before, 'Unknown', new_processor)
41
+ end
42
+ assert_equal "Option processor 'Unknown' not found", ex.message
43
+ end
44
+ end
45
+
46
+ describe '#find_by_name' do
47
+ it 'finds a processor' do
48
+ assert_equal processor2, pl.find_by_name('P2')
49
+ end
50
+
51
+ it 'raises an exception when the processor was not found' do
52
+ ex = assert_raises ArgumentError do
53
+ pl.find_by_name('Unknown')
54
+ end
55
+ assert_equal "Option processor 'Unknown' not found", ex.message
56
+ end
57
+ end
58
+
59
+ describe '#process' do
60
+ it 'calls all processors' do
61
+ defined_options = []
62
+ pl[0].expects(:process).with(defined_options, { :initial => 0 }).returns({ :initial => 0, :p1 => 1 })
63
+ pl[1].expects(:process).with(defined_options, { :initial => 0, :p1 => 1 }).returns({ :p2 => 2 })
64
+ pl[2].expects(:process).with(defined_options, { :p2 => 2 }).returns({ :p3 => 3 })
65
+
66
+ result = pl.process(defined_options, { :initial => 0 })
67
+ assert_equal({ :p3 => 3 }, result)
68
+ end
69
+ end
70
+ end
@@ -1,61 +1,50 @@
1
- require File.join(File.dirname(__FILE__), 'test_helper')
1
+ require 'hammer_cli/options/validators/dsl_block_validator'
2
+ require_relative '../../test_helper'
2
3
 
3
4
  describe "constraints" do
4
-
5
- class FakeCmd < Clamp::Command
6
- def initialize
7
- context = {
8
- :defaults => HammerCLI::Defaults.new({ :default => { :value => 2 }})
9
- }
10
- super("", context)
11
- @option_a = 1
12
- @option_b = 1
13
- @option_c = 1
14
- @option_unset_d = nil
15
- @option_unset_e = nil
16
- end
17
- end
18
-
19
- let(:cmd) {
20
- FakeCmd.new
21
- }
5
+ let(:option_values) {{
6
+ :option_a => 1,
7
+ :option_b => 1,
8
+ 'option_c' => 1,
9
+ :option_unset_d => nil,
10
+ :option_unset_e => nil
11
+ }}
22
12
 
23
13
  let(:option_names) { ["a", "b", "c", "unset-d", "unset-e", "default"] }
24
- let(:options_def) {
14
+ let(:options) {
25
15
  option_names.collect{ |n| Clamp::Option::Definition.new(["-"+n, "--option-"+n], n.upcase, "Option "+n.upcase) }
26
16
  }
27
- let(:options) { options_def.collect{|d| d.of(cmd) } }
28
17
 
29
- describe HammerCLI::Validator::BaseConstraint do
18
+ describe HammerCLI::Options::Validators::DSL::BaseConstraint do
30
19
 
31
- let(:cls) { HammerCLI::Validator::BaseConstraint }
20
+ let(:cls) { HammerCLI::Options::Validators::DSL::BaseConstraint }
32
21
 
33
22
  describe "exist?" do
34
23
  it "throws not implemented error" do
35
- constraint = cls.new(options, [:option_a, :option_b, :option_c])
24
+ constraint = cls.new(options, option_values, [:option_a, :option_b, :option_c])
36
25
  proc{ constraint.exist? }.must_raise NotImplementedError
37
26
  end
38
27
  end
39
28
 
40
29
  describe "rejected" do
41
30
  it "should raise exception when exist? returns true" do
42
- constraint = cls.new(options, [])
31
+ constraint = cls.new(options, option_values, [])
43
32
  constraint.stubs(:exist?).returns(true)
44
- proc{ constraint.rejected }.must_raise HammerCLI::Validator::ValidationError
33
+ proc{ constraint.rejected }.must_raise HammerCLI::Options::Validators::ValidationError
45
34
  end
46
35
 
47
36
  it "should raise exception with a message" do
48
- constraint = cls.new(options, [])
37
+ constraint = cls.new(options, option_values, [])
49
38
  constraint.stubs(:exist?).returns(true)
50
39
  begin
51
40
  constraint.rejected :msg => "CUSTOM MESSAGE"
52
- rescue HammerCLI::Validator::ValidationError => e
41
+ rescue HammerCLI::Options::Validators::ValidationError => e
53
42
  e.message.must_equal "CUSTOM MESSAGE"
54
43
  end
55
44
  end
56
45
 
57
46
  it "should return nil when exist? returns true" do
58
- constraint = cls.new(options, [])
47
+ constraint = cls.new(options, option_values, [])
59
48
  constraint.stubs(:exist?).returns(false)
60
49
  constraint.rejected.must_equal nil
61
50
  end
@@ -63,23 +52,23 @@ describe "constraints" do
63
52
 
64
53
  describe "required" do
65
54
  it "should raise exception when exist? returns true" do
66
- constraint = cls.new(options, [])
55
+ constraint = cls.new(options, option_values, [])
67
56
  constraint.stubs(:exist?).returns(false)
68
- proc{ constraint.required }.must_raise HammerCLI::Validator::ValidationError
57
+ proc{ constraint.required }.must_raise HammerCLI::Options::Validators::ValidationError
69
58
  end
70
59
 
71
60
  it "should raise exception with a message" do
72
- constraint = cls.new(options, [])
61
+ constraint = cls.new(options, option_values, [])
73
62
  constraint.stubs(:exist?).returns(false)
74
63
  begin
75
64
  constraint.rejected :msg => "CUSTOM MESSAGE"
76
- rescue HammerCLI::Validator::ValidationError => e
65
+ rescue HammerCLI::Options::Validators::ValidationError => e
77
66
  e.message.must_equal "CUSTOM MESSAGE"
78
67
  end
79
68
  end
80
69
 
81
70
  it "should return nil when exist? returns true" do
82
- constraint = cls.new(options, [])
71
+ constraint = cls.new(options, option_values, [])
83
72
  constraint.stubs(:exist?).returns(true)
84
73
  constraint.required.must_equal nil
85
74
  end
@@ -87,162 +76,137 @@ describe "constraints" do
87
76
 
88
77
  end
89
78
 
90
- describe HammerCLI::Validator::AllConstraint do
79
+ describe HammerCLI::Options::Validators::DSL::AllConstraint do
91
80
 
92
- let(:cls) { HammerCLI::Validator::AllConstraint }
81
+ let(:cls) { HammerCLI::Options::Validators::DSL::AllConstraint }
93
82
 
94
83
  describe "exist?" do
95
84
 
96
85
  it "should return true when no options are passed" do
97
- constraint = cls.new(options, [])
86
+ constraint = cls.new(options, option_values, [])
98
87
  constraint.exist?.must_equal true
99
88
  end
100
89
 
101
90
  it "should return true when all the options exist" do
102
- constraint = cls.new(options, [:option_a, :option_b, :option_c])
103
- constraint.exist?.must_equal true
104
- end
105
-
106
- it "should return true when all the options exist or are set in the defaults" do
107
- constraint = cls.new(options, [:option_a, :option_b, :option_c, :option_default])
91
+ constraint = cls.new(options, option_values, [:option_a, :option_b, :option_c])
108
92
  constraint.exist?.must_equal true
109
93
  end
110
94
 
111
95
  it "should return false when one of the options is missing" do
112
- constraint = cls.new(options, [:option_a, :option_b, :option_c, :option_unset_d])
96
+ constraint = cls.new(options, option_values, [:option_a, :option_b, :option_c, :option_unset_d])
113
97
  constraint.exist?.must_equal false
114
98
  end
115
99
  end
116
100
 
117
101
  end
118
102
 
119
- describe HammerCLI::Validator::OneOptionConstraint do
120
- let(:cls) { HammerCLI::Validator::OneOptionConstraint }
103
+ describe HammerCLI::Options::Validators::DSL::OneOptionConstraint do
104
+ let(:cls) { HammerCLI::Options::Validators::DSL::OneOptionConstraint }
121
105
 
122
106
  describe "exist?" do
123
107
  it "should return true when the option exist" do
124
- constraint = cls.new(options, :option_a)
125
- constraint.exist?.must_equal true
126
- end
127
-
128
- it "should return true when the option is set in the defaults" do
129
- constraint = cls.new(options, :option_default)
108
+ constraint = cls.new(options, option_values, :option_a)
130
109
  constraint.exist?.must_equal true
131
110
  end
132
111
 
133
112
  it "should return false when the option is missing" do
134
- constraint = cls.new(options, :option_unset_d)
113
+ constraint = cls.new(options, option_values, :option_unset_d)
135
114
  constraint.exist?.must_equal false
136
115
  end
137
116
  end
138
117
 
139
118
  describe "#rejected" do
140
119
  it "returns nil when the option is missing" do
141
- constraint = cls.new(options, :option_unset_d)
120
+ constraint = cls.new(options, option_values, :option_unset_d)
142
121
  constraint.rejected.must_equal nil
143
122
  end
144
123
 
145
124
  it "raises exception when the option is present" do
146
- constraint = cls.new(options, :option_a)
147
- e = proc{ constraint.rejected }.must_raise HammerCLI::Validator::ValidationError
125
+ constraint = cls.new(options, option_values, :option_a)
126
+ e = proc{ constraint.rejected }.must_raise HammerCLI::Options::Validators::ValidationError
148
127
  e.message.must_equal "You can't set option --option-a."
149
128
  end
150
129
  end
151
130
 
152
131
  describe "#required" do
153
132
  it "returns nil when the option exist" do
154
- constraint = cls.new(options, :option_a)
133
+ constraint = cls.new(options, option_values, :option_a)
155
134
  constraint.required.must_equal nil
156
135
  end
157
136
 
158
137
  it "raises exception when the option is present" do
159
- constraint = cls.new(options, :option_unset_d)
160
- e = proc{ constraint.required }.must_raise HammerCLI::Validator::ValidationError
138
+ constraint = cls.new(options, option_values, :option_unset_d)
139
+ e = proc{ constraint.required }.must_raise HammerCLI::Options::Validators::ValidationError
161
140
  e.message.must_equal 'Option --option-unset-d is required.'
162
141
  end
163
142
  end
164
143
 
165
144
  describe "#value" do
166
145
  it "returns value of the option" do
167
- constraint = cls.new(options, :option_a)
146
+ constraint = cls.new(options, option_values, :option_a)
168
147
  constraint.value.must_equal 1
169
148
  end
170
149
 
171
- it "returns value of the option defined in the defaults" do
172
- constraint = cls.new(options, :option_default)
173
- constraint.value.must_equal 2
174
- end
175
-
176
150
  it "returns nil when the option is missing" do
177
- constraint = cls.new(options, :option_unset_d)
151
+ constraint = cls.new(options, option_values, :option_unset_d)
178
152
  constraint.value.must_equal nil
179
153
  end
180
154
  end
181
155
  end
182
156
 
183
- describe HammerCLI::Validator::AnyConstraint do
157
+ describe HammerCLI::Options::Validators::DSL::AnyConstraint do
184
158
 
185
- let(:cls) { HammerCLI::Validator::AnyConstraint }
159
+ let(:cls) { HammerCLI::Options::Validators::DSL::AnyConstraint }
186
160
 
187
161
  describe "exist?" do
188
162
 
189
163
  it "should return true when no options are passed" do
190
- constraint = cls.new(options, [])
164
+ constraint = cls.new(options, option_values, [])
191
165
  constraint.exist?.must_equal true
192
166
  end
193
167
 
194
168
  it "should return true when one of the options exist" do
195
- constraint = cls.new(options, [:option_a, :option_unset_d, :option_unset_e])
196
- constraint.exist?.must_equal true
197
- end
198
-
199
- it "should return true when one of the options exist and is set in the defaults" do
200
- constraint = cls.new(options, [:option_default, :option_unset_d, :option_unset_e])
169
+ constraint = cls.new(options, option_values, [:option_a, :option_unset_d, :option_unset_e])
201
170
  constraint.exist?.must_equal true
202
171
  end
203
172
 
204
173
  it "should return false when all the options are missing" do
205
- constraint = cls.new(options, [:option_unset_d, :option_unset_e])
174
+ constraint = cls.new(options, option_values, [:option_unset_d, :option_unset_e])
206
175
  constraint.exist?.must_equal false
207
176
  end
208
177
  end
209
178
 
210
179
  end
211
180
 
212
- describe HammerCLI::Validator::OneOfConstraint do
181
+ describe HammerCLI::Options::Validators::DSL::OneOfConstraint do
213
182
 
214
- let(:cls) { HammerCLI::Validator::OneOfConstraint }
183
+ let(:cls) { HammerCLI::Options::Validators::DSL::OneOfConstraint }
215
184
 
216
185
  it "raises exception when nothing to check is set" do
217
- e = proc{ cls.new(options, []) }.must_raise RuntimeError
186
+ e = proc{ cls.new(options, option_values, []) }.must_raise RuntimeError
218
187
  e.message.must_equal 'Set at least one expected option'
219
188
  end
220
189
 
221
190
  describe "#exist?" do
222
191
  it "should return true when one of the options exist" do
223
- constraint = cls.new(options, [:option_a, :option_unset_d, :option_unset_e])
224
- constraint.exist?.must_equal true
225
- end
226
-
227
- it "should return true when one of the options exist and is set in the defaults" do
228
- constraint = cls.new(options, [:option_default, :option_unset_d, :option_unset_e])
192
+ constraint = cls.new(options, option_values, [:option_a, :option_unset_d, :option_unset_e])
229
193
  constraint.exist?.must_equal true
230
194
  end
231
195
 
232
196
  it "should return false when the option isn't present" do
233
- constraint = cls.new(options, [:option_unset_d, :option_unset_e])
197
+ constraint = cls.new(options, option_values, [:option_unset_d, :option_unset_e])
234
198
  constraint.exist?.must_equal false
235
199
  end
236
200
 
237
201
  it "should return false when more than one of the options is present" do
238
- constraint = cls.new(options, [:option_a, :option_b])
202
+ constraint = cls.new(options, option_values, [:option_a, :option_b])
239
203
  constraint.exist?.must_equal false
240
204
  end
241
205
  end
242
206
 
243
207
  describe "#rejected" do
244
208
  it "raises not implemented exception" do
245
- constraint = cls.new(options, [:option_a, :option_unset_d])
209
+ constraint = cls.new(options, option_values, [:option_a, :option_unset_d])
246
210
  e = proc{ constraint.rejected }.must_raise NotImplementedError
247
211
  e.message.must_equal '#rejected is unsupported for OneOfConstraint'
248
212
  end
@@ -250,19 +214,19 @@ describe "constraints" do
250
214
 
251
215
  describe "#required" do
252
216
  it "returns nil when one of the options exist" do
253
- constraint = cls.new(options, [:option_a, :option_unset_d, :option_unset_e])
217
+ constraint = cls.new(options, option_values, [:option_a, :option_unset_d, :option_unset_e])
254
218
  constraint.required.must_equal nil
255
219
  end
256
220
 
257
221
  it "raises exception when none of the options is present" do
258
- constraint = cls.new(options, [:option_unset_d, :option_unset_e])
259
- e = proc{ constraint.required }.must_raise HammerCLI::Validator::ValidationError
222
+ constraint = cls.new(options, option_values, [:option_unset_d, :option_unset_e])
223
+ e = proc{ constraint.required }.must_raise HammerCLI::Options::Validators::ValidationError
260
224
  e.message.must_equal 'One of options --option-unset-d, --option-unset-e is required.'
261
225
  end
262
226
 
263
227
  it "raises exception when more than one of the options is present" do
264
- constraint = cls.new(options, [:option_a, :option_b])
265
- e = proc{ constraint.required }.must_raise HammerCLI::Validator::ValidationError
228
+ constraint = cls.new(options, option_values, [:option_a, :option_b])
229
+ e = proc{ constraint.required }.must_raise HammerCLI::Options::Validators::ValidationError
266
230
  e.message.must_equal 'Only one of options --option-a, --option-b can be set.'
267
231
  end
268
232
  end
@@ -59,6 +59,9 @@ describe HammerCLI::Output::Adapter::Abstract do
59
59
  proc { adapter.print_message("MESSAGE %{a}, %{b}", :a => 'A', :b => 'B') }.must_output(/.*MESSAGE A, B.*/, "")
60
60
  end
61
61
 
62
+ it 'should print message with nil params' do
63
+ proc { adapter.print_message('MESSAGE', nil) }.must_output(/.*MESSAGE.*/, '')
64
+ end
62
65
  end
63
66
 
64
67
  it "should raise not implemented on print_collection" do