Added tests for keg_only_text

This commit is contained in:
mansimarkaur 2017-07-18 01:29:05 +05:30
parent 6de94839de
commit a5334b9dca

View File

@ -1,5 +1,6 @@
require "formula" require "formula"
require "caveats" require "caveats"
require "pathname"
describe Caveats do describe Caveats do
subject { described_class.new(f) } subject { described_class.new(f) }
@ -37,7 +38,7 @@ describe Caveats do
end end
plist_options startup: true plist_options startup: true
end end
expect(described_class.new(f).caveats).to include("startup:\n sudo brew") expect(described_class.new(f).caveats).to include("startup")
end end
it "prints plist login information when f.plist_startup is nil" do it "prints plist login information when f.plist_startup is nil" do
@ -47,30 +48,54 @@ describe Caveats do
"plist_test.plist" "plist_test.plist"
end end
end end
expect(described_class.new(f).caveats).to include("login:\n brew") expect(described_class.new(f).caveats).to include("login")
end end
end end
context "when f.keg_only is not nil" do context "when f.keg_only is not nil" do
it "tells formula is keg_only and gives information about command to be run when f.bin and f.sbin are directories" do let(:f) {
Path = Pathname.new("path") formula do
f = formula do
url "foo-1.0" url "foo-1.0"
keg_only "some reason" keg_only "some reason"
end end
}
let(:caveats) { described_class.new(f).caveats }
allow(f).to receive(:bin).and_return(Path) it "tells formula is keg_only" do
allow(f.bin).to receive(:directory?).and_return(true)
allow(f).to receive(:sbin).and_return(Path)
allow(f.sbin).to receive(:directory?).and_return(true)
caveats = described_class.new(f).caveats
expect(caveats).to include("keg-only") expect(caveats).to include("keg-only")
end
it "gives command to be run when f.bin is a directory" do
Pathname.new(f.bin).mkpath
expect(caveats).to include(f.opt_bin.to_s) expect(caveats).to include(f.opt_bin.to_s)
end
it "gives command to be run when f.sbin is a directory" do
Pathname.new(f.sbin).mkpath
expect(caveats).to include(f.opt_sbin.to_s) expect(caveats).to include(f.opt_sbin.to_s)
end end
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
end end
end end
end end