command_kit 0.1.0.pre2 → 0.2.1

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 (98) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +15 -0
  3. data/.rubocop.yml +141 -0
  4. data/ChangeLog.md +98 -2
  5. data/Gemfile +3 -0
  6. data/README.md +189 -117
  7. data/Rakefile +3 -2
  8. data/command_kit.gemspec +4 -4
  9. data/examples/command.rb +1 -1
  10. data/gemspec.yml +10 -2
  11. data/lib/command_kit/arguments/argument.rb +2 -0
  12. data/lib/command_kit/arguments/argument_value.rb +2 -0
  13. data/lib/command_kit/arguments.rb +23 -4
  14. data/lib/command_kit/colors.rb +253 -45
  15. data/lib/command_kit/command.rb +6 -1
  16. data/lib/command_kit/command_name.rb +9 -0
  17. data/lib/command_kit/commands/auto_load.rb +24 -1
  18. data/lib/command_kit/commands/auto_require.rb +16 -0
  19. data/lib/command_kit/commands/command.rb +3 -0
  20. data/lib/command_kit/commands/help.rb +5 -2
  21. data/lib/command_kit/commands/parent_command.rb +7 -0
  22. data/lib/command_kit/commands/subcommand.rb +13 -1
  23. data/lib/command_kit/commands.rb +54 -9
  24. data/lib/command_kit/description.rb +12 -1
  25. data/lib/command_kit/env/home.rb +9 -0
  26. data/lib/command_kit/env/path.rb +16 -1
  27. data/lib/command_kit/env.rb +4 -0
  28. data/lib/command_kit/examples.rb +12 -1
  29. data/lib/command_kit/exception_handler.rb +4 -0
  30. data/lib/command_kit/help/man.rb +26 -30
  31. data/lib/command_kit/help.rb +7 -1
  32. data/lib/command_kit/inflector.rb +49 -17
  33. data/lib/command_kit/interactive.rb +248 -0
  34. data/lib/command_kit/main.rb +18 -9
  35. data/lib/command_kit/man.rb +44 -0
  36. data/lib/command_kit/open_app.rb +69 -0
  37. data/lib/command_kit/options/option.rb +3 -6
  38. data/lib/command_kit/options/option_value.rb +5 -2
  39. data/lib/command_kit/options/parser.rb +46 -19
  40. data/lib/command_kit/options/quiet.rb +3 -0
  41. data/lib/command_kit/options/verbose.rb +5 -0
  42. data/lib/command_kit/options/version.rb +6 -0
  43. data/lib/command_kit/options.rb +32 -7
  44. data/lib/command_kit/os/linux.rb +157 -0
  45. data/lib/command_kit/os.rb +165 -11
  46. data/lib/command_kit/package_manager.rb +200 -0
  47. data/lib/command_kit/pager.rb +80 -11
  48. data/lib/command_kit/printing/indent.rb +27 -4
  49. data/lib/command_kit/printing.rb +35 -1
  50. data/lib/command_kit/program_name.rb +7 -0
  51. data/lib/command_kit/stdio.rb +24 -0
  52. data/lib/command_kit/sudo.rb +40 -0
  53. data/lib/command_kit/terminal.rb +159 -0
  54. data/lib/command_kit/usage.rb +14 -0
  55. data/lib/command_kit/version.rb +1 -1
  56. data/lib/command_kit/xdg.rb +13 -0
  57. data/lib/command_kit.rb +1 -0
  58. data/spec/arguments/argument_spec.rb +2 -2
  59. data/spec/arguments_spec.rb +53 -27
  60. data/spec/colors_spec.rb +277 -13
  61. data/spec/command_name_spec.rb +1 -1
  62. data/spec/command_spec.rb +79 -5
  63. data/spec/commands/auto_load/subcommand_spec.rb +1 -1
  64. data/spec/commands/auto_load_spec.rb +34 -3
  65. data/spec/commands/auto_require_spec.rb +2 -2
  66. data/spec/commands/help_spec.rb +1 -1
  67. data/spec/commands/parent_command_spec.rb +1 -1
  68. data/spec/commands/subcommand_spec.rb +1 -1
  69. data/spec/commands_spec.rb +103 -29
  70. data/spec/description_spec.rb +1 -25
  71. data/spec/env/home_spec.rb +1 -1
  72. data/spec/env/path_spec.rb +7 -1
  73. data/spec/examples_spec.rb +1 -25
  74. data/spec/exception_handler_spec.rb +1 -1
  75. data/spec/help/man_spec.rb +45 -58
  76. data/spec/help_spec.rb +0 -25
  77. data/spec/inflector_spec.rb +71 -9
  78. data/spec/interactive_spec.rb +415 -0
  79. data/spec/main_spec.rb +7 -7
  80. data/spec/man_spec.rb +46 -0
  81. data/spec/open_app_spec.rb +85 -0
  82. data/spec/options/option_spec.rb +5 -5
  83. data/spec/options/option_value_spec.rb +56 -1
  84. data/spec/options_spec.rb +283 -1
  85. data/spec/os/linux_spec.rb +164 -0
  86. data/spec/os_spec.rb +201 -14
  87. data/spec/package_manager_spec.rb +806 -0
  88. data/spec/pager_spec.rb +76 -11
  89. data/spec/printing/indent_spec.rb +8 -6
  90. data/spec/printing_spec.rb +33 -3
  91. data/spec/program_name_spec.rb +1 -1
  92. data/spec/spec_helper.rb +0 -3
  93. data/spec/sudo_spec.rb +51 -0
  94. data/spec/{console_spec.rb → terminal_spec.rb} +65 -35
  95. data/spec/usage_spec.rb +2 -2
  96. data/spec/xdg_spec.rb +1 -1
  97. metadata +26 -8
  98. data/lib/command_kit/console.rb +0 -141
