command_kit 0.1.0.pre1 → 0.2.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.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +15 -0
  3. data/.rubocop.yml +138 -0
  4. data/ChangeLog.md +34 -2
  5. data/Gemfile +3 -0
  6. data/README.md +135 -214
  7. data/Rakefile +3 -2
  8. data/command_kit.gemspec +4 -4
  9. data/examples/colors.rb +30 -0
  10. data/examples/command.rb +65 -0
  11. data/examples/pager.rb +30 -0
  12. data/gemspec.yml +10 -2
  13. data/lib/command_kit/arguments/argument.rb +16 -44
  14. data/lib/command_kit/arguments/argument_value.rb +3 -30
  15. data/lib/command_kit/arguments.rb +66 -20
  16. data/lib/command_kit/colors.rb +253 -45
  17. data/lib/command_kit/command.rb +50 -3
  18. data/lib/command_kit/command_name.rb +9 -0
  19. data/lib/command_kit/commands/auto_load/subcommand.rb +3 -0
  20. data/lib/command_kit/commands/auto_load.rb +16 -0
  21. data/lib/command_kit/commands/auto_require.rb +16 -0
  22. data/lib/command_kit/commands/command.rb +3 -0
  23. data/lib/command_kit/commands/help.rb +2 -0
  24. data/lib/command_kit/commands/parent_command.rb +7 -0
  25. data/lib/command_kit/commands/subcommand.rb +15 -0
  26. data/lib/command_kit/commands.rb +40 -4
  27. data/lib/command_kit/description.rb +15 -2
  28. data/lib/command_kit/env/home.rb +9 -0
  29. data/lib/command_kit/env/path.rb +15 -0
  30. data/lib/command_kit/env.rb +4 -0
  31. data/lib/command_kit/examples.rb +15 -2
  32. data/lib/command_kit/exception_handler.rb +4 -0
  33. data/lib/command_kit/help/man.rb +74 -47
  34. data/lib/command_kit/help.rb +10 -1
  35. data/lib/command_kit/inflector.rb +49 -17
  36. data/lib/command_kit/interactive.rb +239 -0
  37. data/lib/command_kit/main.rb +20 -9
  38. data/lib/command_kit/man.rb +44 -0
  39. data/lib/command_kit/open_app.rb +69 -0
  40. data/lib/command_kit/options/option.rb +36 -9
  41. data/lib/command_kit/options/option_value.rb +42 -3
  42. data/lib/command_kit/options/parser.rb +44 -17
  43. data/lib/command_kit/options/quiet.rb +3 -0
  44. data/lib/command_kit/options/verbose.rb +5 -0
  45. data/lib/command_kit/options/version.rb +6 -0
  46. data/lib/command_kit/options.rb +59 -10
  47. data/lib/command_kit/os/linux.rb +157 -0
  48. data/lib/command_kit/os.rb +165 -11
  49. data/lib/command_kit/package_manager.rb +200 -0
  50. data/lib/command_kit/pager.rb +84 -9
  51. data/lib/command_kit/printing/indent.rb +25 -2
  52. data/lib/command_kit/printing.rb +23 -0
  53. data/lib/command_kit/program_name.rb +7 -0
  54. data/lib/command_kit/stdio.rb +24 -0
  55. data/lib/command_kit/sudo.rb +40 -0
  56. data/lib/command_kit/terminal.rb +159 -0
  57. data/lib/command_kit/usage.rb +14 -0
  58. data/lib/command_kit/version.rb +1 -1
  59. data/lib/command_kit/xdg.rb +21 -1
  60. data/lib/command_kit.rb +1 -0
  61. data/spec/arguments/argument_spec.rb +5 -41
  62. data/spec/arguments/argument_value_spec.rb +1 -61
  63. data/spec/arguments_spec.rb +8 -25
  64. data/spec/colors_spec.rb +277 -13
  65. data/spec/command_name_spec.rb +1 -1
  66. data/spec/command_spec.rb +4 -1
  67. data/spec/commands/auto_load/subcommand_spec.rb +1 -1
  68. data/spec/commands/auto_load_spec.rb +1 -1
  69. data/spec/commands/auto_require_spec.rb +2 -2
  70. data/spec/commands/help_spec.rb +1 -1
  71. data/spec/commands/parent_command_spec.rb +1 -1
  72. data/spec/commands/subcommand_spec.rb +1 -1
  73. data/spec/commands_spec.rb +2 -2
  74. data/spec/description_spec.rb +1 -25
  75. data/spec/env/home_spec.rb +1 -1
  76. data/spec/env/path_spec.rb +1 -1
  77. data/spec/examples_spec.rb +1 -25
  78. data/spec/exception_handler_spec.rb +1 -1
  79. data/spec/help/man_spec.rb +316 -0
  80. data/spec/help_spec.rb +0 -25
  81. data/spec/inflector_spec.rb +71 -9
  82. data/spec/interactive_spec.rb +415 -0
  83. data/spec/main_spec.rb +7 -7
  84. data/spec/man_spec.rb +46 -0
  85. data/spec/open_app_spec.rb +85 -0
  86. data/spec/options/option_spec.rb +48 -9
  87. data/spec/options/option_value_spec.rb +53 -4
  88. data/spec/options_spec.rb +1 -1
  89. data/spec/os/linux_spec.rb +154 -0
  90. data/spec/os_spec.rb +201 -14
  91. data/spec/package_manager_spec.rb +806 -0
  92. data/spec/pager_spec.rb +78 -15
  93. data/spec/printing/indent_spec.rb +1 -1
  94. data/spec/printing_spec.rb +10 -2
  95. data/spec/program_name_spec.rb +1 -1
  96. data/spec/spec_helper.rb +0 -3
  97. data/spec/sudo_spec.rb +51 -0
  98. data/spec/{console_spec.rb → terminal_spec.rb} +65 -35
  99. data/spec/usage_spec.rb +2 -2
  100. data/spec/xdg_spec.rb +1 -1
  101. metadata +32 -13
  102. data/lib/command_kit/arguments/usage.rb +0 -6
  103. data/lib/command_kit/console.rb +0 -141
  104. data/lib/command_kit/options/usage.rb +0 -6
