ronin-core 0.1.0.beta1 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +1 -0
  3. data/.rubocop.yml +13 -150
  4. data/.yardopts +1 -1
  5. data/ChangeLog.md +9 -1
  6. data/Gemfile +3 -1
  7. data/README.md +2 -1
  8. data/Rakefile +1 -1
  9. data/examples/ruby_shell.rb +5 -0
  10. data/examples/test_shell.rb +41 -0
  11. data/gemspec.yml +1 -1
  12. data/lib/ronin/core/class_registry.rb +18 -13
  13. data/lib/ronin/core/cli/command.rb +12 -12
  14. data/lib/ronin/core/cli/command_shell/command.rb +9 -6
  15. data/lib/ronin/core/cli/command_shell.rb +11 -11
  16. data/lib/ronin/core/cli/generator/options/author.rb +5 -6
  17. data/lib/ronin/core/cli/generator/options/description.rb +3 -3
  18. data/lib/ronin/core/cli/generator/options/reference.rb +3 -3
  19. data/lib/ronin/core/cli/generator/options/summary.rb +3 -3
  20. data/lib/ronin/core/cli/generator.rb +11 -8
  21. data/lib/ronin/core/cli/logging.rb +6 -3
  22. data/lib/ronin/core/cli/options/param.rb +5 -5
  23. data/lib/ronin/core/cli/options/values/arches.rb +3 -3
  24. data/lib/ronin/core/cli/options/values/oses.rb +3 -3
  25. data/lib/ronin/core/cli/printing/arch.rb +3 -3
  26. data/lib/ronin/core/cli/printing/metadata.rb +4 -4
  27. data/lib/ronin/core/cli/printing/os.rb +6 -3
  28. data/lib/ronin/core/cli/printing/params.rb +7 -7
  29. data/lib/ronin/core/cli/ruby_shell.rb +4 -3
  30. data/lib/ronin/core/cli/shell.rb +16 -8
  31. data/lib/ronin/core/git.rb +3 -3
  32. data/lib/ronin/core/home.rb +3 -3
  33. data/lib/ronin/core/metadata/authors/author.rb +6 -3
  34. data/lib/ronin/core/metadata/authors.rb +9 -6
  35. data/lib/ronin/core/metadata/description.rb +9 -6
  36. data/lib/ronin/core/metadata/id.rb +8 -5
  37. data/lib/ronin/core/metadata/references.rb +14 -7
  38. data/lib/ronin/core/metadata/summary.rb +11 -8
  39. data/lib/ronin/core/metadata/version.rb +9 -6
  40. data/lib/ronin/core/params/exceptions.rb +3 -3
  41. data/lib/ronin/core/params/mixin.rb +17 -17
  42. data/lib/ronin/core/params/param.rb +4 -4
  43. data/lib/ronin/core/params/types/boolean.rb +3 -3
  44. data/lib/ronin/core/params/types/enum.rb +8 -4
  45. data/lib/ronin/core/params/types/float.rb +3 -3
  46. data/lib/ronin/core/params/types/integer.rb +3 -3
  47. data/lib/ronin/core/params/types/numeric.rb +4 -4
  48. data/lib/ronin/core/params/types/regexp.rb +3 -3
  49. data/lib/ronin/core/params/types/string.rb +3 -3
  50. data/lib/ronin/core/params/types/type.rb +3 -3
  51. data/lib/ronin/core/params/types/uri.rb +3 -3
  52. data/lib/ronin/core/params/types.rb +7 -4
  53. data/lib/ronin/core/params.rb +3 -3
  54. data/lib/ronin/core/version.rb +4 -4
  55. data/ronin-core.gemspec +7 -4
  56. metadata +5 -90
  57. data/spec/class_registry_spec.rb +0 -224
  58. data/spec/cli/command_shell/command_spec.rb +0 -113
  59. data/spec/cli/command_shell_spec.rb +0 -1114
  60. data/spec/cli/command_spec.rb +0 -16
  61. data/spec/cli/fixtures/irb_command +0 -8
  62. data/spec/cli/fixtures/template/dir/file1.txt +0 -1
  63. data/spec/cli/fixtures/template/dir/file2.txt +0 -1
  64. data/spec/cli/fixtures/template/file.erb +0 -1
  65. data/spec/cli/fixtures/template/file.txt +0 -1
  66. data/spec/cli/generator/options/author_spec.rb +0 -121
  67. data/spec/cli/generator/options/description_spec.rb +0 -45
  68. data/spec/cli/generator/options/reference_spec.rb +0 -53
  69. data/spec/cli/generator/options/summary_spec.rb +0 -45
  70. data/spec/cli/generator_spec.rb +0 -244
  71. data/spec/cli/logging_spec.rb +0 -95
  72. data/spec/cli/options/param_spec.rb +0 -67
  73. data/spec/cli/options/values/arches_spec.rb +0 -62
  74. data/spec/cli/printing/arch_spec.rb +0 -130
  75. data/spec/cli/printing/metadata_spec.rb +0 -211
  76. data/spec/cli/printing/os_spec.rb +0 -64
  77. data/spec/cli/printing/params_spec.rb +0 -63
  78. data/spec/cli/ruby_shell.rb +0 -99
  79. data/spec/cli/shell_spec.rb +0 -211
  80. data/spec/fixtures/example_class_registry/base_class.rb +0 -9
  81. data/spec/fixtures/example_class_registry/classes/loaded_class.rb +0 -9
  82. data/spec/fixtures/example_class_registry/classes/name_mismatch.rb +0 -9
  83. data/spec/fixtures/example_class_registry/classes/no_module.rb +0 -4
  84. data/spec/fixtures/example_class_registry.rb +0 -8
  85. data/spec/git_spec.rb +0 -58
  86. data/spec/home_spec.rb +0 -64
  87. data/spec/metadata/authors/author_spec.rb +0 -335
  88. data/spec/metadata/authors_spec.rb +0 -126
  89. data/spec/metadata/description_spec.rb +0 -74
  90. data/spec/metadata/id_spec.rb +0 -92
  91. data/spec/metadata/references_spec.rb +0 -100
  92. data/spec/metadata/summary_spec.rb +0 -74
  93. data/spec/metadata/version_spec.rb +0 -72
  94. data/spec/params/mixin_spec.rb +0 -484
  95. data/spec/params/param_spec.rb +0 -164
  96. data/spec/params/types/boolean_spec.rb +0 -56
  97. data/spec/params/types/enum_spec.rb +0 -94
  98. data/spec/params/types/float_spec.rb +0 -107
  99. data/spec/params/types/integer_spec.rb +0 -155
  100. data/spec/params/types/numeric_spec.rb +0 -138
  101. data/spec/params/types/regexp_spec.rb +0 -64
  102. data/spec/params/types/string_spec.rb +0 -174
  103. data/spec/params/types/type_spec.rb +0 -14
  104. data/spec/params/types/uri_spec.rb +0 -62
  105. data/spec/spec_helper.rb +0 -11
