clamp 1.3.2 → 1.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,52 +4,68 @@ require "spec_helper"
4
4
 
5
5
  describe Clamp::Parameter::Definition do
6
6
 
7
- context "normal" do
7
+ context "when regular" do
8
8
 
9
9
  let(:parameter) do
10
10
  described_class.new("COLOR", "hue of choice")
11
11
  end
12
12
 
13
13
  it "has a name" do
14
- expect(parameter.name).to eql "COLOR"
14
+ expect(parameter.name).to eq "COLOR"
15
15
  end
16
16
 
17
17
  it "has a description" do
18
- expect(parameter.description).to eql "hue of choice"
18
+ expect(parameter.description).to eq "hue of choice"
19
19
  end
20
20
 
21
21
  it "is single-valued" do
22
- expect(parameter).to_not be_multivalued
22
+ expect(parameter).not_to be_multivalued
23
23
  end
24
24
 
25
25
  describe "#attribute_name" do
26
26
 
27
27
  it "is derived from the name" do
28
- expect(parameter.attribute_name).to eql "color"
28
+ expect(parameter.attribute_name).to eq "color"
29
29
  end
30
30
 
31
31
  it "can be overridden" do
32
32
  parameter = described_class.new("COLOR", "hue of choice", attribute_name: "hue")
33
- expect(parameter.attribute_name).to eql "hue"
33
+ expect(parameter.attribute_name).to eq "hue"
34
34
  end
35
35
 
36
36
  end
37
37
 
38
38
  describe "#consume" do
39
39
 
40
- it "consumes one argument" do
41
- arguments = %w[a b c]
42
- expect(parameter.consume(arguments)).to eql ["a"]
43
- expect(arguments).to eql %w[b c]
40
+ subject(:consume) { parameter.consume(arguments) }
41
+
42
+ context "with arguments" do
43
+ let(:arguments) { %w[a b c] }
44
+
45
+ it "returns one consumed argument" do
46
+ expect(consume).to eq ["a"]
47
+ end
48
+
49
+ describe "arguments after consume" do
50
+
51
+ before do
52
+ consume
53
+ end
54
+
55
+ it "has only non-consumed" do
56
+ expect(arguments).to eq %w[b c]
57
+ end
58
+
59
+ end
60
+
44
61
  end
45
62
 
46
- describe "with no arguments" do
63
+ context "without arguments" do
64
+
65
+ let(:arguments) { [] }
47
66
 
48
67
  it "raises an Argument error" do
49
- arguments = []
50
- expect do
51
- parameter.consume(arguments)
52
- end.to raise_error(ArgumentError)
68
+ expect { consume }.to raise_error(ArgumentError)
53
69
  end
54
70
 
55
71
  end
@@ -58,37 +74,55 @@ describe Clamp::Parameter::Definition do
58
74
 
59
75
  end
60
76
 
61
- context "optional (name in square brackets)" do
77
+ context "when optional (name in square brackets)" do
62
78
 
63
79
  let(:parameter) do
64
80
  described_class.new("[COLOR]", "hue of choice")
65
81
  end
66
82
 
67
83
  it "is single-valued" do
68
- expect(parameter).to_not be_multivalued
84
+ expect(parameter).not_to be_multivalued
69
85
  end
70
86
 
71
87
  describe "#attribute_name" do
72
88
 
73
89
  it "omits the brackets" do
74
- expect(parameter.attribute_name).to eql "color"
90
+ expect(parameter.attribute_name).to eq "color"
75
91
  end
76
92
 
77
93
  end
78
94
 
79
95
  describe "#consume" do
80
96
 
81
- it "consumes one argument" do
82
- arguments = %w[a b c]
83
- expect(parameter.consume(arguments)).to eql ["a"]
84
- expect(arguments).to eql %w[b c]
97
+ subject(:consume) { parameter.consume(arguments) }
98
+
99
+ context "with arguments" do
100
+
101
+ let(:arguments) { %w[a b c] }
102
+
103
+ it "returns one consumed argument" do
104
+ expect(consume).to eq ["a"]
105
+ end
106
+
107
+ describe "arguments after consume" do
108
+
109
+ before do
110
+ consume
111
+ end
112
+
113
+ it "has only non-consumed" do
114
+ expect(arguments).to eq %w[b c]
115
+ end
116
+
117
+ end
85
118
  end
86
119
 
87
- describe "with no arguments" do
120
+ context "without arguments" do
121
+
122
+ let(:arguments) { [] }
88
123
 
89
124
  it "consumes nothing" do
90
- arguments = []
91
- expect(parameter.consume(arguments)).to eql []
125
+ expect(consume).to be_empty
92
126
  end