data/lib/command_kit.rb CHANGED
@@ -1 +1,2 @@
1
+ require 'command_kit/command'
1
2
  require 'command_kit/version'
@@ -1,41 +1,21 @@
1
1
  require 'spec_helper'
2
2
  require 'command_kit/arguments/argument'
3
3
 
4
- describe Arguments::Argument do
4
+ describe CommandKit::Arguments::Argument do
5
5
  let(:name) { :foo }
6
- let(:type) { String }
7
6
  let(:usage) { 'FOO' }
8
- let(:default) { 'foo' }
9
7
  let(:required) { true }
10
8
  let(:repeats) { false }
11
9
  let(:desc) { 'Foo argument' }
12
10
 
13
11
  subject do
14
- described_class.new name, type: type,
15
- usage: usage,
16
- default: default,
12
+ described_class.new name, usage: usage,
17
13
  required: required,
18
14
  repeats: repeats,
19
15
  desc: desc
20
16
  end
21
17
 
22
18
  describe "#initialize" do
23
- context "when the type: keyword is given" do
24
- subject { described_class.new(name, type: type, desc: desc) }
25
-
26
- it "must set #type" do
27
- expect(subject.type).to eq(type)
28
- end
29
- end
30
-
31
- context "when the type: keyword is not given" do
32
- subject { described_class.new(name, desc: desc) }
33
-
34
- it "default #type to String" do
35
- expect(subject.type).to eq(String)
36
- end
37
- end
38
-
39
19
  context "when the usage: keyword is given" do
40
20
  subject { described_class.new(name, usage: usage, desc: desc) }
41
21
 