@@ -1,17 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
  #
3
- # Copyright (c) 2021-2022 Hal Brodigan (postmodern.mod3 at gmail.com)
3
+ # Copyright (c) 2021-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
4
4
  #
5
5
  # ronin-core is free software: you can redistribute it and/or modify
6
6
  # it under the terms of the GNU Lesser General Public License as published
7
7
  # by the Free Software Foundation, either version 3 of the License, or
8
8
  # (at your option) any later version.
9
- #
9
+ #
10
10
  # ronin-core is distributed in the hope that it will be useful,
11
11
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
12
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
13
  # GNU Lesser General Public License for more details.
14
- #
14
+ #
15
15
  # You should have received a copy of the GNU Lesser General Public License
16
16
  # along with ronin-core. If not, see <https://www.gnu.org/licenses/>.
17
17
  #
@@ -19,6 +19,6 @@
19
19
  module Ronin
20
20
  module Core
21
21
  # ronin-core version
22
- VERSION = '0.1.0.beta1'
22
+ VERSION = '0.1.1'
23
23
  end
24
24
  end
data/ronin-core.gemspec CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'yaml'
2
4
 
3
5
  Gem::Specification.new do |gem|
@@ -20,18 +22,19 @@ Gem::Specification.new do |gem|
20
22
  gem.homepage = gemspec['homepage']
21
23
  gem.metadata = gemspec['metadata'] if gemspec['metadata']
22
24
 
23
- glob = lambda { |patterns| gem.files & Dir[*patterns] }
25
+ glob = ->(patterns) { gem.files & Dir[*patterns] }
24
26
 