data/spec/pager_spec.rb CHANGED
@@ -3,7 +3,7 @@ require 'command_kit/pager'
3
3
 
4
4
  require 'stringio'
5
5
 
6
- describe Pager do
6
+ describe CommandKit::Pager do
7
7
  module TestPager
8
8
  class TestCommand
9
9
  include CommandKit::Pager
@@ -19,8 +19,8 @@ describe Pager do
19
19
 
20
20
  subject { command_class.new(env: {'PAGER' => pager}) }
21
21
 
22
- it "must set @pager to the PAGER env variable" do
23
- expect(subject.instance_variable_get('@pager')).to eq(pager)
22
+ it "must set @pager_command to the PAGER env variable" do
23
+ expect(subject.instance_variable_get('@pager_command')).to eq(pager)
24
24
  end
25
25
  end
26
26
 
@@ -29,7 +29,7 @@ describe Pager do
29
29
  subject { command_class.new(env: {'PATH' => ENV['PATH']}) }
30
30
 
31
31
  it "must search PATH for one of the pagers" do
32
- expect(subject.instance_variable_get('@pager')).to eq("less -r")
32
+ expect(subject.instance_variable_get('@pager_command')).to eq("less -r")
33
33
  end
34
34
  end
35
35
  end
@@ -46,9 +46,9 @@ describe Pager do
46
46
  end
47
47
  end
48
48
 
49
- context "when @pager isn't initialized" do
49
+ context "when @pager_command isn't initialized" do
50
50
  before do
51
- subject.instance_variable_set('@pager',nil)
51
+ subject.instance_variable_set('@pager_command',nil)
52
52
  end
53
53
 
54
54
  it "must yield stdout" do
@@ -58,7 +58,7 @@ describe Pager do
58
58
  end
59
59
  end
60
60
 
61
- context "when stdout is a TTY and @pager is initialized" do
61
+ context "when stdout is a TTY and @pager_command is initialized" do
62
62
  let(:pager) { 'less -r' }
63
63
 
64
64
  subject { command_class.new(env: {'PAGER' => pager}) }
@@ -95,10 +95,10 @@ describe Pager do
95
95
  end
96
96
 
97
97
  describe "#print_or_page" do
98
- let(:console_height) { 10 }
98
+ let(:terminal_height) { 10 }
99
99
 