@@ -52,22 +32,6 @@ describe Arguments::Argument do
52
32
  end
53
33
  end
54
34
 
55
- context "when the default: keyword is given" do
56
- subject { described_class.new(name, default: default, desc: desc) }
57
-
58
- it "must set #default" do
59
- expect(subject.default).to eq(default)
60
- end
61
- end
62
-
63
- context "when the default: keyword is not given" do
64
- subject { described_class.new(name, desc: desc) }
65
-
66
- it "default #default to String" do
67
- expect(subject.default).to eq(nil)
68
- end
69
- end
70
-
71
35
  context "when the required: keyword is given" do
72
36
  subject { described_class.new(name, required: required, desc: desc) }
73
37
 
@@ -88,7 +52,7 @@ describe Arguments::Argument do
88
52
  subject { described_class.new(name, repeats: repeats, desc: desc) }
89
53
 
90
54
  it "must set #repeats" do
91
- expect(subject.repeats).to eq(repeats)
55
+ expect(subject.repeats?).to eq(repeats)
92
56
  end
93
57
  end
94
58
 
@@ -96,7 +60,7 @@ describe Arguments::Argument do
96
60
  subject { described_class.new(name, desc: desc) }
97
61
 
98
62
  it "default #repeats to String" do
99
- expect(subject.repeats).to eq(false)
63
+ expect(subject.repeats?).to eq(false)
100
64
  end
101
65
  end
102
66
 
@@ -162,7 +126,7 @@ describe Arguments::Argument do
162
126
  let(:repeats) { false }
163
127
 
164
128
  it "must return the usage name unchanged" do
165
- expect(subject.usage).to eq("#{usage}")
129
+ expect(subject.usage).to eq(usage)
166
130
  end
167
131
  end
168
132
  end
@@ -2,16 +2,12 @@ require 'spec_helper'
2
2
  require 'command_kit/arguments/argument_value'
3
3
 
4
4
  describe CommandKit::Arguments::ArgumentValue do
5
- let(:type) { String }
6
5
  let(:required) { false }
7
- let(:default) { "foo" }
8
6
  let(:usage) { 'FOO' }
9
7
 
10
8
  subject do
11
9
  described_class.new(
12
- type: type,
13
10
  required: required,
14
- default: default,
15
11
  usage: usage
16
12
  )
17
13
  end
@@ -19,26 +15,10 @@ describe CommandKit::Arguments::ArgumentValue do
19
15
  describe "#initialize" do
20
16
  it "must require a usage: keyword"do
21
17
  expect {
22
- described_class.new(type: type, required: required, default: default)
18
+ described_class.new(required: required)
23
19
  }.to raise_error(ArgumentError)
24
20
  end
25
21
 
26
- context "when type: is given" do
27
- subject { described_class.new(type: type, usage: usage) }
28
-
29
- it "must set #type" do
30
- expect(subject.type).to eq(type)
31
- end
32
- end
33
-
34
- context "when type: is not given" do
35
- subject { described_class.new(usage: usage) }
36
-
37
- it "must default to nil" do
38
- expect(subject.type).to be_nil
39
- end
40
- end
41
-
42
22
  context "when required: is given" do
43
23
  subject { described_class.new(required: required, usage: usage) }
44
24
 
@@ -54,22 +34,6 @@ describe CommandKit::Arguments::ArgumentValue do
54
34
  expect(subject.required).to be(true)
55
35
  end
56
36
  end
57
-
58
- context "when default: is given" do
59
- subject { described_class.new(default: default, usage: usage) }
60
-
61
- it "must set #default" do
62
- expect(subject.default).to eq(default)
63
- end
64
- end
65
-
66
- context "when default: is not given" do
67
- subject { described_class.new(usage: usage) }
68
-
69
- it "must default to nil" do
70
- expect(subject.default).to be_nil
71
- end
72
- end
73
37
  end
74
38
 
75
39
  describe "#required?" do
