-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
command_spec.rb
82 lines (76 loc) · 2.41 KB
/
command_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
require "spec_setup"
require "stud/temporary"
require "fpm" # local
require "fpm/command" # local
require "fixtures/mockpackage"
describe FPM::Command do
describe "--prefix"
describe "-C"
describe "-p / --package"
describe "-f"
describe "-n"
describe "-v"
describe "--iteration"
describe "--epoch"
describe "--license"
describe "--vendor"
describe "--category"
describe "-d / --depends"
describe "--no-depends"
describe "--provides"
describe "--conflicts"
describe "--replaces"
describe "--config-files"
describe "--directories"
describe "-a | --architecture"
describe "-p | --package" do
context "when given a directory" do
it "should write the package to the given directory." do
Stud::Temporary.directory do |path|
cmd = FPM::Command.new("fpm")
cmd.run(["-s", "empty", "-t", "deb", "-n", "example", "-p", path])
files = Dir.new(path).to_a - [".", ".."]
insist { files.size } == 1
insist { files[0] } =~ /^example_/
end
end
end
context "when not set" do
it "should write the package to the current directory." do
Stud::Temporary.directory do |path|
Dir.chdir(path) do
cmd = FPM::Command.new("fpm")
cmd.run(["-s", "empty", "-t", "deb", "-n", "example"])
end
files = Dir.new(path).to_a - ['.', '..']
insist { files.size } == 1
insist { files[0] } =~ /example_/
end
end
end
end
describe "--log" do
subject { FPM::Command.new("fpm") }
let (:args) { [ "-s", "mock", "-t", "mock" ] }
context "when not given" do
it "should not raise an exception" do
subject.parse(args)
end
end
context "when given a valid log level" do
it "should not raise an exception" do
subject.parse(args + ["--log", "error"])
subject.parse(args + ["--log", "warn"])
subject.parse(args + ["--log", "info"])
subject.parse(args + ["--log", "debug"])
end
end
context "when given an invalid log level" do
it "should raise an exception" do
insist { subject.parse(args + ["--log", ""]) }.raises FPM::Package::InvalidArgument
insist { subject.parse(args + ["--log", "whatever"]) }.raises FPM::Package::InvalidArgument
insist { subject.parse(args + ["--log", "fatal"]) }.raises FPM::Package::InvalidArgument
end
end
end
end