100
100
  before do
101
- expect(subject).to receive(:console_height).and_return(console_height)
101
+ expect(subject).to receive(:terminal_height).and_return(terminal_height)
102
102
  end
103
103
 
104
104
  context "when given a String" do
@@ -113,7 +113,7 @@ describe Pager do
113
113
  end
114
114
 
115
115
  context "and the number of lines is greater than the console's height" do
116
- let(:string) { "foo#{$/}bar#{$/}" * console_height }
116
+ let(:string) { "foo#{$/}bar#{$/}" * terminal_height }
117
117
 
118
118
  it "must spawn a pager and puts the String to the pager" do
119
119
  pager = double('pager')
@@ -137,7 +137,7 @@ describe Pager do
137
137
  end
138
138
 
139
139
  context "and the number of lines is greater than the console's height" do
140
- let(:array) { ['foo', 'bar'] * console_height }
140
+ let(:array) { ['foo', 'bar'] * terminal_height }
141
141
 
142
142
  it "must spawn a pager and puts the Array of Strings to the pager" do
143
143
  pager = double('pager')
@@ -149,4 +149,69 @@ describe Pager do
149
149
  end
150
150
  end
151
151
  end
152
+
153
+ describe "#pipe_to_pager" do
154
+ context "when @pager_command is initialized" do
155
+ let(:pager) { 'less' }
156
+
157
+ subject do
158
+ command_class.new(env: {'PAGER' => pager})
159
+ end
160
+
161
+ context "and when given a single String" do
162
+ let(:command) { "find ." }
163
+
164
+ it "must run the command but piped into the pager" do
165
+ expect(subject).to receive(:system).with("#{command} | #{pager}")
166
+
167
+ subject.pipe_to_pager(command)
168
+ end
169
+ end
170
+
171
+ context "and when given a String and additional arguments" do
172
+ let(:command) { 'find' }
173
+ let(:arguments) { %w[. -name *.md] }
174
+
175
+ let(:escaped_command) do
176
+ Shellwords.shelljoin([command,*arguments])
177
+ end
178
+
179
+ it "must shell escape the command and arguments" do
180
+ expect(subject).to receive(:system).with(
181
+ "#{escaped_command} | #{pager}"
182
+ )
183
+
184
+ subject.pipe_to_pager(command,*arguments)
185
+ end
186
+ end
187
+ end
188
+
189
+ context "when @pager_command is not initialized" do
190
+ before do
191
+ subject.instance_variable_set('@pager_command',nil)
192
+ end
193
+
194
+ let(:command) { 'find' }
195
+ let(:arguments) { %w[. -name *.md] }
196
+
197
+ it "must pass the command and any additional arguments to #system" do
198
+ expect(subject).to receive(:system).with(command,*arguments)
199
+
200
+ subject.pipe_to_pager(command,*arguments)
201
+ end
202
+
203
+ context "when one of the arguments is not a String" do
204
+ let(:command) { :find }
205
+ let(:arguments) { ['.', :"-name", "*.md"] }
206
+
207
+ it "must convert the command to a String before calling #system" do
208
+ expect(subject).to receive(:system).with(
209
+ command.to_s, *arguments.map(&:to_s)
210
+ )
211
+
212
+ subject.pipe_to_pager(command,*arguments)
213
+ end
214
+ end
215
+ end
216
+ end
152
217
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
  require 'command_kit/printing/indent'
3
3
 
4
- describe Printing::Indent do
4
+ describe CommandKit::Printing::Indent do
5
5
  module TestIndent
6
6
  class TestCommand
7
7
  include CommandKit::Printing::Indent
@@ -12,14 +12,16 @@ describe Printing::Indent do
12
12
  subject { command_class.new }
13
13
 
14
14
  describe "#initialize" do
15
- it "must initialize @indent to 0" do
16
- expect(subject.instance_variable_get('@indent')).to eq(0)
15
+ it "must initialize #indent to 0" do
16
+ expect(subject.indent).to eq(0)
17
17
  end
18
18
 
19
19
  context "when the class has a superclass" do