@@ -99,28 +63,4 @@ describe CommandKit::Arguments::ArgumentValue do
99
63
  it { expect(subject.optional?).to be(true) }
100
64
  end
101
65
  end
102
-
103
- describe "#default_value" do
104
- context "when initialized with a default: that responded to #call" do
105
- let(:default) do
106
- ->{ [] }
107
- end
108
-
109
- it "must call the default #call method" do
110
- expect(subject.default_value).to eq(default.call)
111
- end
112
- end
113
-
114
- context "when initialized with a default: that it's an Object" do
115
- let(:default) { "" }
116
-
117
- it "must return the default: object" do
118
- expect(subject.default_value).to eq(default)
119
- end
120
-
121
- it "must duplicate the default: object each time" do
122
- expect(subject.default_value).to_not be(subject.default_value)
123
- end
124
- end
125
- end
126
66
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
  require 'command_kit/arguments'
3
3
 
4
- describe Arguments do
4
+ describe CommandKit::Arguments do
5
5
  module TestArguments
6
6
  class ImplicitCmd
7
7
  include CommandKit::Arguments
@@ -10,6 +10,13 @@ describe Arguments do
10
10
 
11
11
  let(:command_class) { TestArguments::ImplicitCmd }
12
12
 
13
+ describe ".included" do
14
+ subject { command_class }
15
+
16
+ it { expect(subject).to include(CommandKit::Main) }
17
+ it { expect(subject).to include(CommandKit::Help) }
18
+ end
19
+
13
20
  describe ".arguments" do
14
21
  subject { TestArguments::ImplicitCmd }
15
22
 
@@ -185,29 +192,5 @@ describe Arguments do
185
192
 
186
193
  subject.help
187
194
  end
188
-
189
- context "when the superclass defines it's own #help method" do
190
- module TestDescription
191
- class SuperclassHelpMethod
192
- def help
193
- puts 'superclass'
194
- end
195
- end
196
-
197
- class InheritedHelpMethod < SuperclassHelpMethod
198
- include CommandKit::Arguments
199
- end
200
- end
201
-
202
- let(:super_command_class) { TestDescription::SuperclassHelpMethod }
203
- let(:command_class) { TestDescription::InheritedHelpMethod }
204
-
205
- it "must call the superclass'es #help method first" do
206
- expect_any_instance_of(super_command_class).to receive(:help)
207
- expect(subject).to receive(:help_arguments)
208
-
209
- subject.help
210
- end
211
- end
212
195
  end
213
196
  end
data/spec/colors_spec.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
  require 'command_kit/colors'
3
3
 
4
- describe Colors do
4
+ describe CommandKit::Colors do
5
5
  module TestColors
6
6
  class TestCommand
7
7
  include CommandKit::Colors
@@ -11,10 +11,10 @@ describe Colors do
11
11
  let(:command_class) { TestColors::TestCommand }
12
12
  subject { command_class.new }
13
13
 
14
- it { expect(described_class).to include(Stdio) }
15
- it { expect(described_class).to include(Env) }
14
+ it { expect(described_class).to include(CommandKit::Stdio) }
15
+ it { expect(described_class).to include(CommandKit::Env) }
16
16
 
17
- describe Colors::ANSI do
17
+ describe CommandKit::Colors::ANSI do
18
18
  subject { described_class }
19
19
 
20
20
  describe "RESET" do
@@ -65,6 +65,38 @@ describe Colors do
65
65
  it { expect(subject::WHITE).to eq("\e[37m") }
66
66
  end
67
67
 