25
27
  gem.files = `git ls-files`.split($/)
26
- gem.files = glob[gemspec['files']] if gemspec['files']
28
+ gem.files = glob[gemspec['files']] if gemspec['files']
27
29
  gem.files += Array(gemspec['generated_files'])
30
+ # exclude test files from the packages gem
31
+ gem.files -= glob[gemspec['test_files'] || 'spec/{**/}*']
28
32
 
29
33
  gem.executables = gemspec.fetch('executables') do
30
34
  glob['bin/*'].map { |path| File.basename(path) }
31
35
  end
32
36
 
33
37
  gem.extensions = glob[gemspec['extensions'] || 'ext/**/extconf.rb']
34
- gem.test_files = glob[gemspec['test_files'] || 'spec/{**/}*_spec.rb']
35
38
  gem.extra_rdoc_files = glob[gemspec['extra_doc_files'] || '*.{txt,md}']
36
39
 
37
40
  gem.require_paths = Array(gemspec.fetch('require_paths') {
@@ -43,7 +46,7 @@ Gem::Specification.new do |gem|
43
46
  gem.required_rubygems_version = gemspec['required_rubygems_version']
44
47
  gem.post_install_message = gemspec['post_install_message']
45
48
 
46
- split = lambda { |string| string.split(/,\s*/) }
49
+ split = ->(string) { string.split(/,\s*/) }
47
50
 
48
51
  if gemspec['dependencies']
49
52
  gemspec['dependencies'].each do |name,versions|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ronin-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.beta1
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Postmodern
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-01 00:00:00.000000000 Z
11
+ date: 2023-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: reline
@@ -90,6 +90,7 @@ files:
90
90
  - README.md
91
91
  - Rakefile
92
92
  - examples/ruby_shell.rb
93
+ - examples/test_shell.rb
93
94
  - gemspec.yml
94
95
  - lib/ronin/core/class_registry.rb
95
96
  - lib/ronin/core/cli/command.rb
@@ -135,60 +136,11 @@ files:
135
136
  - lib/ronin/core/params/types/uri.rb
136
137
  - lib/ronin/core/version.rb
137
138
  - ronin-core.gemspec
138
- - spec/class_registry_spec.rb
139
- - spec/cli/command_shell/command_spec.rb
140
- - spec/cli/command_shell_spec.rb
141
- - spec/cli/command_spec.rb
142
- - spec/cli/fixtures/irb_command
143
- - spec/cli/fixtures/template/dir/file1.txt
144
- - spec/cli/fixtures/template/dir/file2.txt
145
- - spec/cli/fixtures/template/file.erb
146
- - spec/cli/fixtures/template/file.txt
147
- - spec/cli/generator/options/author_spec.rb
148
- - spec/cli/generator/options/description_spec.rb
149
- - spec/cli/generator/options/reference_spec.rb
150
- - spec/cli/generator/options/summary_spec.rb
151
- - spec/cli/generator_spec.rb
152
- - spec/cli/logging_spec.rb
153
- - spec/cli/options/param_spec.rb
154
- - spec/cli/options/values/arches_spec.rb
155
- - spec/cli/printing/arch_spec.rb
156
- - spec/cli/printing/metadata_spec.rb
157
- - spec/cli/printing/os_spec.rb
158
- - spec/cli/printing/params_spec.rb
159
- - spec/cli/ruby_shell.rb
160
- - spec/cli/shell_spec.rb
161
- - spec/fixtures/example_class_registry.rb
162
- - spec/fixtures/example_class_registry/base_class.rb
163
- - spec/fixtures/example_class_registry/classes/loaded_class.rb
164
- - spec/fixtures/example_class_registry/classes/name_mismatch.rb
165
- - spec/fixtures/example_class_registry/classes/no_module.rb
166
- - spec/git_spec.rb
167
- - spec/home_spec.rb
168
- - spec/metadata/authors/author_spec.rb
169
- - spec/metadata/authors_spec.rb
170
- - spec/metadata/description_spec.rb
171
- - spec/metadata/id_spec.rb
172
- - spec/metadata/references_spec.rb
173
- - spec/metadata/summary_spec.rb
174
- - spec/metadata/version_spec.rb
175
- - spec/params/mixin_spec.rb
176
- - spec/params/param_spec.rb
177
- - spec/params/types/boolean_spec.rb
178
- - spec/params/types/enum_spec.rb
179
- - spec/params/types/float_spec.rb
180
- - spec/params/types/integer_spec.rb
181
- - spec/params/types/numeric_spec.rb
182
- - spec/params/types/regexp_spec.rb
183
- - spec/params/types/string_spec.rb
184
- - spec/params/types/type_spec.rb
185
- - spec/params/types/uri_spec.rb
186
- - spec/spec_helper.rb
187
139
  homepage: https://ronin-rb.dev/
188
140
  licenses:
189
141
  - LGPL-3.0
190
142
  metadata:
191
- documentation_uri: https://rubydoc.info/gems/ronin-core
143
+ documentation_uri: https://ronin-rb.dev/docs/ronin-core
192
144
  source_code_uri: https://github.com/ronin-rb/ronin-core
193
145
  bug_tracker_uri: https://github.com/ronin-rb/ronin-core/issues
194
146
  changelog_uri: https://github.com/ronin-rb/ronin-core/blob/main/ChangeLog.md
@@ -212,41 +164,4 @@ rubygems_version: 3.3.26
212
164
  signing_key:
213
165
  specification_version: 4
214
166
  summary: A core library for all ronin libraries.
215
- test_files:
216
- - spec/class_registry_spec.rb
217
- - spec/cli/command_shell/command_spec.rb
218
- - spec/cli/command_shell_spec.rb
219
- - spec/cli/command_spec.rb
220
- - spec/cli/generator/options/author_spec.rb
221
- - spec/cli/generator/options/description_spec.rb
222
- - spec/cli/generator/options/reference_spec.rb
223
- - spec/cli/generator/options/summary_spec.rb
224
- - spec/cli/generator_spec.rb
225
- - spec/cli/logging_spec.rb
226
- - spec/cli/options/param_spec.rb
227
- - spec/cli/options/values/arches_spec.rb
228
- - spec/cli/printing/arch_spec.rb
229
- - spec/cli/printing/metadata_spec.rb
230
- - spec/cli/printing/os_spec.rb
231
- - spec/cli/printing/params_spec.rb
232
- - spec/cli/shell_spec.rb
233
- - spec/git_spec.rb
234
- - spec/home_spec.rb
235
- - spec/metadata/authors/author_spec.rb
236
- - spec/metadata/authors_spec.rb
237
- - spec/metadata/description_spec.rb
238
- - spec/metadata/id_spec.rb
239
- - spec/metadata/references_spec.rb
240
- - spec/metadata/summary_spec.rb
241
- - spec/metadata/version_spec.rb
242
- - spec/params/mixin_spec.rb
243
- - spec/params/param_spec.rb
244
- - spec/params/types/boolean_spec.rb
245
- - spec/params/types/enum_spec.rb
246
- - spec/params/types/float_spec.rb
247
- - spec/params/types/integer_spec.rb
248
- - spec/params/types/numeric_spec.rb
249
- - spec/params/types/regexp_spec.rb
250
- - spec/params/types/string_spec.rb
251
- - spec/params/types/type_spec.rb
252
- - spec/params/types/uri_spec.rb
167
+ test_files: []
@@ -1,224 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/core/class_registry'
3
-
4
- require 'fixtures/example_class_registry'
5
-
6
- describe Ronin::Core::ClassRegistry do
7
- let(:fixtures_dir) { File.join(__dir__,'fixtures') }
8
-
9
- describe ".class_dir" do
10
- context "when a class_dir has been defined" do
11
- module TestClassRegistry
12
- module WithAModulesDir
13
- include Ronin::Core::ClassRegistry
14
-
15
- class_dir "#{__dir__}/test/dir"
16
- end
17
- end
18
-
19
- subject { TestClassRegistry::WithAModulesDir }
20
-
21
- it "must return the previously set .class_dir" do
22
- expect(subject.class_dir).to eq("#{__dir__}/test/dir")
23
- end
24
- end
25
-
26
- context "but when no class_dir has been defined" do
27
- module TestClassRegistry
28
- module WithNoModuleLoadPath
29
- include Ronin::Core::ClassRegistry
30
- end
31
- end
32
-
33
- subject { TestClassRegistry::WithNoModuleLoadPath }
34
-
35
- it do
36
- expect {
37
- subject.class_dir
38
- }.to raise_error(NotImplementedError,"#{subject} did not define a class_dir")
39
- end
40
- end
41
- end
42
-
43
- subject { ExampleClassRegistry }
44
-
45
- describe ".list_files" do
46
- it "must return an Array of module names" do
47
- expect(subject.list_files).to eq(
48
- %w[
49
- loaded_class
50
- name_mismatch
51
- no_module
52
- ]
53
- )
54
- end
55
- end
56
-
57
- describe ".registry" do
58
- it "must default to {}" do
59
- expect(subject.registry).to eq({})
60
- end
61
- end
62
-
63
- describe ".path_for" do
64
- context "when the module name exists within the .class_dir" do
65
- let(:id) { 'loaded_class' }
66
-
67
- it "must return the path to the .rb file for the module" do
68
- expect(subject.path_for(id)).to eq(
69
- File.join(subject.class_dir,"#{id}.rb")
70
- )
71
- end
72
- end
73
-
74
- context "when the module name does not have a file within .class_dir" do
75
- let(:id) { "does_not_exist" }
76
-
77
- it "must return nil" do
78
- expect(subject.path_for(id)).to be(nil)
79
- end
80
- end
81
- end
82
-
83
- describe ".register" do
84
- module TestClassRegistry
85
- module ExampleNamespace
86
- class Foo
87
- end
88
- end
89
- end
90
-
91
- let(:id) { 'foo' }
92
- let(:klass) { TestClassRegistry::ExampleNamespace::Foo }
93
-
94
- before { subject.register(id,klass) }
95
-
96
- it "must add the class id and class to #registry" do
97
- expect(subject.registry[id]).to be(klass)
98
- end
99
-
100
- after { subject.registry.clear }
101
- end
102
-
103
- describe ".load_class_from_file" do
104
- let(:id) { 'loaded_class' }
105
- let(:file) { File.join(subject.class_dir,"#{id}.rb") }
106
- let(:klass) { ExampleClassRegistry::LoadedClass }
107
-
108
- it "must require the file" do
109
- subject.load_class_from_file(file)
110
-
111
- expect($LOADED_FEATURES).to include(file)
112
- end
113
-
114
- it "must return the registered module" do
115
- expect(subject.load_class_from_file(file)).to be(klass)
116
- end
117
-
118
- it "must register the module with the same id as the file" do
119
- subject.load_class_from_file(file)
120
-
121
- expect(subject.registry[id]).to be(klass)
122
- end
123
-
124
- context "when given a relative path" do
125
- let(:relative_path) { File.join(subject.class_dir,'foo','..',"#{id}.rb") }
126
- let(:absolute_path) { File.expand_path(relative_path) }
127
-
128
- it "must expand the path first" do
129
- expect(subject).to receive(:require).with(absolute_path) do
130
- load(absolute_path)
131
- end
132
-
133
- subject.load_class_from_file(relative_path)
134
- end
135
- end
136
-
137
- context "when the file does not exist" do
138
- let(:file) { "path/does/not/exist.rb" }
139
- let(:absolute_path) { File.expand_path(file) }
140
-
141
- it do
142
- expect {
143
- subject.load_class_from_file(file)
144
- }.to raise_error(described_class::ClassNotFound,"no such file or directory: #{absolute_path.inspect}")
145
- end
146
- end
147
-
148
- context "when the file does not register a module" do
149
- let(:id) { 'no_module' }
150
- let(:file) { File.join(subject.class_dir,"#{id}.rb") }
151
-
152
- it do
153
- expect {
154
- subject.load_class_from_file(file)
155
- }.to raise_error(described_class::ClassNotFound,"file did not register a class: #{file.inspect}")
156
- end
157
- end
158
-
159
- after do
160
- subject.registry.clear
161
- $LOADED_FEATURES.delete(file)
162
- end
163
- end
164
-
165
- describe ".load_class" do
166
- let(:id) { 'loaded_class' }
167
- let(:klass) { ExampleClassRegistry::LoadedClass }
168
- let(:path) { File.join(subject.class_dir,"#{id}.rb") }
169
-
170
- it "must require the file within the .class_dir" do
171
- subject.load_class(id)
172
-
173
- expect($LOADED_FEATURES).to include(path)
174
- end
175
-
176
- it "must return the registered module" do
177
- expect(subject.load_class(id)).to be(klass)
178
- end
179
-
180
- it "must register the module with the same id as the file" do
181
- subject.load_class(id)
182
-
183
- expect(subject.registry[id]).to be(klass)
184
- end
185
-
186
- context "when the file does not exist" do
187
- let(:id) { 'does_not_exist' }
188
-
189
- it do
190
- expect {
191
- subject.load_class(id)
192
- }.to raise_error(described_class::ClassNotFound,"could not find file for #{id.inspect}")
193
- end
194
- end
195
-
196
- context "when the file does not register a module" do
197
- let(:id) { 'no_module' }
198
-
199
- it do
200
- expect {
201
- subject.load_class(id)
202
- }.to raise_error(described_class::ClassNotFound,"file did not register a class: #{path.inspect}")
203
- end
204
- end
205
-
206
- context "when the file registers a module of a different name" do
207
- let(:id) { 'name_mismatch' }
208
- let(:unexpected_id) { 'different_name' }
209
-
210
- it do
211
- expect {
212
- subject.load_class(id)
213
- }.to raise_error(described_class::ClassNotFound,"file registered a class with a different id (#{unexpected_id.inspect}): #{path.inspect}")
214
- end
215
-
216
-
217
- end
218
-
219
- after do
220
- subject.registry.clear
221
- $LOADED_FEATURES.delete(path)
222
- end
223
- end
224
- end
@@ -1,113 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/core/cli/command_shell/command'
3
-
4
- describe Ronin::Core::CLI::CommandShell::Command do
5
- let(:name) { :foo }
6
- let(:usage) { 'ARG1 [ARG2]' }
7
- let(:completions) { %w[arg1 arg2] }
8
- let(:summary) { 'Foo bar baz' }
9
- let(:help) do
10
- [
11
- "Foo bar baz",
12
- "blah blah blah",
13
- "",
14
- " foo /bar",
15
- ""
16
- ].join($/)
17
- end
18
-
19
- subject do
20
- described_class.new(name, usage: usage,
21
- completions: completions,
22
- summary: summary,
23
- help: help)
24
- end
25
-
26
- describe "#initialize" do
27
- subject { described_class.new(name, summary: summary) }
28
-
29
- it "must set #name" do
30
- expect(subject.name).to eq(name)
31
- end
32
-
33
- it "must default #method_name to name" do
34
- expect(subject.method_name).to eq(name)
35
- end
36
-
37
- it "must default #usage to nil" do
38
- expect(subject.usage).to be(nil)
39
- end
40
-
41
- it "must default #completions to nil" do
42
- expect(subject.completions).to be(nil)
43
- end
44
-
45
- it "must default #help to #summary" do
46
- expect(subject.help).to eq(subject.summary)
47
- end
48
-
49
- context "when the method_name: keyword is given" do
50
- let(:method_name) { 'foo2' }
51
-
52
- subject do
53
- described_class.new(name, method_name: method_name,
54
- summary: summary)
55
- end
56
-
57
- it "must override #method_name" do
58
- expect(subject.method_name).to eq(method_name)
59
- end
60
- end
61
-
62
- context "when the usage: keyword is given" do
63
- subject do
64
- described_class.new(name, usage: usage,
65
- summary: summary)
66
- end
67
-
68
- it "must set #usage" do
69
- expect(subject.usage).to eq(usage)
70
- end
71
- end
72
-
73
- context "when the completions: keyword is given" do
74
- subject do
75
- described_class.new(name, usage: usage,
76
- summary: summary,
77
- completions: completions)
78
- end
79
-
80
- it "must set #completions" do
81
- expect(subject.completions).to eq(completions)
82
- end
83
- end
84
-
85
- context "when the help: keyword is given" do
86
- subject do
87
- described_class.new(name, usage: usage,
88
- summary: summary,
89
- help: help)
90
- end
91
-
92
- it "must set #help" do
93
- expect(subject.help).to eq(help)
94
- end
95
- end
96
- end
97
-
98
- describe "#to_s" do
99
- context "when #usage is set" do
100
- it "must return the #name and #usage string" do
101
- expect(subject.to_s).to eq("#{name} #{usage}")
102
- end
103
- end
104
-
105
- context "when #usage is not set" do
106
- subject { described_class.new(name, summary: summary) }
107
-
108
- it "must return the #name as a String" do
109
- expect(subject.to_s).to eq(name.to_s)
110
- end
111
- end
112
- end
113
- end