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.
- 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
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), '
|
1
|
+
require File.join(File.dirname(__FILE__), './test_helper')
|
2
2
|
|
3
3
|
# require 'hammer_cli/options/option_definition'
|
4
4
|
|
@@ -8,17 +8,17 @@ describe HammerCLI::Apipie::OptionDefinition do
|
|
8
8
|
|
9
9
|
describe "referenced resource" do
|
10
10
|
it "should be nil by default" do
|
11
|
-
opt.referenced_resource
|
11
|
+
assert_nil opt.referenced_resource
|
12
12
|
end
|
13
13
|
|
14
14
|
it "should set referenced resource" do
|
15
15
|
@referenced_resource = "organization"
|
16
|
-
opt.referenced_resource.must_equal "organization"
|
16
|
+
_(opt.referenced_resource).must_equal "organization"
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should convert referenced resource name to string" do
|
20
20
|
@referenced_resource = :organization
|
21
|
-
opt.referenced_resource.must_equal "organization"
|
21
|
+
_(opt.referenced_resource).must_equal "organization"
|
22
22
|
end
|
23
23
|
|
24
24
|
end
|
@@ -27,7 +27,7 @@ describe HammerCLI::Apipie::OptionDefinition do
|
|
27
27
|
|
28
28
|
describe "Option Description should be converted" do
|
29
29
|
it "should be converted" do
|
30
|
-
opt2.description.must_equal "'OPT2'"
|
30
|
+
_(opt2.description).must_equal "'OPT2'"
|
31
31
|
end
|
32
32
|
|
33
33
|
end
|
data/test/unit/bash_test.rb
CHANGED
@@ -33,105 +33,105 @@ describe HammerCLI::Bash::Completion do
|
|
33
33
|
|
34
34
|
it 'returns options when no input given' do
|
35
35
|
result = subject.complete('').sort
|
36
|
-
result.must_equal ['host ', '--interactive ', '--help ', '-h '].sort
|
36
|
+
_(result).must_equal ['host ', '--interactive ', '--help ', '-h '].sort
|
37
37
|
end
|
38
38
|
|
39
39
|
it 'returns filtered options when partial input is given' do
|
40
40
|
result = subject.complete('-').sort
|
41
|
-
result.must_equal ['--help ', '-h ', '--interactive '].sort
|
41
|
+
_(result).must_equal ['--help ', '-h ', '--interactive '].sort
|
42
42
|
end
|
43
43
|
|
44
44
|
it 'returns filtered options when partial input is given' do
|
45
45
|
result = subject.complete('host')
|
46
|
-
result.must_equal ['host ']
|
46
|
+
_(result).must_equal ['host ']
|
47
47
|
end
|
48
48
|
|
49
49
|
it 'returns options when subcommand is given' do
|
50
50
|
result = subject.complete('host ').sort
|
51
|
-
result.must_equal ['create ', '--help ', '--dry '].sort
|
51
|
+
_(result).must_equal ['create ', '--help ', '--dry '].sort
|
52
52
|
end
|
53
53
|
|
54
54
|
it 'returns no options when subcommand is wrong' do
|
55
55
|
result = subject.complete('unknown -h')
|
56
|
-
result.must_equal []
|
56
|
+
_(result).must_equal []
|
57
57
|
end
|
58
58
|
|
59
59
|
it 'returns no options when there are no other params allowed' do
|
60
60
|
result = subject.complete('host create /tmp some /tmp extra')
|
61
|
-
result.must_equal []
|
61
|
+
_(result).must_equal []
|
62
62
|
end
|
63
63
|
|
64
64
|
it 'return hint for option-value pair without value' do
|
65
65
|
result = subject.complete('host create -t ')
|
66
|
-
result.must_equal ['--->', 'Add option <value>']
|
66
|
+
_(result).must_equal ['--->', 'Add option <value>']
|
67
67
|
end
|
68
68
|
|
69
69
|
it 'return no options for option-value pair without complete value' do
|
70
70
|
result = subject.complete('host create -t x')
|
71
|
-
result.must_equal []
|
71
|
+
_(result).must_equal []
|
72
72
|
end
|
73
73
|
|
74
74
|
# multiple options in one subcommand
|
75
75
|
it 'allows mutiple options of the same subcommand' do
|
76
76
|
result = subject.complete('host create --build --he')
|
77
|
-
result.must_equal ['--help ']
|
77
|
+
_(result).must_equal ['--help ']
|
78
78
|
end
|
79
79
|
|
80
80
|
# multiple options with values in one subcommand
|
81
81
|
it 'allows mutiple options with values of the same subcommand' do
|
82
82
|
result = subject.complete('host create -t value --he')
|
83
|
-
result.must_equal ['--help ']
|
83
|
+
_(result).must_equal ['--help ']
|
84
84
|
end
|
85
85
|
|
86
86
|
# subcommand after options
|
87
87
|
it 'allows subcommand after options' do
|
88
88
|
result = subject.complete('host --dry crea')
|
89
|
-
result.must_equal ['create ']
|
89
|
+
_(result).must_equal ['create ']
|
90
90
|
end
|
91
91
|
|
92
92
|
describe 'completion by type' do
|
93
93
|
it 'completes :value' do
|
94
94
|
result = subject.complete('host create -t ')
|
95
|
-
result.must_equal ['--->', 'Add option <value>']
|
95
|
+
_(result).must_equal ['--->', 'Add option <value>']
|
96
96
|
end
|
97
97
|
|
98
98
|
it 'completes :flag' do
|
99
99
|
result = subject.complete('host --h')
|
100
|
-
result.must_equal ['--help ']
|
100
|
+
_(result).must_equal ['--help ']
|
101
101
|
end
|
102
102
|
|
103
103
|
it 'completes :schema' do
|
104
104
|
result = subject.complete('host create --installed-products-attributes ')
|
105
|
-
result.must_equal ["--->", 'Add value by following schema: "product_id=string\,product_name=string\,arch=string\,version=string, ... "']
|
105
|
+
_(result).must_equal ["--->", 'Add value by following schema: "product_id=string\,product_name=string\,arch=string\,version=string, ... "']
|
106
106
|
end
|
107
107
|
|
108
108
|
it 'completes :enum' do
|
109
109
|
result = subject.complete('host create --managed ')
|
110
|
-
result.must_equal ['yes ', 'no ']
|
110
|
+
_(result).must_equal ['yes ', 'no ']
|
111
111
|
end
|
112
112
|
|
113
113
|
it 'completes :multienum' do
|
114
114
|
result = subject.complete('host create --volume ')
|
115
|
-
result.must_equal ['first', 'second', 'third']
|
115
|
+
_(result).must_equal ['first', 'second', 'third']
|
116
116
|
|
117
117
|
result = subject.complete('host create --volume fir')
|
118
|
-
result.must_equal ['first']
|
118
|
+
_(result).must_equal ['first']
|
119
119
|
|
120
120
|
result = subject.complete('host create --volume first,')
|
121
|
-
result.must_equal ['second', 'third']
|
121
|
+
_(result).must_equal ['second', 'third']
|
122
122
|
|
123
123
|
result = subject.complete('host create --volume first,se')
|
124
|
-
result.must_equal ['first,second']
|
124
|
+
_(result).must_equal ['first,second']
|
125
125
|
end
|
126
126
|
|
127
127
|
it 'completes :list' do
|
128
128
|
result = subject.complete('host create --config-group-ids ')
|
129
|
-
result.must_equal ['--->', 'Add comma-separated list of values']
|
129
|
+
_(result).must_equal ['--->', 'Add comma-separated list of values']
|
130
130
|
end
|
131
131
|
|
132
132
|
it 'completes :key_value_list' do
|
133
133
|
result = subject.complete('host create --params ')
|
134
|
-
result.must_equal ['--->', 'Add comma-separated list of key=value']
|
134
|
+
_(result).must_equal ['--->', 'Add comma-separated list of key=value']
|
135
135
|
end
|
136
136
|
end
|
137
137
|
end
|
@@ -57,68 +57,68 @@ describe HammerCLI::CommandExtensions do
|
|
57
57
|
it 'should extend options only' do
|
58
58
|
cmd.extend_with(CmdExtensions.new(only: :option))
|
59
59
|
opt = cmd.find_option('--ext')
|
60
|
-
opt.is_a?(HammerCLI::Options::OptionDefinition).must_equal true
|
61
|
-
cmd.output_definition.empty
|
60
|
+
_(opt.is_a?(HammerCLI::Options::OptionDefinition)).must_equal true
|
61
|
+
_(cmd.output_definition.empty?).must_equal true
|
62
62
|
end
|
63
63
|
|
64
64
|
it 'should extend output only' do
|
65
65
|
cmd.extend_with(CmdExtensions.new(only: :output))
|
66
|
-
cmd.output_definition.empty
|
66
|
+
_(cmd.output_definition.empty?).must_equal false
|
67
67
|
opt = cmd.find_option('--ext')
|
68
|
-
opt.is_a?(HammerCLI::Options::OptionDefinition).must_equal false
|
68
|
+
_(opt.is_a?(HammerCLI::Options::OptionDefinition)).must_equal false
|
69
69
|
end
|
70
70
|
|
71
71
|
it 'should extend help only' do
|
72
72
|
cmd.extend_with(CmdExtensions.new(only: :help))
|
73
|
-
cmd.new('', {}).help.must_match(/.*Section.*/)
|
74
|
-
cmd.new('', {}).help.must_match(/.*text.*/)
|
73
|
+
_(cmd.new('', {}).help).must_match(/.*Section.*/)
|
74
|
+
_(cmd.new('', {}).help).must_match(/.*text.*/)
|
75
75
|
end
|
76
76
|
|
77
77
|
it 'should extend params only' do
|
78
78
|
cmd.extend_with(CmdExtensions.new(only: :request_params))
|
79
|
-
cmd.new('', {}).extended_request[0].must_equal(thin: true)
|
80
|
-
cmd.new('', {}).extended_request[1].must_equal({})
|
81
|
-
cmd.new('', {}).extended_request[2].must_equal({})
|
79
|
+
_(cmd.new('', {}).extended_request[0]).must_equal(thin: true)
|
80
|
+
_(cmd.new('', {}).extended_request[1]).must_equal({})
|
81
|
+
_(cmd.new('', {}).extended_request[2]).must_equal({})
|
82
82
|
end
|
83
83
|
|
84
84
|
it 'should extend headers only' do
|
85
85
|
cmd.extend_with(CmdExtensions.new(only: :request_headers))
|
86
|
-
cmd.new('', {}).extended_request[0].must_equal({})
|
87
|
-
cmd.new('', {}).extended_request[1].must_equal(ssl: true)
|
88
|
-
cmd.new('', {}).extended_request[2].must_equal({})
|
86
|
+
_(cmd.new('', {}).extended_request[0]).must_equal({})
|
87
|
+
_(cmd.new('', {}).extended_request[1]).must_equal(ssl: true)
|
88
|
+
_(cmd.new('', {}).extended_request[2]).must_equal({})
|
89
89
|
end
|
90
90
|
|
91
91
|
it 'should extend options only' do
|
92
92
|
cmd.extend_with(CmdExtensions.new(only: :request_options))
|
93
|
-
cmd.new('', {}).extended_request[0].must_equal({})
|
94
|
-
cmd.new('', {}).extended_request[1].must_equal({})
|
95
|
-
cmd.new('', {}).extended_request[2].must_equal(with_authentication: true)
|
93
|
+
_(cmd.new('', {}).extended_request[0]).must_equal({})
|
94
|
+
_(cmd.new('', {}).extended_request[1]).must_equal({})
|
95
|
+
_(cmd.new('', {}).extended_request[2]).must_equal(with_authentication: true)
|
96
96
|
end
|
97
97
|
|
98
98
|
it 'should extend params and options and headers' do
|
99
99
|
cmd.extend_with(CmdExtensions.new(only: :request))
|
100
|
-
cmd.new('', {}).extended_request[0].must_equal(thin: true)
|
101
|
-
cmd.new('', {}).extended_request[1].must_equal(ssl: true)
|
102
|
-
cmd.new('', {}).extended_request[2].must_equal(with_authentication: true)
|
100
|
+
_(cmd.new('', {}).extended_request[0]).must_equal(thin: true)
|
101
|
+
_(cmd.new('', {}).extended_request[1]).must_equal(ssl: true)
|
102
|
+
_(cmd.new('', {}).extended_request[2]).must_equal(with_authentication: true)
|
103
103
|
end
|
104
104
|
|
105
105
|
it 'should extend data only' do
|
106
106
|
cmd.extend_with(CmdExtensions.new(only: :data))
|
107
|
-
cmd.new('', {}).help.wont_match(/.*Section.*/)
|
108
|
-
cmd.new('', {}).help.wont_match(/.*text.*/)
|
109
|
-
cmd.output_definition.empty
|
107
|
+
_(cmd.new('', {}).help).wont_match(/.*Section.*/)
|
108
|
+
_(cmd.new('', {}).help).wont_match(/.*text.*/)
|
109
|
+
_(cmd.output_definition.empty?).must_equal true
|
110
110
|
opt = cmd.find_option('--ext')
|
111
|
-
opt.is_a?(HammerCLI::Options::OptionDefinition).must_equal false
|
112
|
-
cmd.new('', {}).extended_request[0].must_equal({})
|
113
|
-
cmd.new('', {}).extended_request[1].must_equal({})
|
114
|
-
cmd.new('', {}).extended_request[2].must_equal({})
|
115
|
-
cmd.new('', {}).extended_data({}).must_equal('key' => 'value')
|
111
|
+
_(opt.is_a?(HammerCLI::Options::OptionDefinition)).must_equal false
|
112
|
+
_(cmd.new('', {}).extended_request[0]).must_equal({})
|
113
|
+
_(cmd.new('', {}).extended_request[1]).must_equal({})
|
114
|
+
_(cmd.new('', {}).extended_request[2]).must_equal({})
|
115
|
+
_(cmd.new('', {}).extended_data({})).must_equal('key' => 'value')
|
116
116
|
end
|
117
117
|
|
118
118
|
it 'should extend option family only' do
|
119
119
|
cmd.extend_with(CmdExtensions.new(only: :option_family))
|
120
|
-
cmd.output_definition.empty
|
121
|
-
cmd.recognised_options.map(&:switches).flatten.must_equal ['-h', '--help', '--test-one', '--test-two']
|
120
|
+
_(cmd.output_definition.empty?).must_equal true
|
121
|
+
_(cmd.recognised_options.map(&:switches).flatten).must_equal ['-h', '--help', '--test-one', '--test-two']
|
122
122
|
end
|
123
123
|
end
|
124
124
|
|
@@ -126,80 +126,80 @@ describe HammerCLI::CommandExtensions do
|
|
126
126
|
it 'should extend all except options' do
|
127
127
|
cmd.extend_with(CmdExtensions.new(except: :option))
|
128
128
|
opt = cmd.find_option('--ext')
|
129
|
-
opt.is_a?(HammerCLI::Options::OptionDefinition).must_equal false
|
130
|
-
cmd.output_definition.empty
|
131
|
-
cmd.new('', {}).extended_request[0].must_equal(thin: true)
|
132
|
-
cmd.new('', {}).extended_request[1].must_equal(ssl: true)
|
133
|
-
cmd.new('', {}).extended_request[2].must_equal(with_authentication: true)
|
129
|
+
_(opt.is_a?(HammerCLI::Options::OptionDefinition)).must_equal false
|
130
|
+
_(cmd.output_definition.empty?).must_equal false
|
131
|
+
_(cmd.new('', {}).extended_request[0]).must_equal(thin: true)
|
132
|
+
_(cmd.new('', {}).extended_request[1]).must_equal(ssl: true)
|
133
|
+
_(cmd.new('', {}).extended_request[2]).must_equal(with_authentication: true)
|
134
134
|
end
|
135
135
|
|
136
136
|
it 'should extend all except output' do
|
137
137
|
cmd.extend_with(CmdExtensions.new(except: :output))
|
138
|
-
cmd.output_definition.empty
|
138
|
+
_(cmd.output_definition.empty?).must_equal true
|
139
139
|
opt = cmd.find_option('--ext')
|
140
|
-
opt.is_a?(HammerCLI::Options::OptionDefinition).must_equal true
|
141
|
-
cmd.new('', {}).extended_request[0].must_equal(thin: true)
|
142
|
-
cmd.new('', {}).extended_request[1].must_equal(ssl: true)
|
143
|
-
cmd.new('', {}).extended_request[2].must_equal(with_authentication: true)
|
140
|
+
_(opt.is_a?(HammerCLI::Options::OptionDefinition)).must_equal true
|
141
|
+
_(cmd.new('', {}).extended_request[0]).must_equal(thin: true)
|
142
|
+
_(cmd.new('', {}).extended_request[1]).must_equal(ssl: true)
|
143
|
+
_(cmd.new('', {}).extended_request[2]).must_equal(with_authentication: true)
|
144
144
|
end
|
145
145
|
|
146
146
|
it 'should extend all except help' do
|
147
147
|
cmd.extend_with(CmdExtensions.new(except: :help))
|
148
|
-
cmd.new('', {}).help.wont_match(/.*Section.*/)
|
149
|
-
cmd.new('', {}).help.wont_match(/.*text.*/)
|
150
|
-
cmd.output_definition.empty
|
148
|
+
_(cmd.new('', {}).help).wont_match(/.*Section.*/)
|
149
|
+
_(cmd.new('', {}).help).wont_match(/.*text.*/)
|
150
|
+
_(cmd.output_definition.empty?).must_equal false
|
151
151
|
opt = cmd.find_option('--ext')
|
152
|
-
opt.is_a?(HammerCLI::Options::OptionDefinition).must_equal true
|
153
|
-
cmd.new('', {}).extended_request[0].must_equal(thin: true)
|
154
|
-
cmd.new('', {}).extended_request[1].must_equal(ssl: true)
|
155
|
-
cmd.new('', {}).extended_request[2].must_equal(with_authentication: true)
|
152
|
+
_(opt.is_a?(HammerCLI::Options::OptionDefinition)).must_equal true
|
153
|
+
_(cmd.new('', {}).extended_request[0]).must_equal(thin: true)
|
154
|
+
_(cmd.new('', {}).extended_request[1]).must_equal(ssl: true)
|
155
|
+
_(cmd.new('', {}).extended_request[2]).must_equal(with_authentication: true)
|
156
156
|
end
|
157
157
|
|
158
158
|
it 'should extend all except params' do
|
159
159
|
cmd.extend_with(CmdExtensions.new(except: :request_params))
|
160
|
-
cmd.new('', {}).extended_request[0].must_equal({})
|
161
|
-
cmd.new('', {}).extended_request[1].must_equal(ssl: true)
|
162
|
-
cmd.new('', {}).extended_request[2].must_equal(with_authentication: true)
|
160
|
+
_(cmd.new('', {}).extended_request[0]).must_equal({})
|
161
|
+
_(cmd.new('', {}).extended_request[1]).must_equal(ssl: true)
|
162
|
+
_(cmd.new('', {}).extended_request[2]).must_equal(with_authentication: true)
|
163
163
|
end
|
164
164
|
|
165
165
|
it 'should extend all except headers' do
|
166
166
|
cmd.extend_with(CmdExtensions.new(except: :request_headers))
|
167
|
-
cmd.new('', {}).extended_request[0].must_equal(thin: true)
|
168
|
-
cmd.new('', {}).extended_request[1].must_equal({})
|
169
|
-
cmd.new('', {}).extended_request[2].must_equal(with_authentication: true)
|
167
|
+
_(cmd.new('', {}).extended_request[0]).must_equal(thin: true)
|
168
|
+
_(cmd.new('', {}).extended_request[1]).must_equal({})
|
169
|
+
_(cmd.new('', {}).extended_request[2]).must_equal(with_authentication: true)
|
170
170
|
end
|
171
171
|
|
172
172
|
it 'should extend all except options' do
|
173
173
|
cmd.extend_with(CmdExtensions.new(except: :request_options))
|
174
|
-
cmd.new('', {}).extended_request[0].must_equal(thin: true)
|
175
|
-
cmd.new('', {}).extended_request[1].must_equal(ssl: true)
|
176
|
-
cmd.new('', {}).extended_request[2].must_equal({})
|
174
|
+
_(cmd.new('', {}).extended_request[0]).must_equal(thin: true)
|
175
|
+
_(cmd.new('', {}).extended_request[1]).must_equal(ssl: true)
|
176
|
+
_(cmd.new('', {}).extended_request[2]).must_equal({})
|
177
177
|
end
|
178
178
|
|
179
179
|
it 'should extend all except params and options and headers' do
|
180
180
|
cmd.extend_with(CmdExtensions.new(except: :request))
|
181
|
-
cmd.new('', {}).extended_request[0].must_equal({})
|
182
|
-
cmd.new('', {}).extended_request[1].must_equal({})
|
183
|
-
cmd.new('', {}).extended_request[2].must_equal({})
|
181
|
+
_(cmd.new('', {}).extended_request[0]).must_equal({})
|
182
|
+
_(cmd.new('', {}).extended_request[1]).must_equal({})
|
183
|
+
_(cmd.new('', {}).extended_request[2]).must_equal({})
|
184
184
|
end
|
185
185
|
|
186
186
|
it 'should extend all except data' do
|
187
187
|
cmd.extend_with(CmdExtensions.new(except: :data))
|
188
|
-
cmd.new('', {}).help.must_match(/.*Section.*/)
|
189
|
-
cmd.new('', {}).help.must_match(/.*text.*/)
|
190
|
-
cmd.output_definition.empty
|
188
|
+
_(cmd.new('', {}).help).must_match(/.*Section.*/)
|
189
|
+
_(cmd.new('', {}).help).must_match(/.*text.*/)
|
190
|
+
_(cmd.output_definition.empty?).must_equal false
|
191
191
|
opt = cmd.find_option('--ext')
|
192
|
-
opt.is_a?(HammerCLI::Options::OptionDefinition).must_equal true
|
193
|
-
cmd.new('', {}).extended_request[0].must_equal(thin: true)
|
194
|
-
cmd.new('', {}).extended_request[1].must_equal(ssl: true)
|
195
|
-
cmd.new('', {}).extended_request[2].must_equal(with_authentication: true)
|
196
|
-
cmd.new('', {}).extended_data({}).must_equal({})
|
192
|
+
_(opt.is_a?(HammerCLI::Options::OptionDefinition)).must_equal true
|
193
|
+
_(cmd.new('', {}).extended_request[0]).must_equal(thin: true)
|
194
|
+
_(cmd.new('', {}).extended_request[1]).must_equal(ssl: true)
|
195
|
+
_(cmd.new('', {}).extended_request[2]).must_equal(with_authentication: true)
|
196
|
+
_(cmd.new('', {}).extended_data({})).must_equal({})
|
197
197
|
end
|
198
198
|
|
199
199
|
it 'should extend all except option family' do
|
200
200
|
cmd.extend_with(CmdExtensions.new(except: :option_family))
|
201
|
-
cmd.output_definition.empty
|
202
|
-
cmd.recognised_options.map(&:switches).flatten.must_equal ['--ext', '-h', '--help']
|
201
|
+
_(cmd.output_definition.empty?).must_equal false
|
202
|
+
_(cmd.recognised_options.map(&:switches).flatten).must_equal ['--ext', '-h', '--help']
|
203
203
|
end
|
204
204
|
end
|
205
205
|
|
@@ -209,7 +209,7 @@ describe HammerCLI::CommandExtensions do
|
|
209
209
|
cmd.option_family associate: 'test' do
|
210
210
|
child '--test-three', '', ''
|
211
211
|
end
|
212
|
-
cmd.recognised_options.map(&:switches).flatten.must_equal ['-h', '--help', '--test-one', '--test-two', '--test-three']
|
212
|
+
_(cmd.recognised_options.map(&:switches).flatten).must_equal ['-h', '--help', '--test-one', '--test-two', '--test-three']
|
213
213
|
end
|
214
214
|
end
|
215
215
|
end
|