68
+ describe "ON_BLACK" do
69
+ it { expect(subject::ON_BLACK).to eq("\e[40m") }
70
+ end
71
+
72
+ describe "ON_RED" do
73
+ it { expect(subject::ON_RED).to eq("\e[41m") }
74
+ end
75
+
76
+ describe "ON_GREEN" do
77
+ it { expect(subject::ON_GREEN).to eq("\e[42m") }
78
+ end
79
+
80
+ describe "ON_YELLOW" do
81
+ it { expect(subject::ON_YELLOW).to eq("\e[43m") }
82
+ end
83
+
84
+ describe "ON_BLUE" do
85
+ it { expect(subject::ON_BLUE).to eq("\e[44m") }
86
+ end
87
+
88
+ describe "ON_MAGENTA" do
89
+ it { expect(subject::ON_MAGENTA).to eq("\e[45m") }
90
+ end
91
+
92
+ describe "ON_CYAN" do
93
+ it { expect(subject::ON_CYAN).to eq("\e[46m") }
94
+ end
95
+
96
+ describe "ON_WHITE" do
97
+ it { expect(subject::ON_WHITE).to eq("\e[47m") }
98
+ end
99
+
68
100
  describe "RESET_COLOR" do
69
101
  it { expect(subject::RESET_COLOR).to eq("\e[39m") }
70
102
  end
@@ -186,9 +218,105 @@ describe Colors do
186
218
  it { expect(subject.white).to eq("\e[37m") }
187
219
  end
188
220
  end
221
+
222
+ describe ".on_black" do
223
+ context "when given a string" do
224
+ it "must wrap the string with \\e[40m and \\e[39m" do
225
+ expect(subject.on_black(str)).to eq("\e[40m#{str}\e[49m")
226
+ end
227
+ end
228
+
229
+ context "when given no arguments" do
230
+ it { expect(subject.on_black).to eq("\e[40m") }
231
+ end
232
+ end
233
+
234
+ describe ".on_red" do
235
+ context "when given a string" do
236
+ it "must wrap the string with \\e[41m and \\e[39m" do
237
+ expect(subject.on_red(str)).to eq("\e[41m#{str}\e[49m")
238
+ end
239
+ end
240
+
241
+ context "when given no arguments" do
242
+ it { expect(subject.on_red).to eq("\e[41m") }
243
+ end
244
+ end
245
+
246
+ describe ".on_green" do
247
+ context "when given a string" do
248
+ it "must wrap the string with \\e[42m and \\e[39m" do
249
+ expect(subject.on_green(str)).to eq("\e[42m#{str}\e[49m")
250
+ end
251
+ end
252
+
253
+ context "when given no arguments" do
254
+ it { expect(subject.on_green).to eq("\e[42m") }
255
+ end
256
+ end
257
+
258
+ describe ".on_yellow" do
259
+ context "when given a string" do
260
+ it "must wrap the string with \\e[43m and \\e[39m" do
261
+ expect(subject.on_yellow(str)).to eq("\e[43m#{str}\e[49m")
262
+ end
263
+ end
264
+
265
+ context "when given no arguments" do
266
+ it { expect(subject.on_yellow).to eq("\e[43m") }
267
+ end
268
+ end
269
+
270
+ describe ".on_blue" do
271
+ context "when given a string" do
272
+ it "must wrap the string with \\e[44m and \\e[39m" do
273
+ expect(subject.on_blue(str)).to eq("\e[44m#{str}\e[49m")
274
+ end
275
+ end
276
+
277
+ context "when given no arguments" do
278
+ it { expect(subject.on_blue).to eq("\e[44m") }
279
+ end
280
+ end
281
+
282
+ describe ".on_magenta" do
283
+ context "when given a string" do
284
+ it "must wrap the string with \\e[45m and \\e[39m" do
285
+ expect(subject.on_magenta(str)).to eq("\e[45m#{str}\e[49m")
286
+ end
287
+ end
288
+
289
+ context "when given no arguments" do
290
+ it { expect(subject.on_magenta).to eq("\e[45m") }
291
+ end
292
+ end
293
+
294
+ describe ".on_cyan" do
295
+ context "when given a string" do
296
+ it "must wrap the string with \\e[46m and \\e[39m" do
297
+ expect(subject.on_cyan(str)).to eq("\e[46m#{str}\e[49m")
298
+ end
299
+ end
300
+
301
+ context "when given no arguments" do
302
+ it { expect(subject.on_cyan).to eq("\e[46m") }
303
+ end
304
+ end
305
+
306
+ describe ".on_white" do
307
+ context "when given a string" do
308
+ it "must wrap the string with \\e[47m and \\e[39m" do
309
+ expect(subject.on_white(str)).to eq("\e[47m#{str}\e[49m")
310
+ end
311
+ end
312
+
313
+ context "when given no arguments" do
314
+ it { expect(subject.on_white).to eq("\e[47m") }
315
+ end
316
+ end
189
317
  end