20
20
  module TestIndent
21
21
  class TestSuperCommand
22
22
 
23
+ attr_reader :var
24
+
23
25
  def initialize(var: 'default')
24
26
  @var = var
25
27
  end
@@ -36,11 +38,11 @@ describe Printing::Indent do
36
38
  let(:command_class) { TestIndent::TestSubCommand }
37
39
 
38
40
  it "must initialize @indent to 0" do
39
- expect(subject.instance_variable_get('@indent')).to eq(0)
41
+ expect(subject.indent).to eq(0)
40
42
  end
41
43
 
42
44
  it "must call super()" do
43
- expect(subject.instance_variable_get('@var')).to eq('default')
45
+ expect(subject.var).to eq('default')
44
46
  end
45
47
 
46
48
  context "and additional keyword arguments are given" do
@@ -49,7 +51,7 @@ describe Printing::Indent do
49
51
  subject { command_class.new(var: var) }
50
52
 
51
53
  it "must call super() with the additional keyword arguments" do
52
- expect(subject.instance_variable_get('@var')).to eq(var)
54
+ expect(subject.var).to eq(var)
53
55
  end
54
56
  end
55
57
  end
@@ -1,9 +1,10 @@
1
1
  require 'spec_helper'
2
2
  require 'command_kit/printing'
3
+ require 'command_kit/command_name'
3
4
 
4
5
  require 'stringio'
5
6
 
6
- describe Printing do
7
+ describe CommandKit::Printing do
7
8
  module TestPrinting
8
9
  class TestCmd
9
10
 
@@ -14,11 +15,19 @@ describe Printing do
14
15
 
15
16
  let(:command_class) { TestPrinting::TestCmd }
16
17
  subject { command_class.new }
18
+
19
+ describe "EOL" do
20
+ subject { described_class::EOL }
21
+
22
+ it "must equal $/" do
23
+ expect(subject).to eq($/)
24
+ end
25
+ end
17
26
 
18
27
  describe ".included" do
19
28
  subject { command_class }
20
29
 
21
- it { expect(command_class).to include(Stdio) }
30
+ it { expect(command_class).to include(CommandKit::Stdio) }
22
31
  end
23
32
 
24
33
  let(:nl) { $/ }
@@ -26,11 +35,32 @@ describe Printing do
26
35
  describe "#print_error" do
27
36
  let(:message) { "oh no!" }
28
37
 
29
- it "must print a line to stderr" do
38
+ it "must print the error message to stderr" do
30
39
  expect {
31
40
  subject.print_error(message)
32
41
  }.to output("#{message}#{nl}").to_stderr
33
42
  end
43
+
44
+ context "and when CommandKit::CommandName is included" do
45
+ module TestPrinting
46
+ class TestCmdWithCommandName
47
+
48
+ include CommandKit::CommandName
49
+ include CommandKit::Printing
50
+
51
+ command_name 'foo'
52
+
53
+ end
54
+ end
55
+
56
+ let(:command_class) { TestPrinting::TestCmdWithCommandName }
57
+
58
+ it "must print the command_name and the error message" do
59
+ expect {
60
+ subject.print_error(message)
61
+ }.to output("#{subject.command_name}: #{message}#{nl}").to_stderr
62
+ end
63
+ end
34
64
  end
35
65
 
36
66
  describe "#print_exception" do
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
  require 'command_kit/program_name'
3
3
 
4
- describe ProgramName do
4
+ describe CommandKit::ProgramName do
5
5
  module TestProgramName
6
6
  class TestCmd
7
7
  include CommandKit::ProgramName
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,3 @@
1
1
  require 'rspec'
2
2
  require 'simplecov'
3
3
  SimpleCov.start
