switches.rb 0.12.1 → 0.13.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG +16 -2
- data/Rakefile +3 -3
- data/lib/Switches/VERSION.rb +1 -1
- data/spec/all.rb +84 -77
- data/switches.rb.gemspec +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b590f038763df24590cd79b6646fb8ebb2edfb110f3b9d43c464ba29b8b6cf89
|
|
4
|
+
data.tar.gz: d3b8192ac3ba56d12c252cfb5d97cbe850bb4e1035f05e5bd9d70d6e837c0665
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 82248fe0a7aa10ebb8b4dd0bc5bad30d7f85232dcc46456ae4bb2274da1e78d9184e6beb33d77db28ffe2b46b4f94c9f1a717238c0f0f2a7b0799a0a68fb00f0
|
|
7
|
+
data.tar.gz: 2a930511b47f3ea6f4d1aedc2c9a0370fd092435890ec3b2a11ca86340a15c59432a19a6fa0f6a75c03de8964cc198c08a0d4f977b479c62becc92e7005ca6cc
|
data/CHANGELOG
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 20260817
|
|
4
|
+
|
|
5
|
+
0.13.0: Convert the specs from RSpec to Minitest.
|
|
6
|
+
|
|
7
|
+
1. ~ spec/all.rb: Minitest spec style throughout, + require 'minitest/autorun'. The 75 examples run as 75 runs and 92 assertions, a raise checked for its message becoming two. The substitutions are tabulated in ROADMAP.md, along with the four the mechanical pass got wrong.
|
|
8
|
+
2. ~ Rakefile: Rake::TestTask in place of RSpec::Core::RakeTask, pointed at spec/all.rb.
|
|
9
|
+
3. ~ switches.rb.gemspec: minitest and rake as the development dependencies, in place of rake and rspec.
|
|
10
|
+
4. ~ spec/all.rb: the gemspec spec which asserts those dependencies, which the conversion otherwise fails against itself.
|
|
11
|
+
5. ~ CHANGELOG: - item 5 of the 0.12.0 entry, which named ROADMAP.md and the header's Todo and Ideas sections. Both went out in 0.12.1 and 0.12.0 contains neither; it was left behind when the one commit was split into two.
|
|
12
|
+
6. ~ ROADMAP.md: the conversion moves from Open questions into 0.13.0's section, and 0.12.0's section is dated 20260817, which is when it was made.
|
|
13
|
+
7. ~ CHANGELOG: the date headings — 0.13.0, 0.12.1 and 0.12.0 under 20260817, and + 20260816 for 0.11.0, 0.10.5 and 0.10.4, which had been left under the one heading with them.
|
|
4
14
|
|
|
5
15
|
0.12.1: Move the reasoning out of the CHANGELOG and the header into a ROADMAP.
|
|
6
16
|
|
|
@@ -14,7 +24,9 @@
|
|
|
14
24
|
2. + lib/Switches.rb: SwitchNameCollision < ArgumentError.
|
|
15
25
|
3. ~ README.md: + a Notes entry for the refusal, and for the booleans and OptionParser names it does not cover.
|
|
16
26
|
4. + spec/all.rb: the refusal through #set and #perform, the message, that nothing reaches the parser first, and the two legal cases.
|
|
17
|
-
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
## 20260816
|
|
18
30
|
|
|
19
31
|
0.11.0: Forward to OptionParser, which #method_missing has never actually done.
|
|
20
32
|
|
|
@@ -42,6 +54,7 @@
|
|
|
42
54
|
6. ~ lib/Switches.rb: the header's Dependencies section names ostruct, since the Standard Ruby Library no longer covers it.
|
|
43
55
|
7. ~ .gitignore: + a header, + .claude, ~ /tmp/ to tmp/, and - /test/tmp/, which tmp/ now covers.
|
|
44
56
|
|
|
57
|
+
|
|
45
58
|
## 20260812
|
|
46
59
|
|
|
47
60
|
0.10.3: Move the version into a constant, and add the standard version and gemspec tests.
|
|
@@ -78,6 +91,7 @@
|
|
|
78
91
|
5. + LICENSE.txt: the MIT licence.
|
|
79
92
|
6. + CHANGELOG: this file.
|
|
80
93
|
|
|
94
|
+
|
|
81
95
|
## 20180404
|
|
82
96
|
|
|
83
97
|
0.9.16: Add a Gemfile.
|
data/Rakefile
CHANGED
data/lib/Switches/VERSION.rb
CHANGED
data/spec/all.rb
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
# spec/all.rb
|
|
2
2
|
|
|
3
|
+
require 'minitest/autorun'
|
|
4
|
+
|
|
3
5
|
require_relative '../lib/Switches'
|
|
4
6
|
|
|
5
7
|
describe Switches do
|
|
6
8
|
describe ".new" do
|
|
7
9
|
it "returns an object of class Switches" do
|
|
8
|
-
|
|
10
|
+
_(Switches.new.class).must_equal Switches
|
|
9
11
|
end
|
|
10
12
|
end
|
|
11
13
|
|
|
@@ -21,40 +23,40 @@ describe Switches do
|
|
|
21
23
|
end
|
|
22
24
|
|
|
23
25
|
it "sets a short boolean switch to true when supplied with a short switch" do
|
|
24
|
-
|
|
26
|
+
_(build('-v').v?).must_equal true
|
|
25
27
|
end
|
|
26
28
|
|
|
27
29
|
it "sets a long boolean switch to true when supplied with a short switch" do
|
|
28
|
-
|
|
30
|
+
_(build('-v').verbose?).must_equal true
|
|
29
31
|
end
|
|
30
32
|
|
|
31
33
|
it "sets a short boolean switch to true when supplied with a long switch" do
|
|
32
|
-
|
|
34
|
+
_(build('--verbose').v?).must_equal true
|
|
33
35
|
end
|
|
34
36
|
|
|
35
37
|
it "sets a long boolean switch to true when supplied with a long switch" do
|
|
36
|
-
|
|
38
|
+
_(build('--verbose').verbose?).must_equal true
|
|
37
39
|
end
|
|
38
40
|
|
|
39
41
|
it "sets a short switch to the value supplied when supplied with a short switch" do
|
|
40
|
-
|
|
42
|
+
_(build('-p 22').p).must_equal '22'
|
|
41
43
|
end
|
|
42
44
|
|
|
43
45
|
it "sets a long switch to the value supplied when supplied with a short switch" do
|
|
44
|
-
|
|
46
|
+
_(build('-p 22').port).must_equal '22'
|
|
45
47
|
end
|
|
46
48
|
|
|
47
49
|
it "sets a short switch to the value supplied when supplied with a long switch" do
|
|
48
|
-
|
|
50
|
+
_(build('--port 22').p).must_equal '22'
|
|
49
51
|
end
|
|
50
52
|
|
|
51
53
|
it "sets a long switch to the value supplied when supplied with a long switch" do
|
|
52
|
-
|
|
54
|
+
_(build('--port 22').port).must_equal '22'
|
|
53
55
|
end
|
|
54
56
|
|
|
55
57
|
it "doesn't matter in which order the short and long switches are given" do
|
|
56
|
-
|
|
57
|
-
|
|
58
|
+
_(build('-h example.com').h).must_equal 'example.com'
|
|
59
|
+
_(build('--host example.com').h).must_equal 'example.com'
|
|
58
60
|
end
|
|
59
61
|
end
|
|
60
62
|
|
|
@@ -68,27 +70,27 @@ describe Switches do
|
|
|
68
70
|
end
|
|
69
71
|
|
|
70
72
|
it "sets a short switch to the argument supplied with a short switch" do
|
|
71
|
-
|
|
73
|
+
_(build('-p 22').p).must_equal '22'
|
|
72
74
|
end
|
|
73
75
|
|
|
74
76
|
it "sets a long switch to the argument supplied with a short switch" do
|
|
75
|
-
|
|
77
|
+
_(build('-p 22').port).must_equal '22'
|
|
76
78
|
end
|
|
77
79
|
|
|
78
80
|
it "sets a short switch to the argument supplied with a long switch" do
|
|
79
|
-
|
|
81
|
+
_(build('--port 22').p).must_equal '22'
|
|
80
82
|
end
|
|
81
83
|
|
|
82
84
|
it "sets a long switch to the argument supplied with a long switch" do
|
|
83
|
-
|
|
85
|
+
_(build('--port 22').port).must_equal '22'
|
|
84
86
|
end
|
|
85
87
|
|
|
86
88
|
it "raises OptionParser::MissingArgument when no argument is supplied to a short switch" do
|
|
87
|
-
|
|
89
|
+
_{build('-p')}.must_raise OptionParser::MissingArgument
|
|
88
90
|
end
|
|
89
91
|
|
|
90
92
|
it "raises OptionParser::MissingArgument when no argument is supplied to a long switch" do
|
|
91
|
-
|
|
93
|
+
_{build('--port')}.must_raise OptionParser::MissingArgument
|
|
92
94
|
end
|
|
93
95
|
end
|
|
94
96
|
|
|
@@ -102,27 +104,28 @@ describe Switches do
|
|
|
102
104
|
end
|
|
103
105
|
|
|
104
106
|
it "sets a short switch to the argument supplied with a short switch" do
|
|
105
|
-
|
|
107
|
+
_(build('-p 22').p).must_equal '22'
|
|
106
108
|
end
|
|
107
109
|
|
|
108
110
|
it "sets a long switch to the argument supplied with a short switch" do
|
|
109
|
-
|
|
111
|
+
_(build('-p 22').port).must_equal '22'
|
|
110
112
|
end
|
|
111
113
|
|
|
112
114
|
it "sets a short switch to the argument supplied with a long switch" do
|
|
113
|
-
|
|
115
|
+
_(build('--port 22').p).must_equal '22'
|
|
114
116
|
end
|
|
115
117
|
|
|
116
118
|
it "sets a long switch to the argument supplied with a long switch" do
|
|
117
|
-
|
|
119
|
+
_(build('--port 22').port).must_equal '22'
|
|
118
120
|
end
|
|
119
121
|
|
|
120
122
|
it "raises RequiredSwitchMissing when no switch is supplied" do
|
|
121
|
-
|
|
123
|
+
_{build}.must_raise RequiredSwitchMissing
|
|
122
124
|
end
|
|
123
125
|
|
|
124
126
|
it "names every missing switch in the RequiredSwitchMissing message" do
|
|
125
|
-
|
|
127
|
+
error = _{build}.must_raise RequiredSwitchMissing
|
|
128
|
+
_(error.message).must_match(/-p.*--port/m)
|
|
126
129
|
end
|
|
127
130
|
end
|
|
128
131
|
|
|
@@ -136,31 +139,31 @@ describe Switches do
|
|
|
136
139
|
end
|
|
137
140
|
|
|
138
141
|
it "sets a short switch to the argument supplied with a short switch" do
|
|
139
|
-
|
|
142
|
+
_(build('-p 22').p).must_equal '22'
|
|
140
143
|
end
|
|
141
144
|
|
|
142
145
|
it "sets a long switch to the argument supplied with a short switch" do
|
|
143
|
-
|
|
146
|
+
_(build('-p 22').port).must_equal '22'
|
|
144
147
|
end
|
|
145
148
|
|
|
146
149
|
it "sets a short switch to the argument supplied with a long switch" do
|
|
147
|
-
|
|
150
|
+
_(build('--port 22').p).must_equal '22'
|
|
148
151
|
end
|
|
149
152
|
|
|
150
153
|
it "sets a long switch to the argument supplied with a long switch" do
|
|
151
|
-
|
|
154
|
+
_(build('--port 22').port).must_equal '22'
|
|
152
155
|
end
|
|
153
156
|
|
|
154
157
|
it "raises OptionParser::MissingArgument when no argument is supplied to a short switch" do
|
|
155
|
-
|
|
158
|
+
_{build('-p')}.must_raise OptionParser::MissingArgument
|
|
156
159
|
end
|
|
157
160
|
|
|
158
161
|
it "raises OptionParser::MissingArgument when no argument is supplied to a long switch" do
|
|
159
|
-
|
|
162
|
+
_{build('--port')}.must_raise OptionParser::MissingArgument
|
|
160
163
|
end
|
|
161
164
|
|
|
162
165
|
it "raises RequiredSwitchMissing when no switch is supplied" do
|
|
163
|
-
|
|
166
|
+
_{build}.must_raise RequiredSwitchMissing
|
|
164
167
|
end
|
|
165
168
|
end
|
|
166
169
|
|
|
@@ -171,41 +174,44 @@ describe Switches do
|
|
|
171
174
|
end
|
|
172
175
|
|
|
173
176
|
it "refuses a switch named after a core method" do
|
|
174
|
-
|
|
177
|
+
error = _{build{|s| s.set(:tap)}}.must_raise SwitchNameCollision
|
|
178
|
+
_(error.message).must_match(/Kernel#tap/)
|
|
175
179
|
end
|
|
176
180
|
|
|
177
181
|
it "refuses a switch named after a Switches method" do
|
|
178
|
-
|
|
182
|
+
error = _{build{|s| s.set(:settings)}}.must_raise SwitchNameCollision
|
|
183
|
+
_(error.message).must_match(/Switches#settings/)
|
|
179
184
|
end
|
|
180
185
|
|
|
181
186
|
it "refuses a colliding name declared through #perform" do
|
|
182
|
-
|
|
187
|
+
_{build{|s| s.perform(:display){}}}.must_raise SwitchNameCollision
|
|
183
188
|
end
|
|
184
189
|
|
|
185
190
|
it "names the switch in the form it would be supplied in" do
|
|
186
|
-
|
|
191
|
+
error = _{build{|s| s.set(:instance_variable_get)}}.must_raise SwitchNameCollision
|
|
192
|
+
_(error.message).must_match(/--instance_variable_get/)
|
|
187
193
|
end
|
|
188
194
|
|
|
189
195
|
it "raises before the switch is declared to the parser" do
|
|
190
196
|
switches = Switches.new
|
|
191
197
|
begin; switches.set(:tap); rescue SwitchNameCollision; end
|
|
192
|
-
|
|
198
|
+
_(switches.to_h).must_equal({})
|
|
193
199
|
end
|
|
194
200
|
|
|
195
201
|
it "accepts the name as a boolean, the accessor then carrying a question mark" do
|
|
196
202
|
ARGV.clear
|
|
197
203
|
ARGV << '--tap'
|
|
198
|
-
|
|
204
|
+
_(Switches.new{|s| s.boolean(:tap)}.tap?).must_equal true
|
|
199
205
|
end
|
|
200
206
|
|
|
201
207
|
it "accepts a name OptionParser has, a declared switch winning over the parser" do
|
|
202
208
|
ARGV.clear
|
|
203
209
|
%w{--banner text}.each{|a| ARGV << a}
|
|
204
|
-
|
|
210
|
+
_(Switches.new{|s| s.set(:banner)}.banner).must_equal 'text'
|
|
205
211
|
end
|
|
206
212
|
|
|
207
213
|
it "raises a SwitchNameCollision, which is an ArgumentError" do
|
|
208
|
-
|
|
214
|
+
_(SwitchNameCollision.ancestors).must_include ArgumentError
|
|
209
215
|
end
|
|
210
216
|
end
|
|
211
217
|
|
|
@@ -216,47 +222,47 @@ describe Switches do
|
|
|
216
222
|
end
|
|
217
223
|
|
|
218
224
|
it "forwards a writer to the OptionParser" do
|
|
219
|
-
|
|
225
|
+
_(build{|s| s.banner = 'Usage: tap-audit [options]'}.help).must_match(/\AUsage: tap-audit \[options\]/)
|
|
220
226
|
end
|
|
221
227
|
|
|
222
228
|
it "forwards a method taking an argument to the OptionParser" do
|
|
223
|
-
|
|
229
|
+
_(build{|s| s.separator 'Options:'}.help).must_match(/^Options:$/)
|
|
224
230
|
end
|
|
225
231
|
|
|
226
232
|
it "forwards a reader to the OptionParser" do
|
|
227
233
|
switches = build{|s| s.program_name = 'tap-audit'}
|
|
228
|
-
|
|
229
|
-
|
|
234
|
+
_(switches.program_name).must_equal 'tap-audit'
|
|
235
|
+
_(switches.help).must_match(/\AUsage: tap-audit/)
|
|
230
236
|
end
|
|
231
237
|
|
|
232
238
|
it "prefers a declared switch to the OptionParser method of the same name" do
|
|
233
239
|
ARGV.clear
|
|
234
240
|
%w{--version 2.1}.each{|a| ARGV << a}
|
|
235
|
-
|
|
241
|
+
_(Switches.new{|s| s.set(:version)}.version).must_equal '2.1'
|
|
236
242
|
end
|
|
237
243
|
|
|
238
244
|
it "prefers a declared switch when it is written to as well" do
|
|
239
245
|
switches = build{|s| s.set(:banner)}
|
|
240
246
|
switches.banner = 'a setting, not the banner'
|
|
241
|
-
|
|
247
|
+
_(switches.to_h[:banner]).must_equal 'a setting, not the banner'
|
|
242
248
|
end
|
|
243
249
|
|
|
244
250
|
it "falls through to the settings for a name which is neither" do
|
|
245
|
-
|
|
251
|
+
_(build{|s| s.set(:port)}.nonesuch).must_be_nil
|
|
246
252
|
end
|
|
247
253
|
|
|
248
254
|
it "does not forward #to_a, which OptionParser answers with its help" do
|
|
249
|
-
|
|
255
|
+
_(build{|s| s.set(:port)}.to_a).must_be_nil
|
|
250
256
|
end
|
|
251
257
|
|
|
252
258
|
it "leaves Array() with the switches rather than the parser's help" do
|
|
253
259
|
switches = build{|s| s.set(:port)}
|
|
254
|
-
|
|
260
|
+
_(Array(switches)).must_equal [switches]
|
|
255
261
|
end
|
|
256
262
|
|
|
257
263
|
it "leaves the splat with the switches rather than the parser's help" do
|
|
258
264
|
switches = build{|s| s.set(:port)}
|
|
259
|
-
|
|
265
|
+
_([*switches]).must_equal [switches]
|
|
260
266
|
end
|
|
261
267
|
end
|
|
262
268
|
|
|
@@ -271,23 +277,23 @@ describe Switches do
|
|
|
271
277
|
end
|
|
272
278
|
|
|
273
279
|
it "sets a boolean switch supplied in its underscored form" do
|
|
274
|
-
|
|
280
|
+
_(build('--update_template').update_template?).must_equal true
|
|
275
281
|
end
|
|
276
282
|
|
|
277
283
|
it "sets a boolean switch supplied in its hyphenated form" do
|
|
278
|
-
|
|
284
|
+
_(build('--update-template').update_template?).must_equal true
|
|
279
285
|
end
|
|
280
286
|
|
|
281
287
|
it "sets a switch to the argument supplied in its underscored form" do
|
|
282
|
-
|
|
288
|
+
_(build('--access_token abc123').access_token).must_equal 'abc123'
|
|
283
289
|
end
|
|
284
290
|
|
|
285
291
|
it "sets a switch to the argument supplied in its hyphenated form" do
|
|
286
|
-
|
|
292
|
+
_(build('--access-token abc123').access_token).must_equal 'abc123'
|
|
287
293
|
end
|
|
288
294
|
|
|
289
295
|
it "names the setting for the symbol declared, whichever form is supplied" do
|
|
290
|
-
|
|
296
|
+
_(build('--update-template --access-token abc123').to_h).must_equal({update_template?: true, access_token: 'abc123'})
|
|
291
297
|
end
|
|
292
298
|
end
|
|
293
299
|
|
|
@@ -301,19 +307,19 @@ describe Switches do
|
|
|
301
307
|
end
|
|
302
308
|
|
|
303
309
|
it "sets the switch to the argument supplied in its underscored form" do
|
|
304
|
-
|
|
310
|
+
_(build('--access_token abc123').access_token).must_equal 'abc123'
|
|
305
311
|
end
|
|
306
312
|
|
|
307
313
|
it "sets the switch to the argument supplied in its hyphenated form" do
|
|
308
|
-
|
|
314
|
+
_(build('--access-token abc123').access_token).must_equal 'abc123'
|
|
309
315
|
end
|
|
310
316
|
|
|
311
317
|
it "raises OptionParser::MissingArgument when no argument is supplied to the underscored form" do
|
|
312
|
-
|
|
318
|
+
_{build('--access_token')}.must_raise OptionParser::MissingArgument
|
|
313
319
|
end
|
|
314
320
|
|
|
315
321
|
it "raises OptionParser::MissingArgument when no argument is supplied to the hyphenated form" do
|
|
316
|
-
|
|
322
|
+
_{build('--access-token')}.must_raise OptionParser::MissingArgument
|
|
317
323
|
end
|
|
318
324
|
end
|
|
319
325
|
|
|
@@ -327,19 +333,20 @@ describe Switches do
|
|
|
327
333
|
end
|
|
328
334
|
|
|
329
335
|
it "counts the underscored form as supplied" do
|
|
330
|
-
|
|
336
|
+
_(build('--access_token abc123').access_token).must_equal 'abc123'
|
|
331
337
|
end
|
|
332
338
|
|
|
333
339
|
it "counts the hyphenated form as supplied" do
|
|
334
|
-
|
|
340
|
+
_(build('--access-token abc123').access_token).must_equal 'abc123'
|
|
335
341
|
end
|
|
336
342
|
|
|
337
343
|
it "raises RequiredSwitchMissing when neither form is supplied" do
|
|
338
|
-
|
|
344
|
+
_{build}.must_raise RequiredSwitchMissing
|
|
339
345
|
end
|
|
340
346
|
|
|
341
347
|
it "names the hyphenated form in the RequiredSwitchMissing message" do
|
|
342
|
-
|
|
348
|
+
error = _{build}.must_raise RequiredSwitchMissing
|
|
349
|
+
_(error.message).must_match(/--access-token/)
|
|
343
350
|
end
|
|
344
351
|
end
|
|
345
352
|
|
|
@@ -353,23 +360,23 @@ describe Switches do
|
|
|
353
360
|
it "calls the block when supplied with a short switch" do
|
|
354
361
|
called = false
|
|
355
362
|
build('-a'){called = true}
|
|
356
|
-
|
|
363
|
+
_(called).must_equal true
|
|
357
364
|
end
|
|
358
365
|
|
|
359
366
|
it "calls the block when supplied with a long switch" do
|
|
360
367
|
called = false
|
|
361
368
|
build('--action'){called = true}
|
|
362
|
-
|
|
369
|
+
_(called).must_equal true
|
|
363
370
|
end
|
|
364
371
|
|
|
365
372
|
it "doesn't call the block when the switch isn't supplied" do
|
|
366
373
|
called = false
|
|
367
374
|
build{called = true}
|
|
368
|
-
|
|
375
|
+
_(called).must_equal false
|
|
369
376
|
end
|
|
370
377
|
|
|
371
378
|
it "doesn't require an argument" do
|
|
372
|
-
|
|
379
|
+
_(build('-a'){}).must_be_kind_of Switches
|
|
373
380
|
end
|
|
374
381
|
end
|
|
375
382
|
|
|
@@ -383,23 +390,23 @@ describe Switches do
|
|
|
383
390
|
it "passes the argument to the block when supplied with a short switch" do
|
|
384
391
|
argument = nil
|
|
385
392
|
build('-a value'){|o| argument = o}
|
|
386
|
-
|
|
393
|
+
_(argument).must_equal 'value'
|
|
387
394
|
end
|
|
388
395
|
|
|
389
396
|
it "passes the argument to the block when supplied with a long switch" do
|
|
390
397
|
argument = nil
|
|
391
398
|
build('--action value'){|o| argument = o}
|
|
392
|
-
|
|
399
|
+
_(argument).must_equal 'value'
|
|
393
400
|
end
|
|
394
401
|
|
|
395
402
|
it "doesn't call the block when the switch isn't supplied" do
|
|
396
403
|
called = false
|
|
397
404
|
build{called = true}
|
|
398
|
-
|
|
405
|
+
_(called).must_equal false
|
|
399
406
|
end
|
|
400
407
|
|
|
401
408
|
it "raises OptionParser::MissingArgument when no argument is supplied" do
|
|
402
|
-
|
|
409
|
+
_{build('-a'){}}.must_raise OptionParser::MissingArgument
|
|
403
410
|
end
|
|
404
411
|
end
|
|
405
412
|
end
|
|
@@ -407,16 +414,16 @@ end
|
|
|
407
414
|
describe Switches do
|
|
408
415
|
describe "VERSION" do
|
|
409
416
|
it "is a string" do
|
|
410
|
-
|
|
417
|
+
_(Switches::VERSION).must_be_kind_of String
|
|
411
418
|
end
|
|
412
419
|
|
|
413
420
|
it "is three numbers separated by dots" do
|
|
414
|
-
|
|
421
|
+
_(Switches::VERSION).must_match(/\A\d+\.\d+\.\d+\z/)
|
|
415
422
|
end
|
|
416
423
|
|
|
417
424
|
it "matches the newest entry in the CHANGELOG" do
|
|
418
425
|
changelog = File.read(File.expand_path('../CHANGELOG', __dir__))
|
|
419
|
-
|
|
426
|
+
_(changelog[/^(\d+\.\d+\.\d+):/, 1]).must_equal Switches::VERSION
|
|
420
427
|
end
|
|
421
428
|
end
|
|
422
429
|
end
|
|
@@ -425,22 +432,22 @@ describe 'switches.rb.gemspec' do
|
|
|
425
432
|
let(:spec){Gem::Specification.load(File.expand_path('../switches.rb.gemspec', __dir__))}
|
|
426
433
|
|
|
427
434
|
it "is a valid specification" do
|
|
428
|
-
|
|
435
|
+
_(spec.validate).must_equal true
|
|
429
436
|
end
|
|
430
437
|
|
|
431
438
|
it "does not pin a date" do
|
|
432
|
-
|
|
439
|
+
_(spec.date).must_equal Gem::Specification.new.date
|
|
433
440
|
end
|
|
434
441
|
|
|
435
442
|
it "takes its version from Switches::VERSION" do
|
|
436
|
-
|
|
443
|
+
_(spec.version.to_s).must_equal Switches::VERSION
|
|
437
444
|
end
|
|
438
445
|
|
|
439
446
|
it "declares ostruct as its only runtime dependency" do
|
|
440
|
-
|
|
447
|
+
_(spec.runtime_dependencies.map(&:name).sort).must_equal %w{ostruct}
|
|
441
448
|
end
|
|
442
449
|
|
|
443
450
|
it "declares its development dependencies" do
|
|
444
|
-
|
|
451
|
+
_(spec.development_dependencies.map(&:name).sort).must_equal %w{minitest rake}
|
|
445
452
|
end
|
|
446
453
|
end
|
data/switches.rb.gemspec
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: switches.rb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.13.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- thoran
|
|
@@ -24,7 +24,7 @@ dependencies:
|
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
25
|
version: '0'
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
|
-
name:
|
|
27
|
+
name: minitest
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
29
29
|
requirements:
|
|
30
30
|
- - ">="
|
|
@@ -38,7 +38,7 @@ dependencies:
|
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
39
|
version: '0'
|
|
40
40
|
- !ruby/object:Gem::Dependency
|
|
41
|
-
name:
|
|
41
|
+
name: rake
|
|
42
42
|
requirement: !ruby/object:Gem::Requirement
|
|
43
43
|
requirements:
|
|
44
44
|
- - ">="
|