190
318
 
191
- describe Colors::PlainText do
319
+ describe CommandKit::Colors::PlainText do
192
320
  subject { described_class }
193
321
 
194
322
  let(:str) { 'foo' }
@@ -241,6 +369,38 @@ describe Colors do
241
369
  it { expect(subject::WHITE).to eq('') }
242
370
  end
243
371
 
372
+ describe "ON_BLACK" do
373
+ it { expect(subject::ON_BLACK).to eq('') }
374
+ end
375
+
376
+ describe "ON_RED" do
377
+ it { expect(subject::ON_RED).to eq('') }
378
+ end
379
+
380
+ describe "ON_GREEN" do
381
+ it { expect(subject::ON_GREEN).to eq('') }
382
+ end
383
+
384
+ describe "ON_YELLOW" do
385
+ it { expect(subject::ON_YELLOW).to eq('') }
386
+ end
387
+
388
+ describe "ON_BLUE" do
389
+ it { expect(subject::ON_BLUE).to eq('') }
390
+ end
391
+
392
+ describe "ON_MAGENTA" do
393
+ it { expect(subject::ON_MAGENTA).to eq('') }
394
+ end
395
+
396
+ describe "ON_CYAN" do
397
+ it { expect(subject::ON_CYAN).to eq('') }
398
+ end
399
+
400
+ describe "ON_WHITE" do
401
+ it { expect(subject::ON_WHITE).to eq('') }
402
+ end
403
+
244
404
  describe "RESET_COLOR" do
245
405
  it { expect(subject::RESET_COLOR).to eq('') }
246
406
  end
@@ -360,6 +520,102 @@ describe Colors do
360
520
  it { expect(subject.white).to eq('') }
361
521
  end
362
522
  end
523
+
524
+ describe ".on_black" do
525
+ context "when given a string" do
526
+ it "must return that string" do
527
+ expect(subject.on_black(str)).to eq(str)
528
+ end
529
+ end
530
+
531
+ context "when given no arguments" do
532
+ it { expect(subject.on_black).to eq('') }
533
+ end
534
+ end
535
+
536
+ describe ".on_red" do
537
+ context "when given a string" do
538
+ it "must return that string" do
539
+ expect(subject.on_red(str)).to eq(str)
540
+ end
541
+ end
542
+
543
+ context "when given no arguments" do
544
+ it { expect(subject.on_red).to eq('') }
545
+ end
546
+ end
547
+
548
+ describe ".on_green" do
549
+ context "when given a string" do
550
+ it "must return that string" do
551
+ expect(subject.on_green(str)).to eq(str)
552
+ end
553
+ end
554
+
555
+ context "when given no arguments" do
556
+ it { expect(subject.on_green).to eq('') }
557
+ end
558
+ end
559
+
560
+ describe ".on_yellow" do
561
+ context "when given a string" do
562
+ it "must return that string" do
563
+ expect(subject.on_yellow(str)).to eq(str)
564
+ end
565
+ end
566
+
567
+ context "when given no arguments" do
568
+ it { expect(subject.on_yellow).to eq('') }
569
+ end
570
+ end
571
+
572
+ describe ".on_blue" do
573
+ context "when given a string" do
574
+ it "must return that string" do
575
+ expect(subject.on_blue(str)).to eq(str)
576
+ end
577
+ end
578
+
579
+ context "when given no arguments" do
580
+ it { expect(subject.on_blue).to eq('') }
581
+ end
582
+ end
583
+
584
+ describe ".on_magenta" do
585
+ context "when given a string" do
586
+ it "must return that string" do
587
+ expect(subject.on_magenta(str)).to eq(str)
588
+ end
589
+ end
590
+
591
+ context "when given no arguments" do
592
+ it { expect(subject.on_magenta).to eq('') }
593
+ end
594
+ end
595
+
596
+ describe ".on_cyan" do
597
+ context "when given a string" do
598
+ it "must return that string" do
599
+ expect(subject.on_cyan(str)).to eq(str)
600
+ end
601
+ end
602
+
603
+ context "when given no arguments" do
604
+ it { expect(subject.on_cyan).to eq('') }
605
+ end
606
+ end
607
+
608
+ describe ".on_white" do
609
+ context "when given a string" do
610
+ it "must return that string" do
611
+ expect(subject.on_white(str)).to eq(str)
612
+ end
613
+ end
614
+
615
+ context "when given no arguments" do
616
+ it { expect(subject.on_white).to eq('') }
617
+ end
618
+ end
363
619
  end