4
-
5
- require 'command_kit/version'
6
- include CommandKit
data/spec/sudo_spec.rb ADDED
@@ -0,0 +1,51 @@
1
+ require 'spec_helper'
2
+ require 'command_kit/sudo'
3
+
4
+ describe CommandKit::Sudo do
5
+ module TestSudo
6
+ class TestCommand
7
+ include CommandKit::Sudo
8
+ end
9
+ end
10
+
11
+ let(:command_class) { TestSudo::TestCommand }
12
+ subject { command_class.new }
13
+
14
+ describe "#sudo" do
15
+ let(:command) { "ls" }
16
+ let(:arguments) { ["-la", "~root"] }
17
+ let(:status) { double(:status) }
18
+
19
+ context "on UNIX" do
20
+ context "when the UID is 0" do
21
+ before { allow(Process).to receive(:uid).and_return(0) }
22
+
23
+ it "must execute the command without sudo" do
24
+ expect(subject).to receive(:system).with(command,*arguments).and_return(status)
25
+
26
+ expect(subject.sudo(command,*arguments)).to be(status)
27
+ end
28
+ end
29
+
30
+ context "when the UID is not 0" do
31
+ before { allow(Process).to receive(:uid).and_return(1000) }
32
+
33
+ it "must execute the command with 'sudo ...'" do
34
+ expect(subject).to receive(:system).with('sudo',command,*arguments).and_return(status)
35
+
36
+ expect(subject.sudo(command,*arguments)).to be(status)
37
+ end
38
+ end
39
+ end
40
+
41
+ context "on Windows" do
42
+ subject { command_class.new(os: :windows) }
43
+
44
+ it "must execute the command with 'runas /user:administrator ...'" do
45
+ expect(subject).to receive(:system).with('runas','/user:administrator',command,*arguments).and_return(status)
46
+
47
+ expect(subject.sudo(command,*arguments)).to be(status)
48
+ end
49
+ end
50
+ end
51
+ end
@@ -1,26 +1,26 @@
1
1
  require 'spec_helper'
2
- require 'command_kit/console'
2
+ require 'command_kit/terminal'
3
3
 
4
4
  require 'stringio'
5
5
 
6
- describe Console do
7
- module TestConsole
6
+ describe CommandKit::Terminal do
7
+ module TestTerminal
8
8
  class TestCommand
9
- include CommandKit::Console
9
+ include CommandKit::Terminal
10
10
  end
11
11
  end
12
12
 
13
- let(:command_class) { TestConsole::TestCommand }
13
+ let(:command_class) { TestTerminal::TestCommand }
14
14
  subject { command_class.new }
15
15
 
16
- describe "#console?" do
16
+ describe "#terminal?" do
17
17
  context "when stdout is connected to a TTY" do
18
18
  subject { command_class.new(stdout: STDOUT) }
19
19
 
20
20
  it do
21
21
  skip "STDOUT is not a TTY" unless STDOUT.tty?
22
22
 
23
- expect(subject.console?).to be(true)
23
+ expect(subject.terminal?).to be(true)
24
24
  end
25
25
  end
26
26
 
@@ -28,7 +28,7 @@ describe Console do
28
28
  subject { command_class.new(stdout: StringIO.new) }
29
29
 
30
30
  it do
31
- expect(subject.console?).to be(false)
31
+ expect(subject.terminal?).to be(false)
32
32
  end
33
33
  end
34
34
 
@@ -38,19 +38,19 @@ describe Console do
38
38
  end
39
39
 
40
40
  it do
41
- expect(subject.console?).to be(false)
41
+ expect(subject.terminal?).to be(false)
42
42
  end
43
43
  end
44
44
  end
45
45
 
46
- describe "#console" do
46
+ describe "#tty?" do
47
47
  context "when stdout is connected to a TTY" do
48
48
  subject { command_class.new(stdout: STDOUT) }
49
49
 
50
50
  it do
51
51
  skip "STDOUT is not a TTY" unless STDOUT.tty?
52
52
 
53
- expect(subject.console).to eq(IO.console)
53
+ expect(subject.tty?).to be(true)
54
54
  end
55
55
  end
56
56
 
@@ -58,7 +58,7 @@ describe Console do
58
58
  subject { command_class.new(stdout: StringIO.new) }
59
59
 
60
60
  it do
61
- expect(subject.console).to eq(nil)
61
+ expect(subject.tty?).to be(false)
62
62
  end
63
63
  end
64
64
 