93
127
 
94
128
  end
@@ -97,7 +131,7 @@ describe Clamp::Parameter::Definition do
97
131
 
98
132
  end
99
133
 
100
- context "list (name followed by ellipsis)" do
134
+ context "when list (name followed by ellipsis)" do
101
135
 
102
136
  let(:parameter) do
103
137
  described_class.new("FILE ...", "files to process")
@@ -110,7 +144,7 @@ describe Clamp::Parameter::Definition do
110
144
  describe "#attribute_name" do
111
145
 
112
146
  it "gets a _list suffix" do
113
- expect(parameter.attribute_name).to eql "file_list"
147
+ expect(parameter.attribute_name).to eq "file_list"
114
148
  end
115
149
 
116
150
  end
@@ -118,26 +152,43 @@ describe Clamp::Parameter::Definition do
118
152
  describe "#append_method" do
119
153
 
120
154
  it "is derived from the attribute_name" do
121
- expect(parameter.append_method).to eql "append_to_file_list"
155
+ expect(parameter.append_method).to eq "append_to_file_list"
122
156
  end
123
157
 
124
158
  end
125
159
 
126
160
  describe "#consume" do
127
161
 
128
- it "consumes all the remaining arguments" do
129
- arguments = %w[a b c]
130
- expect(parameter.consume(arguments)).to eql %w[a b c]
131
- expect(arguments).to eql []
162
+ subject(:consume) { parameter.consume(arguments) }
163
+
164
+ context "with arguments" do
165
+
166
+ let(:arguments) { %w[a b c] }
167
+
168
+ it "returns all the consumed arguments" do
169
+ expect(consume).to eq %w[a b c]
170
+ end
171
+
172
+ describe "arguments after consume" do
173
+
174
+ before do
175
+ consume
176
+ end
177
+
178
+ it "empty" do
179
+ expect(arguments).to be_empty
180
+ end
181
+
182
+ end
183
+
132
184
  end
133
185
 
134
- describe "with no arguments" do
186
+ describe "without arguments" do
187
+
188
+ let(:arguments) { [] }
135
189
 
136
190
  it "raises an Argument error" do
137
- arguments = []
138
- expect do
139
- parameter.consume(arguments)
140
- end.to raise_error(ArgumentError)
191
+ expect { consume }.to raise_error(ArgumentError)
141
192
  end
142
193
 
143
194
  end
@@ -153,7 +204,7 @@ describe Clamp::Parameter::Definition do
153
204
  describe "#attribute_name" do
154
205
 
155
206
  it "is the specified one" do
156
- expect(parameter.attribute_name).to eql "config_settings"
207
+ expect(parameter.attribute_name).to eq "config_settings"
157
208
  end
158
209
 
159
210
  end
@@ -162,7 +213,7 @@ describe Clamp::Parameter::Definition do
162
213
 
163
214
  end
164
215
 
165
- context "optional list" do
216
+ context "when optional list" do
166
217
 
167
218
  let(:parameter) do
168
219
  described_class.new("[FILES] ...", "files to process")
@@ -175,7 +226,7 @@ describe Clamp::Parameter::Definition do
175
226
  describe "#attribute_name" do
176
227
 
177
228
  it "gets a _list suffix" do
178
- expect(parameter.attribute_name).to eql "files_list"
229
+ expect(parameter.attribute_name).to eq "files_list"
179
230
  end
180
231
 
181
232
  end
@@ -183,7 +234,7 @@ describe Clamp::Parameter::Definition do
183
234
  describe "#default_value" do
184
235
 
185
236
  it "is an empty list" do
186
- expect(parameter.default_value).to eql []
237
+ expect(parameter.default_value).to be_empty
187
238
  end
188
239
 
189
240
  end
@@ -191,7 +242,7 @@ describe Clamp::Parameter::Definition do
191
242
  describe "#help" do
192
243
 
193
244
  it "does not include default" do
194
- expect(parameter.help_rhs).to_not include("default:")
245
+ expect(parameter.help_rhs).not_to include("default:")
195
246
  end
196
247
 
197
248
  end
@@ -205,7 +256,7 @@ describe Clamp::Parameter::Definition do
205
256
  describe "#default_value" do
206
257
 
207
258
  it "is that specified" do
208
- expect(parameter.default_value).to eql %w[a b c]
259
+ expect(parameter.default_value).to eq %w[a b c]
209
260
  end
210
261
 
211
262
  end
@@ -220,17 +271,36 @@ describe Clamp::Parameter::Definition do
220
271
 
