command_kit 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog.md +6 -0
- data/README.md +3 -0
- data/command_kit.gemspec +7 -2
- data/lib/command_kit/completion/install.rb +276 -0
- data/lib/command_kit/env/prefix.rb +41 -0
- data/lib/command_kit/env/shell.rb +58 -0
- data/lib/command_kit/version.rb +1 -1
- metadata +4 -64
- data/spec/arguments/argument_spec.rb +0 -133
- data/spec/arguments/argument_value_spec.rb +0 -66
- data/spec/arguments_spec.rb +0 -279
- data/spec/bug_report_spec.rb +0 -266
- data/spec/colors_spec.rb +0 -771
- data/spec/command_kit_spec.rb +0 -8
- data/spec/command_name_spec.rb +0 -130
- data/spec/command_spec.rb +0 -123
- data/spec/commands/auto_load/subcommand_spec.rb +0 -82
- data/spec/commands/auto_load_spec.rb +0 -159
- data/spec/commands/auto_require_spec.rb +0 -142
- data/spec/commands/fixtures/test_auto_load/cli/commands/test1.rb +0 -10
- data/spec/commands/fixtures/test_auto_load/cli/commands/test2.rb +0 -10
- data/spec/commands/fixtures/test_auto_require/lib/test_auto_require/cli/commands/test1.rb +0 -10
- data/spec/commands/help_spec.rb +0 -66
- data/spec/commands/parent_command_spec.rb +0 -40
- data/spec/commands/subcommand_spec.rb +0 -99
- data/spec/commands_spec.rb +0 -865
- data/spec/description_spec.rb +0 -179
- data/spec/edit_spec.rb +0 -72
- data/spec/env/home_spec.rb +0 -46
- data/spec/env/path_spec.rb +0 -84
- data/spec/env_spec.rb +0 -123
- data/spec/examples_spec.rb +0 -211
- data/spec/exception_handler_spec.rb +0 -103
- data/spec/file_utils_spec.rb +0 -59
- data/spec/fixtures/template.erb +0 -5
- data/spec/help/man_spec.rb +0 -345
- data/spec/help_spec.rb +0 -94
- data/spec/inflector_spec.rb +0 -166
- data/spec/interactive_spec.rb +0 -415
- data/spec/main_spec.rb +0 -179
- data/spec/man_spec.rb +0 -46
- data/spec/open_app_spec.rb +0 -85
- data/spec/options/option_spec.rb +0 -343
- data/spec/options/option_value_spec.rb +0 -171
- data/spec/options/parser_spec.rb +0 -274
- data/spec/options/quiet_spec.rb +0 -51
- data/spec/options/verbose_spec.rb +0 -51
- data/spec/options/version_spec.rb +0 -146
- data/spec/options_spec.rb +0 -465
- data/spec/os/linux_spec.rb +0 -164
- data/spec/os_spec.rb +0 -233
- data/spec/package_manager_spec.rb +0 -806
- data/spec/pager_spec.rb +0 -217
- data/spec/printing/fields_spec.rb +0 -167
- data/spec/printing/indent_spec.rb +0 -132
- data/spec/printing/lists_spec.rb +0 -99
- data/spec/printing/tables/border_style.rb +0 -43
- data/spec/printing/tables/cell_builer_spec.rb +0 -135
- data/spec/printing/tables/row_builder_spec.rb +0 -165
- data/spec/printing/tables/style_spec.rb +0 -377
- data/spec/printing/tables/table_builder_spec.rb +0 -252
- data/spec/printing/tables/table_formatter_spec.rb +0 -1190
- data/spec/printing/tables_spec.rb +0 -1069
- data/spec/printing_spec.rb +0 -106
- data/spec/program_name_spec.rb +0 -70
- data/spec/spec_helper.rb +0 -3
- data/spec/stdio_spec.rb +0 -264
- data/spec/sudo_spec.rb +0 -51
- data/spec/terminal_spec.rb +0 -231
- data/spec/usage_spec.rb +0 -237
- data/spec/xdg_spec.rb +0 -191
@@ -1,806 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'command_kit/package_manager'
|
3
|
-
|
4
|
-
describe CommandKit::PackageManager do
|
5
|
-
module TestPackageManager
|
6
|
-
class TestCommand
|
7
|
-
include CommandKit::PackageManager
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
let(:command_class) { TestPackageManager::TestCommand }
|
12
|
-
subject { command_class.new }
|
13
|
-
|
14
|
-
describe "#initialize" do
|
15
|
-
context "when no package_manager: keyword is given" do
|
16
|
-
context "and when the OS is macOS" do
|
17
|
-
subject { command_class.new(os: :macos) }
|
18
|
-
|
19
|
-
context "and the brew command is detected" do
|
20
|
-
before do
|
21
|
-
expect_any_instance_of(command_class).to receive(:command_installed?).with('brew').and_return(true)
|
22
|
-
end
|
23
|
-
|
24
|
-
it "must set #package_manager to :brew" do
|
25
|
-
expect(subject.package_manager).to eq(:brew)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
context "but the port command is detected instead" do
|
30
|
-
before do
|
31
|
-
expect_any_instance_of(command_class).to receive(:command_installed?).with('brew').and_return(false)
|
32
|
-
expect_any_instance_of(command_class).to receive(:command_installed?).with('port').and_return(true)
|
33
|
-
end
|
34
|
-
|
35
|
-
it "must set #package_manager to :port" do
|
36
|
-
expect(subject.package_manager).to eq(:port)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
context "if no package manager command can be detected" do
|
41
|
-
before do
|
42
|
-
expect_any_instance_of(command_class).to receive(:command_installed?).with('brew').and_return(false)
|
43
|
-
expect_any_instance_of(command_class).to receive(:command_installed?).with('port').and_return(false)
|
44
|
-
end
|
45
|
-
|
46
|
-
it "must set #package_manager to nil" do
|
47
|
-
expect(subject.package_manager).to be(nil)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
context "and when the OS is Linux" do
|
53
|
-
context "and the Linux Distro is RedHat based" do
|
54
|
-
subject { command_class.new(os: :linux, linux_distro: :redhat) }
|
55
|
-
|
56
|
-
context "and the dnf command is detected" do
|
57
|
-
before do
|
58
|
-
expect_any_instance_of(command_class).to receive(:command_installed?).with('dnf').and_return(true)
|
59
|
-
end
|
60
|
-
|
61
|
-
it "must set #package_manager to :dnf" do
|
62
|
-
expect(subject.package_manager).to eq(:dnf)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
context "but the yum command is detected instead" do
|
67
|
-
before do
|
68
|
-
expect_any_instance_of(command_class).to receive(:command_installed?).with('dnf').and_return(false)
|
69
|
-
expect_any_instance_of(command_class).to receive(:command_installed?).with('yum').and_return(true)
|
70
|
-
end
|
71
|
-
|
72
|
-
it "must set #package_manager to :yum" do
|
73
|
-
expect(subject.package_manager).to eq(:yum)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
context "if no package manager command can be detected" do
|
78
|
-
before do
|
79
|
-
expect_any_instance_of(command_class).to receive(:command_installed?).with('dnf').and_return(false)
|
80
|
-
expect_any_instance_of(command_class).to receive(:command_installed?).with('yum').and_return(false)
|
81
|
-
end
|
82
|
-
|
83
|
-
it "must set #package_manager to nil" do
|
84
|
-
expect(subject.package_manager).to be(nil)
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
context "and the Linux Distro is Debian based" do
|
90
|
-
subject { command_class.new(os: :linux, linux_distro: :debian) }
|
91
|
-
|
92
|
-
context "and the apt command is detected" do
|
93
|
-
before do
|
94
|
-
expect_any_instance_of(command_class).to receive(:command_installed?).with('apt').and_return(true)
|
95
|
-
end
|
96
|
-
|
97
|
-
it "must set #package_manager to :apt" do
|
98
|
-
expect(subject.package_manager).to eq(:apt)
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
context "if no package manager command can be detected" do
|
103
|
-
before do
|
104
|
-
expect_any_instance_of(command_class).to receive(:command_installed?).with('apt').and_return(false)
|
105
|
-
end
|
106
|
-
|
107
|
-
it "must set #package_manager to nil" do
|
108
|
-
expect(subject.package_manager).to be(nil)
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
context "and the Linux Distro is SUSE based" do
|
114
|
-
subject { command_class.new(os: :linux, linux_distro: :suse) }
|
115
|
-
|
116
|
-
context "and the zypper command is detected" do
|
117
|
-
before do
|
118
|
-
expect_any_instance_of(command_class).to receive(:command_installed?).with('zypper').and_return(true)
|
119
|
-
end
|
120
|
-
|
121
|
-
it "must set #package_manager to :zypper" do
|
122
|
-
expect(subject.package_manager).to eq(:zypper)
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
context "if no package manager command can be detected" do
|
127
|
-
before do
|
128
|
-
expect_any_instance_of(command_class).to receive(:command_installed?).with('zypper').and_return(false)
|
129
|
-
end
|
130
|
-
|
131
|
-
it "must set #package_manager to nil" do
|
132
|
-
expect(subject.package_manager).to be(nil)
|
133
|
-
end
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
context "and the Linux Distro is Arch" do
|
138
|
-
subject { command_class.new(os: :linux, linux_distro: :arch) }
|
139
|
-
|
140
|
-
context "and the pacman command is detected" do
|
141
|
-
before do
|
142
|
-
expect_any_instance_of(command_class).to receive(:command_installed?).with('pacman').and_return(true)
|
143
|
-
end
|
144
|
-
|
145
|
-
it "must set #package_manager to :pacman" do
|
146
|
-
expect(subject.package_manager).to eq(:pacman)
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
context "if no package manager command can be detected" do
|
151
|
-
before do
|
152
|
-
expect_any_instance_of(command_class).to receive(:command_installed?).with('pacman').and_return(false)
|
153
|
-
end
|
154
|
-
|
155
|
-
it "must set #package_manager to nil" do
|
156
|
-
expect(subject.package_manager).to be(nil)
|
157
|
-
end
|
158
|
-
end
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
context "and when the OS is FreeBSD" do
|
163
|
-
subject { command_class.new(os: :freebsd) }
|
164
|
-
|
165
|
-
context "and the pkg command is detected" do
|
166
|
-
before do
|
167
|
-
expect_any_instance_of(command_class).to receive(:command_installed?).with('pkg').and_return(true)
|
168
|
-
end
|
169
|
-
|
170
|
-
it "must set #package_manager to :pkg" do
|
171
|
-
expect(subject.package_manager).to eq(:pkg)
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
|
-
context "if no package manager command can be detected" do
|
176
|
-
before do
|
177
|
-
expect_any_instance_of(command_class).to receive(:command_installed?).with('pkg').and_return(false)
|
178
|
-
end
|
179
|
-
|
180
|
-
it "must set #package_manager to nil" do
|
181
|
-
expect(subject.package_manager).to be(nil)
|
182
|
-
end
|
183
|
-
end
|
184
|
-
end
|
185
|
-
|
186
|
-
context "and when the OS is OpenBSD" do
|
187
|
-
subject { command_class.new(os: :openbsd) }
|
188
|
-
|
189
|
-
context "and the pkg command is detected" do
|
190
|
-
before do
|
191
|
-
expect_any_instance_of(command_class).to receive(:command_installed?).with('pkg_add').and_return(true)
|
192
|
-
end
|
193
|
-
|
194
|
-
it "must set #package_manager to :pkg_add" do
|
195
|
-
expect(subject.package_manager).to eq(:pkg_add)
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
context "if no package manager command can be detected" do
|
200
|
-
before do
|
201
|
-
expect_any_instance_of(command_class).to receive(:command_installed?).with('pkg_add').and_return(false)
|
202
|
-
end
|
203
|
-
|
204
|
-
it "must set #package_manager to nil" do
|
205
|
-
expect(subject.package_manager).to be(nil)
|
206
|
-
end
|
207
|
-
end
|
208
|
-
end
|
209
|
-
|
210
|
-
context "but the OS could not be determined" do
|
211
|
-
subject { command_class.new(os: nil) }
|
212
|
-
|
213
|
-
it "must set #package_manager to nil" do
|
214
|
-
expect(subject.package_manager).to be(nil)
|
215
|
-
end
|
216
|
-
end
|
217
|
-
end
|
218
|
-
|
219
|
-
context "when given package_manager: keyword" do
|
220
|
-
let(:package_manager) { :pkg_add }
|
221
|
-
|
222
|
-
subject { command_class.new(package_manager: package_manager) }
|
223
|
-
|
224
|
-
it "must set #package_manager" do
|
225
|
-
expect(subject.package_manager).to eq(package_manager)
|
226
|
-
end
|
227
|
-
end
|
228
|
-
end
|
229
|
-
|
230
|
-
describe "#install_packages" do
|
231
|
-
context "when the #package_manager is :apt" do
|
232
|
-
subject { command_class.new(package_manager: :apt) }
|
233
|
-
|
234
|
-
context "and when arguments are given" do
|
235
|
-
let(:packages) { ["foo", "bar", "baz"] }
|
236
|
-
|
237
|
-
it "must run `sudo apt install ...` with the package names" do
|
238
|
-
expect(subject).to receive(:sudo).with("apt","install",*packages)
|
239
|
-
|
240
|
-
subject.install_packages(*packages)
|
241
|
-
end
|
242
|
-
|
243
|
-
context "and the yes: keyword argument is given" do
|
244
|
-
it "must run `sudo apt install -y ...` with the package names" do
|
245
|
-
expect(subject).to receive(:sudo).with(
|
246
|
-
"apt", "install", "-y", *packages
|
247
|
-
)
|
248
|
-
|
249
|
-
subject.install_packages(*packages, yes: true)
|
250
|
-
end
|
251
|
-
end
|
252
|
-
end
|
253
|
-
|
254
|
-
context "and when the apt: keyword argument is given" do
|
255
|
-
let(:apt_packages) { ["foo", "bar", "baz"] }
|
256
|
-
|
257
|
-
it "must run `sudo apt install ...` with the package names" do
|
258
|
-
expect(subject).to receive(:sudo).with("apt","install",*apt_packages)
|
259
|
-
|
260
|
-
subject.install_packages(apt: apt_packages)
|
261
|
-
end
|
262
|
-
|
263
|
-
context "and the yes: keyword argument is given" do
|
264
|
-
it "must run `sudo apt install -y ...` with the package names" do
|
265
|
-
expect(subject).to receive(:sudo).with(
|
266
|
-
"apt", "install", "-y", *apt_packages
|
267
|
-
)
|
268
|
-
|
269
|
-
subject.install_packages(apt: apt_packages, yes: true)
|
270
|
-
end
|
271
|
-
end
|
272
|
-
end
|
273
|
-
|
274
|
-
context "and when both arguments and apt: keyword argument are given" do
|
275
|
-
let(:packages) { ["foo", "bar"] }
|
276
|
-
let(:apt_packages) { ["baz"] }
|
277
|
-
|
278
|
-
it "must run `sudo apt install ...` with the combined package names" do
|
279
|
-
expect(subject).to receive(:sudo).with(
|
280
|
-
"apt", "install", *(packages + apt_packages)
|
281
|
-
)
|
282
|
-
|
283
|
-
subject.install_packages(*packages, apt: apt_packages)
|
284
|
-
end
|
285
|
-
|
286
|
-
context "and the yes: keyword argument is given" do
|
287
|
-
it "must run `sudo apt install -y ...` with the combined package names" do
|
288
|
-
expect(subject).to receive(:sudo).with(
|
289
|
-
"apt", "install", "-y", *(packages + apt_packages)
|
290
|
-
)
|
291
|
-
|
292
|
-
subject.install_packages(*packages, apt: apt_packages, yes: true)
|
293
|
-
end
|
294
|
-
end
|
295
|
-
end
|
296
|
-
end
|
297
|
-
|
298
|
-
context "when the #package_manager is :brew" do
|
299
|
-
subject { command_class.new(package_manager: :brew) }
|
300
|
-
|
301
|
-
context "and when arguments are given" do
|
302
|
-
let(:packages) { ["foo", "bar", "baz"] }
|
303
|
-
|
304
|
-
it "must run `brew install ...` with the package names" do
|
305
|
-
expect(subject).to receive(:system).with("brew","install",*packages)
|
306
|
-
|
307
|
-
subject.install_packages(*packages)
|
308
|
-
end
|
309
|
-
end
|
310
|
-
|
311
|
-
context "and when the brew: keyword argument is given" do
|
312
|
-
let(:brew_packages) { ["foo", "bar", "baz"] }
|
313
|
-
|
314
|
-
it "must run `brew install ...` with the package names" do
|
315
|
-
expect(subject).to receive(:system).with(
|
316
|
-
"brew", "install", *brew_packages
|
317
|
-
)
|
318
|
-
|
319
|
-
subject.install_packages(brew: brew_packages)
|
320
|
-
end
|
321
|
-
end
|
322
|
-
|
323
|
-
context "and when both arguments and brew: keyword argument are given" do
|
324
|
-
let(:packages) { ["foo", "bar"] }
|
325
|
-
let(:brew_packages) { ["baz"] }
|
326
|
-
|
327
|
-
it "must run `brew install ...` with the combined package names" do
|
328
|
-
expect(subject).to receive(:system).with(
|
329
|
-
"brew", "install", *(packages + brew_packages)
|
330
|
-
)
|
331
|
-
|
332
|
-
subject.install_packages(*packages, brew: brew_packages)
|
333
|
-
end
|
334
|
-
end
|
335
|
-
end
|
336
|
-
|
337
|
-
context "when the #package_manager is :dnf" do
|
338
|
-
subject { command_class.new(package_manager: :dnf) }
|
339
|
-
|
340
|
-
context "and when arguments are given" do
|
341
|
-
let(:packages) { ["foo", "bar", "baz"] }
|
342
|
-
|
343
|
-
it "must run `sudo dnf install ...` with the package names" do
|
344
|
-
expect(subject).to receive(:sudo).with("dnf","install",*packages)
|
345
|
-
|
346
|
-
subject.install_packages(*packages)
|
347
|
-
end
|
348
|
-
|
349
|
-
context "and the yes: keyword argument is given" do
|
350
|
-
it "must run `sudo dnf install -y ...` with the package names" do
|
351
|
-
expect(subject).to receive(:sudo).with(
|
352
|
-
"dnf", "install", "-y", *packages
|
353
|
-
)
|
354
|
-
|
355
|
-
subject.install_packages(*packages, yes: true)
|
356
|
-
end
|
357
|
-
end
|
358
|
-
end
|
359
|
-
|
360
|
-
context "and when the dnf: keyword argument is given" do
|
361
|
-
let(:dnf_packages) { ["foo", "bar", "baz"] }
|
362
|
-
|
363
|
-
it "must run `sudo dnf install ...` with the package names" do
|
364
|
-
expect(subject).to receive(:sudo).with("dnf","install",*dnf_packages)
|
365
|
-
|
366
|
-
subject.install_packages(dnf: dnf_packages)
|
367
|
-
end
|
368
|
-
|
369
|
-
context "and the yes: keyword argument is given" do
|
370
|
-
it "must run `sudo dnf install -y ...` with the package names" do
|
371
|
-
expect(subject).to receive(:sudo).with(
|
372
|
-
"dnf", "install", "-y", *dnf_packages
|
373
|
-
)
|
374
|
-
|
375
|
-
subject.install_packages(dnf: dnf_packages, yes: true)
|
376
|
-
end
|
377
|
-
end
|
378
|
-
end
|
379
|
-
|
380
|
-
context "and when both arguments and dnf: keyword argument are given" do
|
381
|
-
let(:packages) { ["foo", "bar"] }
|
382
|
-
let(:dnf_packages) { ["baz"] }
|
383
|
-
|
384
|
-
it "must run `sudo dnf install ...` with the combined package names" do
|
385
|
-
expect(subject).to receive(:sudo).with(
|
386
|
-
"dnf", "install", *(packages + dnf_packages)
|
387
|
-
)
|
388
|
-
|
389
|
-
subject.install_packages(*packages, dnf: dnf_packages)
|
390
|
-
end
|
391
|
-
|
392
|
-
context "and the yes: keyword argument is given" do
|
393
|
-
it "must run `sudo dnf install -y ...` with the combined package names" do
|
394
|
-
expect(subject).to receive(:sudo).with(
|
395
|
-
"dnf", "install", "-y", *(packages + dnf_packages)
|
396
|
-
)
|
397
|
-
|
398
|
-
subject.install_packages(*packages, dnf: dnf_packages, yes: true)
|
399
|
-
end
|
400
|
-
end
|
401
|
-
end
|
402
|
-
end
|
403
|
-
|
404
|
-
context "when the #package_manager is :yum" do
|
405
|
-
subject { command_class.new(package_manager: :yum) }
|
406
|
-
|
407
|
-
context "and when arguments are given" do
|
408
|
-
let(:packages) { ["foo", "bar", "baz"] }
|
409
|
-
|
410
|
-
it "must run `sudo yum install ...` with the package names" do
|
411
|
-
expect(subject).to receive(:sudo).with("yum","install",*packages)
|
412
|
-
|
413
|
-
subject.install_packages(*packages)
|
414
|
-
end
|
415
|
-
|
416
|
-
context "and the yes: keyword argument is given" do
|
417
|
-
it "must run `sudo yum install -y ...` with the package names" do
|
418
|
-
expect(subject).to receive(:sudo).with(
|
419
|
-
"yum", "install", "-y", *packages
|
420
|
-
)
|
421
|
-
|
422
|
-
subject.install_packages(*packages, yes: true)
|
423
|
-
end
|
424
|
-
end
|
425
|
-
end
|
426
|
-
|
427
|
-
context "and when the yum: keyword argument is given" do
|
428
|
-
let(:yum_packages) { ["foo", "bar", "baz"] }
|
429
|
-
|
430
|
-
it "must run `sudo yum install ...` with the package names" do
|
431
|
-
expect(subject).to receive(:sudo).with("yum","install",*yum_packages)
|
432
|
-
|
433
|
-
subject.install_packages(yum: yum_packages)
|
434
|
-
end
|
435
|
-
|
436
|
-
context "and the yes: keyword argument is given" do
|
437
|
-
it "must run `sudo yum install -y ...` with the package names" do
|
438
|
-
expect(subject).to receive(:sudo).with(
|
439
|
-
"yum", "install", "-y", *yum_packages
|
440
|
-
)
|
441
|
-
|
442
|
-
subject.install_packages(yum: yum_packages, yes: true)
|
443
|
-
end
|
444
|
-
end
|
445
|
-
end
|
446
|
-
|
447
|
-
context "and when both arguments and yum: keyword argument are given" do
|
448
|
-
let(:packages) { ["foo", "bar"] }
|
449
|
-
let(:yum_packages) { ["baz"] }
|
450
|
-
|
451
|
-
it "must run `sudo yum install ...` with the combined package names" do
|
452
|
-
expect(subject).to receive(:sudo).with(
|
453
|
-
"yum", "install", *(packages + yum_packages)
|
454
|
-
)
|
455
|
-
|
456
|
-
subject.install_packages(*packages, yum: yum_packages)
|
457
|
-
end
|
458
|
-
|
459
|
-
context "and the yes: keyword argument is given" do
|
460
|
-
it "must run `sudo yum install -y ...` with the combined package names" do
|
461
|
-
expect(subject).to receive(:sudo).with(
|
462
|
-
"yum", "install", "-y", *(packages + yum_packages)
|
463
|
-
)
|
464
|
-
|
465
|
-
subject.install_packages(*packages, yum: yum_packages, yes: true)
|
466
|
-
end
|
467
|
-
end
|
468
|
-
end
|
469
|
-
end
|
470
|
-
|
471
|
-
context "when the #package_manager is :pacman" do
|
472
|
-
subject { command_class.new(package_manager: :pacman) }
|
473
|
-
|
474
|
-
context "and when arguments are given" do
|
475
|
-
let(:packages) { ["foo", "bar", "baz"] }
|
476
|
-
|
477
|
-
context "when none of the packages are already installed" do
|
478
|
-
before do
|
479
|
-
allow(subject).to receive(:`).with("pacman -T #{packages.join(' ')}").and_return(packages.join($/))
|
480
|
-
end
|
481
|
-
|
482
|
-
it "must run `sudo pacman -T ...` then `sudo pacman -S ...`" do
|
483
|
-
expect(subject).to receive(:sudo).with("pacman","-S",*packages)
|
484
|
-
|
485
|
-
subject.install_packages(*packages)
|
486
|
-
end
|
487
|
-
end
|
488
|
-
|
489
|
-
context "when some of the packages have already been installed" do
|
490
|
-
let(:missing_packages) { ["foo", "baz"] }
|
491
|
-
|
492
|
-
before do
|
493
|
-
allow(subject).to receive(:`).with("pacman -T #{packages.join(' ')}").and_return(missing_packages.join($/))
|
494
|
-
end
|
495
|
-
|
496
|
-
it "must omit them from the `sudo pacman -S ...` command" do
|
497
|
-
expect(subject).to receive(:sudo).with("pacman","-S",*missing_packages)
|
498
|
-
|
499
|
-
subject.install_packages(*packages)
|
500
|
-
end
|
501
|
-
end
|
502
|
-
|
503
|
-
context "when all packages have already been installed" do
|
504
|
-
before do
|
505
|
-
allow(subject).to receive(:`).with("pacman -T #{packages.join(' ')}").and_return($/)
|
506
|
-
end
|
507
|
-
|
508
|
-
it "must return true" do
|
509
|
-
expect(subject.install_packages(*packages)).to be(true)
|
510
|
-
end
|
511
|
-
end
|
512
|
-
end
|
513
|
-
|
514
|
-
context "and when the pacman: keyword argument is given" do
|
515
|
-
let(:pacman_packages) { ["foo", "bar", "baz"] }
|
516
|
-
|
517
|
-
context "when none of the packages are already installed" do
|
518
|
-
before do
|
519
|
-
allow(subject).to receive(:`).with(
|
520
|
-
"pacman -T #{pacman_packages.join(' ')}"
|
521
|
-
).and_return(pacman_packages.join($/))
|
522
|
-
end
|
523
|
-
|
524
|
-
it "must run `sudo pacman -T ...` then `sudo pacman -S ...`" do
|
525
|
-
expect(subject).to receive(:sudo).with(
|
526
|
-
"pacman", "-S", *pacman_packages
|
527
|
-
)
|
528
|
-
|
529
|
-
subject.install_packages(pacman: pacman_packages)
|
530
|
-
end
|
531
|
-
end
|
532
|
-
|
533
|
-
context "when some of the packages have already been installed" do
|
534
|
-
let(:missing_packages) { ["foo", "baz"] }
|
535
|
-
|
536
|
-
before do
|
537
|
-
allow(subject).to receive(:`).with(
|
538
|
-
"pacman -T #{pacman_packages.join(' ')}"
|
539
|
-
).and_return(missing_packages.join($/))
|
540
|
-
end
|
541
|
-
|
542
|
-
it "must omit them from the `sudo pacman -S ...` command" do
|
543
|
-
expect(subject).to receive(:sudo).with(
|
544
|
-
"pacman", "-S", *missing_packages
|
545
|
-
)
|
546
|
-
|
547
|
-
subject.install_packages(pacman: pacman_packages)
|
548
|
-
end
|
549
|
-
end
|
550
|
-
|
551
|
-
context "when all packages have already been installed" do
|
552
|
-
before do
|
553
|
-
allow(subject).to receive(:`).with(
|
554
|
-
"pacman -T #{pacman_packages.join(' ')}"
|
555
|
-
).and_return($/)
|
556
|
-
end
|
557
|
-
|
558
|
-
it "must return true" do
|
559
|
-
expect(
|
560
|
-
subject.install_packages(pacman: pacman_packages)
|
561
|
-
).to be(true)
|
562
|
-
end
|
563
|
-
end
|
564
|
-
end
|
565
|
-
|
566
|
-
context "and when both arguments and pacman: keyword argument are given" do
|
567
|
-
let(:packages) { ["foo", "baz"] }
|
568
|
-
let(:pacman_packages) { ["bar"] }
|
569
|
-
|
570
|
-
context "when none of the packages are already installed" do
|
571
|
-
before do
|
572
|
-
allow(subject).to receive(:`).with(
|
573
|
-
"pacman -T #{(packages + pacman_packages).join(' ')}"
|
574
|
-
).and_return((packages + pacman_packages).join($/))
|
575
|
-
end
|
576
|
-
|
577
|
-
it "must run `sudo pacman -T ...` then `sudo pacman -S ...`" do
|
578
|
-
expect(subject).to receive(:sudo).with(
|
579
|
-
"pacman", "-S", *(packages + pacman_packages)
|
580
|
-
)
|
581
|
-
|
582
|
-
subject.install_packages(*packages, pacman: pacman_packages)
|
583
|
-
end
|
584
|
-
end
|
585
|
-
|
586
|
-
context "when some of the packages have already been installed" do
|
587
|
-
let(:missing_packages) { ["foo", "baz"] }
|
588
|
-
|
589
|
-
before do
|
590
|
-
allow(subject).to receive(:`).with(
|
591
|
-
"pacman -T #{(packages + pacman_packages).join(' ')}"
|
592
|
-
).and_return(missing_packages.join($/))
|
593
|
-
end
|
594
|
-
|
595
|
-
it "must omit them from the `sudo pacman -S ...` command" do
|
596
|
-
expect(subject).to receive(:sudo).with(
|
597
|
-
"pacman", "-S", *missing_packages
|
598
|
-
)
|
599
|
-
|
600
|
-
subject.install_packages(*packages, pacman: pacman_packages)
|
601
|
-
end
|
602
|
-
end
|
603
|
-
|
604
|
-
context "when all packages have already been installed" do
|
605
|
-
before do
|
606
|
-
allow(subject).to receive(:`).with(
|
607
|
-
"pacman -T #{(packages + pacman_packages).join(' ')}"
|
608
|
-
).and_return($/)
|
609
|
-
end
|
610
|
-
|
611
|
-
it "must return true" do
|
612
|
-
expect(
|
613
|
-
subject.install_packages(*packages, pacman: pacman_packages)
|
614
|
-
).to be(true)
|
615
|
-
end
|
616
|
-
end
|
617
|
-
end
|
618
|
-
end
|
619
|
-
|
620
|
-
context "when the #package_manager is :pkg" do
|
621
|
-
subject { command_class.new(package_manager: :pkg) }
|
622
|
-
|
623
|
-
context "and when arguments are given" do
|
624
|
-
let(:packages) { ["foo", "bar", "baz"] }
|
625
|
-
|
626
|
-
it "must run `sudo pkg install ...` with the package names" do
|
627
|
-
expect(subject).to receive(:sudo).with("pkg","install",*packages)
|
628
|
-
|
629
|
-
subject.install_packages(*packages)
|
630
|
-
end
|
631
|
-
|
632
|
-
context "and the yes: keyword argument is given" do
|
633
|
-
it "must run `sudo pkg install -y ...` with the package names" do
|
634
|
-
expect(subject).to receive(:sudo).with(
|
635
|
-
"pkg", "install", "-y", *packages
|
636
|
-
)
|
637
|
-
|
638
|
-
subject.install_packages(*packages, yes: true)
|
639
|
-
end
|
640
|
-
end
|
641
|
-
end
|
642
|
-
|
643
|
-
context "and when the pkg: keyword argument is given" do
|
644
|
-
let(:pkg_packages) { ["foo", "bar", "baz"] }
|
645
|
-
|
646
|
-
it "must run `sudo pkg install ...` with the package names" do
|
647
|
-
expect(subject).to receive(:sudo).with("pkg","install",*pkg_packages)
|
648
|
-
|
649
|
-
subject.install_packages(pkg: pkg_packages)
|
650
|
-
end
|
651
|
-
|
652
|
-
context "and the yes: keyword argument is given" do
|
653
|
-
it "must run `sudo pkg install -y ...` with the package names" do
|
654
|
-
expect(subject).to receive(:sudo).with(
|
655
|
-
"pkg", "install", "-y", *pkg_packages
|
656
|
-
)
|
657
|
-
|
658
|
-
subject.install_packages(pkg: pkg_packages, yes: true)
|
659
|
-
end
|
660
|
-
end
|
661
|
-
end
|
662
|
-
|
663
|
-
context "and when both arguments and pkg: keyword argument are given" do
|
664
|
-
let(:packages) { ["foo", "bar"] }
|
665
|
-
let(:pkg_packages) { ["baz"] }
|
666
|
-
|
667
|
-
it "must run `sudo pkg install ...` with the combined package names" do
|
668
|
-
expect(subject).to receive(:sudo).with(
|
669
|
-
"pkg", "install", *(packages + pkg_packages)
|
670
|
-
)
|
671
|
-
|
672
|
-
subject.install_packages(*packages, pkg: pkg_packages)
|
673
|
-
end
|
674
|
-
|
675
|
-
context "and the yes: keyword argument is given" do
|
676
|
-
it "must run `sudo pkg install -y ...` with the combined package names" do
|
677
|
-
expect(subject).to receive(:sudo).with(
|
678
|
-
"pkg", "install", "-y", *(packages + pkg_packages)
|
679
|
-
)
|
680
|
-
|
681
|
-
subject.install_packages(*packages, pkg: pkg_packages, yes: true)
|
682
|
-
end
|
683
|
-
end
|
684
|
-
end
|
685
|
-
end
|
686
|
-
|
687
|
-
context "when the #package_manager is :pkg_add" do
|
688
|
-
subject { command_class.new(package_manager: :pkg_add) }
|
689
|
-
|
690
|
-
context "and when arguments are given" do
|
691
|
-
let(:packages) { ["foo", "bar", "baz"] }
|
692
|
-
|
693
|
-
it "must run `pkg_add ...` with the package names" do
|
694
|
-
expect(subject).to receive(:sudo).with("pkg_add",*packages)
|
695
|
-
|
696
|
-
subject.install_packages(*packages)
|
697
|
-
end
|
698
|
-
end
|
699
|
-
|
700
|
-
context "and when the pkg_add: keyword argument is given" do
|
701
|
-
let(:pkg_add_packages) { ["foo", "bar", "baz"] }
|
702
|
-
|
703
|
-
it "must run `pkg_add ...` with the package names" do
|
704
|
-
expect(subject).to receive(:sudo).with(
|
705
|
-
"pkg_add", *pkg_add_packages
|
706
|
-
)
|
707
|
-
|
708
|
-
subject.install_packages(pkg_add: pkg_add_packages)
|
709
|
-
end
|
710
|
-
end
|
711
|
-
|
712
|
-
context "and when both arguments and pkg_add: keyword argument are given" do
|
713
|
-
let(:packages) { ["foo", "bar"] }
|
714
|
-
let(:pkg_add_packages) { ["baz"] }
|
715
|
-
|
716
|
-
it "must run `pkg_add ...` with the combined package names" do
|
717
|
-
expect(subject).to receive(:sudo).with(
|
718
|
-
"pkg_add", *(packages + pkg_add_packages)
|
719
|
-
)
|
720
|
-
|
721
|
-
subject.install_packages(*packages, pkg_add: pkg_add_packages)
|
722
|
-
end
|
723
|
-
end
|
724
|
-
end
|
725
|
-
|
726
|
-
context "when the #package_manager is :port" do
|
727
|
-
subject { command_class.new(package_manager: :port) }
|
728
|
-
|
729
|
-
context "and when arguments are given" do
|
730
|
-
let(:packages) { ["foo", "bar", "baz"] }
|
731
|
-
|
732
|
-
it "must run `port install ...` with the package names" do
|
733
|
-
expect(subject).to receive(:sudo).with("port","install",*packages)
|
734
|
-
|
735
|
-
subject.install_packages(*packages)
|
736
|
-
end
|
737
|
-
end
|
738
|
-
|
739
|
-
context "and when the port: keyword argument is given" do
|
740
|
-
let(:port_packages) { ["foo", "bar", "baz"] }
|
741
|
-
|
742
|
-
it "must run `port install ...` with the package names" do
|
743
|
-
expect(subject).to receive(:sudo).with(
|
744
|
-
"port", "install", *port_packages
|
745
|
-
)
|
746
|
-
|
747
|
-
subject.install_packages(port: port_packages)
|
748
|
-
end
|
749
|
-
end
|
750
|
-
|
751
|
-
context "and when both arguments and port: keyword argument are given" do
|
752
|
-
let(:packages) { ["foo", "bar"] }
|
753
|
-
let(:port_packages) { ["baz"] }
|
754
|
-
|
755
|
-
it "must run `port install ...` with the combined package names" do
|
756
|
-
expect(subject).to receive(:sudo).with(
|
757
|
-
"port", "install", *(packages + port_packages)
|
758
|
-
)
|
759
|
-
|
760
|
-
subject.install_packages(*packages, port: port_packages)
|
761
|
-
end
|
762
|
-
end
|
763
|
-
end
|
764
|
-
|
765
|
-
context "when the #package_manager is :zypper" do
|
766
|
-
subject { command_class.new(package_manager: :zypper) }
|
767
|
-
|
768
|
-
context "and when arguments are given" do
|
769
|
-
let(:packages) { ["foo", "bar", "baz"] }
|
770
|
-
|
771
|
-
it "must run `zypper -n install -l ...` with the package names" do
|
772
|
-
expect(subject).to receive(:sudo).with(
|
773
|
-
"zypper", "-n", "in", "-l", *packages
|
774
|
-
)
|
775
|
-
|
776
|
-
subject.install_packages(*packages)
|
777
|
-
end
|
778
|
-
end
|
779
|
-
|
780
|
-
context "and when the zypper: keyword argument is given" do
|
781
|
-
let(:zypper_packages) { ["foo", "bar", "baz"] }
|
782
|
-
|
783
|
-
it "must run `zypper install ...` with the package names" do
|
784
|
-
expect(subject).to receive(:sudo).with(
|
785
|
-
"zypper", "-n", "in", "-l", *zypper_packages
|
786
|
-
)
|
787
|
-
|
788
|
-
subject.install_packages(zypper: zypper_packages)
|
789
|
-
end
|
790
|
-
end
|
791
|
-
|
792
|
-
context "and when both arguments and zypper: keyword argument are given" do
|
793
|
-
let(:packages) { ["foo", "bar"] }
|
794
|
-
let(:zypper_packages) { ["baz"] }
|
795
|
-
|
796
|
-
it "must run `zypper install ...` with the combined package names" do
|
797
|
-
expect(subject).to receive(:sudo).with(
|
798
|
-
"zypper", "-n", "in", "-l", *(packages + zypper_packages)
|
799
|
-
)
|
800
|
-
|
801
|
-
subject.install_packages(*packages, zypper: zypper_packages)
|
802
|
-
end
|
803
|
-
end
|
804
|
-
end
|
805
|
-
end
|
806
|
-
end
|