@@ -68,27 +68,57 @@ describe Console do
68
68
  end
69
69
 
70
70
  it do
71
- expect(subject.console).to be(nil)
71
+ expect(subject.tty?).to be(false)
72
72
  end
73
73
  end
74
74
  end
75
75
 
76
- describe "#console_height" do
76
+ describe "#terminal" do
77
77
  context "when stdout is connected to a TTY" do
78
78
  subject { command_class.new(stdout: STDOUT) }
79
79
 
80
80
  it do
81
81
  skip "STDOUT is not a TTY" unless STDOUT.tty?
82
82
 
83
- expect(subject.console_height).to eq(STDOUT.winsize[0])
83
+ expect(subject.terminal).to eq(IO.console)
84
84
  end
85
85
  end
86
86
 
87
87
  context "when stdout is not connected to a TTY" do
88
88
  subject { command_class.new(stdout: StringIO.new) }
89
89
 
90
- it "must fallback to DEFAULT_HEIGHT" do
91
- expect(subject.console_height).to eq(described_class::DEFAULT_HEIGHT)
90
+ it do
91
+ expect(subject.terminal).to eq(nil)
92
+ end
93
+ end
94
+
95
+ context "when IO.console is missing" do
96
+ before do
97
+ expect(IO).to receive(:respond_to?).with(:console).and_return(false)
98
+ end
99
+
100
+ it do
101
+ expect(subject.terminal).to be(nil)
102
+ end
103
+ end
104
+ end
105
+
106
+ describe "#terminal_height" do
107
+ context "when stdout is connected to a TTY" do
108
+ subject { command_class.new(stdout: STDOUT) }
109
+
110
+ it do
111
+ skip "STDOUT is not a TTY" unless STDOUT.tty?
112
+
113
+ expect(subject.terminal_height).to eq(STDOUT.winsize[0])
114
+ end
115
+ end
116
+
117
+ context "when stdout is not connected to a TTY" do
118
+ subject { command_class.new(stdout: StringIO.new) }
119
+
120
+ it "must fallback to DEFAULT_TERMINAL_HEIGHT" do
121
+ expect(subject.terminal_height).to eq(described_class::DEFAULT_TERMINAL_HEIGHT)
92
122
  end
93
123
 
94
124
  context "but the LINES env variable was set" do
@@ -98,28 +128,28 @@ describe Console do
98
128
  subject { command_class.new(stdout: StringIO.new, env: env) }
99
129
 
100
130
  it "must fallback to the LINES environment variable" do
101
- expect(subject.console_height).to eq(lines)
131
+ expect(subject.terminal_height).to eq(lines)
102
132
  end
103
133
  end
104
134
  end
105
135
  end
106
136
 
107
- describe "#console_width" do
137
+ describe "#terminal_width" do
108
138
  context "when stdout is connected to a TTY" do
109
139
  subject { command_class.new(stdout: STDOUT) }
110
140
 
111
141
  it do
112
142
  skip "STDOUT is not a TTY" unless STDOUT.tty?
113
143
 
114
- expect(subject.console_width).to eq(STDOUT.winsize[1])
144
+ expect(subject.terminal_width).to eq(STDOUT.winsize[1])
115
145
  end
116
146
  end
117
147
 
118
148
  context "when stdout is not connected to a TTY" do
119
149
  subject { command_class.new(stdout: StringIO.new) }
120
150
 
121
- it "must fallback to DEFAULT_WIDTH" do
122
- expect(subject.console_width).to eq(described_class::DEFAULT_WIDTH)
151
+ it "must fallback to DEFAULT_TERMINAL_WIDTH" do
152
+ expect(subject.terminal_width).to eq(described_class::DEFAULT_TERMINAL_WIDTH)
123
153
  end
124
154
 
125
155
  context "but the COLUMNS env variable was set" do
@@ -129,29 +159,29 @@ describe Console do
129
159
  subject { command_class.new(stdout: StringIO.new, env: env) }
130
160
 
131
161
  it "must fallback to the COLUMNS environment variable" do