221
272
  describe "#consume" do
222
273
 
223
- it "consumes all the remaining arguments" do
224
- arguments = %w[a b c]
225
- expect(parameter.consume(arguments)).to eql %w[a b c]
226
- expect(arguments).to eql []
274
+ subject(:consume) { parameter.consume(arguments) }
275
+
276
+ context "with arguments" do
277
+
278
+ let(:arguments) { %w[a b c] }
279
+
280
+ it "returns all the consumed arguments" do
281
+ expect(consume).to eq %w[a b c]
282
+ end
283
+
284
+ describe "arguments after consume" do
285
+
286
+ before do
287
+ consume
288
+ end
289
+
290
+ it "empty" do
291
+ expect(arguments).to be_empty
292
+ end
293
+
294
+ end
295
+
227
296
  end
228
297
 
229
- context "with no arguments" do
298
+ context "without arguments" do
299
+
300
+ let(:arguments) { [] }
230
301
 
231
302
  it "don't override defaults" do
232
- arguments = []
233
- expect(parameter.consume(arguments)).to eql []
303
+ expect(consume).to be_empty
234
304
  end
235
305
 
236
306
  end
data/spec/spec_helper.rb CHANGED
@@ -3,15 +3,14 @@
3
3
  require "rspec"
4
4
  require "clamp"
5
5
  require "stringio"
6
+ require "pry-byebug"
6
7
 
7
8
  RSpec.configure do |config|
8
9
 
9
- config.around(:each) do |example|
10
- begin
11
- example.run
12
- rescue SystemExit => e
13
- raise "Unexpected exit with status #{e.status}"
14
- end
10
+ config.around do |example|
11
+ example.run
12
+ rescue SystemExit => e
13
+ raise "Unexpected exit with status #{e.status}"
15
14
  end
16
15
 
17
16
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clamp
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Williams
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2020-08-20 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies: []
13
12
  description: |
14
13
  Clamp provides an object-model for command-line utilities.
@@ -25,6 +24,7 @@ files:
25
24
  - ".rubocop.yml"
26
25
  - ".travis.yml"
27
26
  - CHANGES.md
27
+ - CODEOWNERS
28
28
  - Gemfile
29
29
  - Guardfile
30
30
  - LICENSE
@@ -61,19 +61,19 @@ files:
61
61
  - lib/clamp/truthy.rb
62
62
  - lib/clamp/version.rb
63
63
  - spec/clamp/command_group_spec.rb
64
+ - spec/clamp/command_option_module_spec.rb
65
+ - spec/clamp/command_option_reordering_spec.rb
64
66
  - spec/clamp/command_spec.rb
65
- - spec/clamp/help_spec.rb
67
+ - spec/clamp/help/builder_spec.rb
66
68
  - spec/clamp/messages_spec.rb
67
69
  - spec/clamp/option/definition_spec.rb
68
- - spec/clamp/option_module_spec.rb
69
- - spec/clamp/option_reordering_spec.rb
70
70
  - spec/clamp/parameter/definition_spec.rb
71
71
  - spec/spec_helper.rb
72
72
  homepage: https://github.com/mdub/clamp
73
73
  licenses:
74
74
  - MIT
75
- metadata: {}
76
- post_install_message:
75
+ metadata:
76
+ rubygems_mfa_required: 'true'
77
77
  rdoc_options: []
78
78
  require_paths:
79
79
  - lib
@@ -81,24 +81,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
81
81
  requirements:
82
82
  - - ">="
83
83
  - !ruby/object:Gem::Version
84
- version: '0'
84
+ version: '2.5'
85
+ - - "<"
86
+ - !ruby/object:Gem::Version
87
+ version: '4'
85
88
  required_rubygems_version: !ruby/object:Gem::Requirement
86
89
  requirements:
87
90
  - - ">="
88
91
  - !ruby/object:Gem::Version
89
92
  version: '0'
90
93
  requirements: []
91
- rubygems_version: 3.1.2
92
- signing_key:
94
+ rubygems_version: 3.7.1
93
95
  specification_version: 4
94
96
  summary: a minimal framework for command-line utilities
95
- test_files:
96
- - spec/clamp/command_group_spec.rb
97
- - spec/clamp/command_spec.rb
98
- - spec/clamp/help_spec.rb
99
- - spec/clamp/messages_spec.rb
100
- - spec/clamp/option/definition_spec.rb
101
- - spec/clamp/option_module_spec.rb
102
- - spec/clamp/option_reordering_spec.rb
103
- - spec/clamp/parameter/definition_spec.rb
104
- - spec/spec_helper.rb
97
+ test_files: []