2017-02-25 20:10:25 +01:00
|
|
|
require "formula"
|
|
|
|
require "caveats"
|
2017-07-18 01:29:05 +05:30
|
|
|
require "pathname"
|
2017-02-25 20:10:25 +01:00
|
|
|
|
|
|
|
describe Caveats do
|
|
|
|
subject { described_class.new(f) }
|
|
|
|
let(:f) { formula { url "foo-1.0" } }
|
|
|
|
|
|
|
|
specify "#f" do
|
|
|
|
expect(subject.f).to eq(f)
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "#empty?" do
|
|
|
|
it "returns true if the Formula has no caveats" do
|
|
|
|
expect(subject).to be_empty
|
|
|
|
end
|
|
|
|
|
|
|
|
it "returns false if the Formula has caveats" do
|
|
|
|
f = formula do
|
|
|
|
url "foo-1.0"
|
|
|
|
|
|
|
|
def caveats
|
|
|
|
"something"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(described_class.new(f)).not_to be_empty
|
|
|
|
end
|
|
|
|
end
|
2017-06-20 05:32:13 +05:30
|
|
|
|
|
|
|
describe "#caveats" do
|
|
|
|
context "when f.plist is not nil" do
|
|
|
|
it "prints plist startup information when f.plist_startup is not nil" do
|
|
|
|
f = formula do
|
|
|
|
url "foo-1.0"
|
|
|
|
def plist
|
|
|
|
"plist_test.plist"
|
|
|
|
end
|
|
|
|
plist_options startup: true
|
|
|
|
end
|
2017-07-18 01:29:05 +05:30
|
|
|
expect(described_class.new(f).caveats).to include("startup")
|
2017-06-20 05:32:13 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it "prints plist login information when f.plist_startup is nil" do
|
|
|
|
f = formula do
|
|
|
|
url "foo-1.0"
|
|
|
|
def plist
|
|
|
|
"plist_test.plist"
|
|
|
|
end
|
|
|
|
end
|
2017-07-18 01:29:05 +05:30
|
|
|
expect(described_class.new(f).caveats).to include("login")
|
2017-06-20 05:32:13 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when f.keg_only is not nil" do
|
2017-07-18 01:29:05 +05:30
|
|
|
let(:f) {
|
|
|
|
formula do
|
2017-06-20 05:32:13 +05:30
|
|
|
url "foo-1.0"
|
|
|
|
keg_only "some reason"
|
|
|
|
end
|
2017-07-18 01:29:05 +05:30
|
|
|
}
|
|
|
|
let(:caveats) { described_class.new(f).caveats }
|
2017-06-20 05:32:13 +05:30
|
|
|
|
2017-07-18 01:29:05 +05:30
|
|
|
it "tells formula is keg_only" do
|
2017-06-20 05:32:13 +05:30
|
|
|
expect(caveats).to include("keg-only")
|
2017-07-18 01:29:05 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it "gives command to be run when f.bin is a directory" do
|
|
|
|
Pathname.new(f.bin).mkpath
|
2017-06-20 05:32:13 +05:30
|
|
|
expect(caveats).to include(f.opt_bin.to_s)
|
2017-07-18 01:29:05 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it "gives command to be run when f.sbin is a directory" do
|
|
|
|
Pathname.new(f.sbin).mkpath
|
2017-06-20 05:32:13 +05:30
|
|
|
expect(caveats).to include(f.opt_sbin.to_s)
|
|
|
|
end
|
2017-07-18 01:29:05 +05:30
|
|
|
|
|
|
|
context "when f.lib or f.include is a directory" do
|
|
|
|
it "gives command to be run when f.lib is a directory" do
|
|
|
|
Pathname.new(f.lib).mkpath
|
|
|
|
expect(caveats).to include("-L#{f.opt_lib}")
|
|
|
|
end
|
|
|
|
|
|
|
|
it "gives command to be run when f.include is a directory" do
|
|
|
|
Pathname.new(f.include).mkpath
|
|
|
|
expect(caveats).to include("-I#{f.opt_include}")
|
|
|
|
end
|
|
|
|
|
|
|
|
it "gives PKG_CONFIG_PATH when f.lib/'pkgconfig' and f.share/'pkgconfig' are directories" do
|
|
|
|
allow_any_instance_of(Object).to receive(:which).with(any_args).and_return(Pathname.new("blah"))
|
|
|
|
|
|
|
|
Pathname.new(f.share/"pkgconfig").mkpath
|
|
|
|
Pathname.new(f.lib/"pkgconfig").mkpath
|
|
|
|
|
|
|
|
expect(caveats).to include("#{f.opt_lib}/pkgconfig")
|
|
|
|
expect(caveats).to include("#{f.opt_share}/pkgconfig")
|
|
|
|
end
|
|
|
|
end
|
2017-06-20 05:32:13 +05:30
|
|
|
end
|
|
|
|
end
|
2017-02-25 20:10:25 +01:00
|
|
|
end
|