364
620
 
365
621
  describe "#ansi?" do
@@ -409,13 +665,15 @@ describe Colors do
409
665
 
410
666
  before { allow(stdout).to receive(:tty?).and_return(true) }
411
667
 
412
- it { expect(subject.colors).to be(Colors::ANSI) }
668
+ it do
669
+ expect(subject.colors).to be(described_class::ANSI)
670
+ end
413
671
 
414
672
  context "when a block is given" do
415
673
  it do
416
674
  expect { |b|
417
675
  subject.colors(&b)
418
- }.to yield_with_args(Colors::ANSI)
676
+ }.to yield_with_args(described_class::ANSI)
419
677
  end
420
678
  end
421
679
  end
@@ -424,13 +682,15 @@ describe Colors do
424
682
  let(:stdout) { StringIO.new }
425
683
  subject { command_class.new(stdout: stdout) }
426
684
 
427
- it { expect(subject.colors).to be(Colors::PlainText) }
685
+ it do
686
+ expect(subject.colors).to be(described_class::PlainText)
687
+ end
428
688
 
429
689
  context "when a block is given" do
430
690
  it do
431
691
  expect { |b|
432
692
  subject.colors(&b)
433
- }.to yield_with_args(Colors::PlainText)
693
+ }.to yield_with_args(described_class::PlainText)
434
694
  end
435
695
  end
436
696
  end
@@ -441,13 +701,15 @@ describe Colors do
441
701
 
442
702
  before { allow(stream).to receive(:tty?).and_return(true) }
443
703
 
444
- it { expect(subject.colors(stream)).to be(Colors::ANSI) }
704
+ it do
705
+ expect(subject.colors(stream)).to be(described_class::ANSI)
706
+ end
445
707
 
446
708
  context "when a block is given" do
447
709
  it do
448
710
  expect { |b|
449
711
  subject.colors(stream,&b)
450
- }.to yield_with_args(Colors::ANSI)
712
+ }.to yield_with_args(described_class::ANSI)
451
713
  end
452
714
  end
453
715
  end
@@ -455,13 +717,15 @@ describe Colors do
455
717
  context "but the alternate stream does not support ANSI" do
456
718
  let(:stream) { StringIO.new }
457
719
 
458
- it { expect(subject.colors(stream)).to be(Colors::PlainText) }
720
+ it do
721
+ expect(subject.colors(stream)).to be(described_class::PlainText)
722
+ end
459
723
 
460
724
  context "when a block is given" do
461
725
  it do
462
726
  expect { |b|
463
727
  subject.colors(stream,&b)
464
- }.to yield_with_args(Colors::PlainText)
728
+ }.to yield_with_args(described_class::PlainText)
465
729
  end
466
730
  end
467
731
  end