132
- expect(subject.console_width).to eq(columns)
162
+ expect(subject.terminal_width).to eq(columns)
133
163
  end
134
164
  end
135
165
  end
136
166
  end
137
167
 
138
- describe "#console_size" do
168
+ describe "#terminal_size" do
139
169
  context "when stdout is connected to a TTY" do
140
170
  subject { command_class.new(stdout: STDOUT) }
141
171
 
142
172
  it do
143
173
  skip "STDOUT is not a TTY" unless STDOUT.tty?
144
174
 
145
- expect(subject.console_size).to eq(STDOUT.winsize)
175
+ expect(subject.terminal_size).to eq(STDOUT.winsize)
146
176
  end
147
177
  end
148
178
 
149
179
  context "when stdout is not connected to a TTY" do
150
180
  subject { command_class.new(stdout: StringIO.new) }
151
181
 
152
- it "must fallback to [DEFAULT_HEIGHT, DEFAULT_WIDTH]" do
153
- expect(subject.console_size).to eq(
154
- [described_class::DEFAULT_HEIGHT, described_class::DEFAULT_WIDTH]
182
+ it "must fallback to [DEFAULT_TERMINAL_HEIGHT, DEFAULT_TERMINAL_WIDTH]" do
183
+ expect(subject.terminal_size).to eq(
184
+ [described_class::DEFAULT_TERMINAL_HEIGHT, described_class::DEFAULT_TERMINAL_WIDTH]
155
185
  )
156
186
  end
157
187
 
@@ -161,9 +191,9 @@ describe Console do
161
191
 
162
192
  subject { command_class.new(stdout: StringIO.new, env: env) }
163
193
 
164
- it "must fallback to the [$LINES, DEFAULT_WIDTH]" do
165
- expect(subject.console_size).to eq(
166
- [lines, described_class::DEFAULT_WIDTH]
194
+ it "must fallback to the [$LINES, DEFAULT_TERMINAL_WIDTH]" do
195
+ expect(subject.terminal_size).to eq(
196
+ [lines, described_class::DEFAULT_TERMINAL_WIDTH]
167
197
  )
168
198
  end
169
199
  end
@@ -174,9 +204,9 @@ describe Console do
174
204
 
175
205
  subject { command_class.new(stdout: StringIO.new, env: env) }
176
206
 
177
- it "must fallback to the [DEFAULT_HEIGHT, COLUMNS]" do
178
- expect(subject.console_size).to eq(
179
- [described_class::DEFAULT_HEIGHT, columns]
207
+ it "must fallback to the [DEFAULT_TERMINAL_HEIGHT, COLUMNS]" do
208
+ expect(subject.terminal_size).to eq(
209
+ [described_class::DEFAULT_TERMINAL_HEIGHT, columns]
180
210
  )
181
211
  end
182
212
  end
@@ -191,7 +221,7 @@ describe Console do
191
221
  subject { command_class.new(stdout: StringIO.new, env: env) }
192
222
 
193
223
  it "must fallback to the [LINES, COLUMNS]" do
194
- expect(subject.console_size).to eq(
224
+ expect(subject.terminal_size).to eq(
195
225
  [lines, columns]
196
226
  )
197
227
  end
data/spec/usage_spec.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
  require 'command_kit/usage'
3
3
 
4
- describe Usage do
4
+ describe CommandKit::Usage do
5
5
  module TestUsage
6
6
  class ImplicitCmd
7
7
  include CommandKit::Usage
@@ -182,7 +182,7 @@ describe Usage do
182
182
  [
183
183
  "#{subject.command_name} #{command_class.usage[0]}",
184
184
  "#{subject.command_name} #{command_class.usage[1]}",
185
- "#{subject.command_name} #{command_class.usage[2]}",
185
+ "#{subject.command_name} #{command_class.usage[2]}"
186
186
  ]
187
187
  )
188
188
  end
data/spec/xdg_spec.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
  require 'command_kit/xdg'
3
3
 
4
- describe XDG do
4
+ describe CommandKit::XDG do
5
5
  module TestXDG
6
6
  class TestCommand
7
7
  include CommandKit::XDG