Used let for sec_in_a_day and removed redundant after(:each) block
This commit is contained in:
parent
5f7a93bceb
commit
01714b17ee
@ -5,6 +5,7 @@ require "pathname"
|
|||||||
|
|
||||||
describe Homebrew::Cleanup do
|
describe Homebrew::Cleanup do
|
||||||
let(:ds_store) { Pathname.new("#{HOMEBREW_PREFIX}/Library/.DS_Store") }
|
let(:ds_store) { Pathname.new("#{HOMEBREW_PREFIX}/Library/.DS_Store") }
|
||||||
|
let(:sec_in_a_day) { 60 * 60 * 24 }
|
||||||
|
|
||||||
around(:each) do |example|
|
around(:each) do |example|
|
||||||
begin
|
begin
|
||||||
@ -118,13 +119,13 @@ describe Homebrew::Cleanup do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "cleans up logs if older than 14 days" do
|
it "cleans up logs if older than 14 days" do
|
||||||
allow_any_instance_of(Pathname).to receive(:mtime).and_return(Time.now - 60 * 60 * 24 * 15)
|
allow_any_instance_of(Pathname).to receive(:mtime).and_return(Time.now - sec_in_a_day * 15)
|
||||||
described_class.cleanup_logs
|
described_class.cleanup_logs
|
||||||
expect(path).not_to exist
|
expect(path).not_to exist
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does not clean up logs less than 14 days old" do
|
it "does not clean up logs less than 14 days old" do
|
||||||
allow_any_instance_of(Pathname).to receive(:mtime).and_return(Time.now - 60 * 60 * 24 * 2)
|
allow_any_instance_of(Pathname).to receive(:mtime).and_return(Time.now - sec_in_a_day * 2)
|
||||||
described_class.cleanup_logs
|
described_class.cleanup_logs
|
||||||
expect(path).to exist
|
expect(path).to exist
|
||||||
end
|
end
|
||||||
@ -199,7 +200,7 @@ describe Homebrew::Cleanup do
|
|||||||
foo = (HOMEBREW_CACHE/"--foo")
|
foo = (HOMEBREW_CACHE/"--foo")
|
||||||
foo.mkpath
|
foo.mkpath
|
||||||
allow(ARGV).to receive(:value).with("prune").and_return("1")
|
allow(ARGV).to receive(:value).with("prune").and_return("1")
|
||||||
allow_any_instance_of(Pathname).to receive(:mtime).and_return(Time.now - 60 * 60 * 24 * 2)
|
allow_any_instance_of(Pathname).to receive(:mtime).and_return(Time.now - sec_in_a_day * 2)
|
||||||
described_class.cleanup_cache
|
described_class.cleanup_cache
|
||||||
expect(foo).not_to exist
|
expect(foo).not_to exist
|
||||||
end
|
end
|
||||||
@ -223,13 +224,6 @@ describe Homebrew::Cleanup do
|
|||||||
FileUtils.touch(CoreTap.instance.formula_dir/"testball.rb")
|
FileUtils.touch(CoreTap.instance.formula_dir/"testball.rb")
|
||||||
end
|
end
|
||||||
|
|
||||||
after(:each) do
|
|
||||||
FileUtils.rm_rf(bottle)
|
|
||||||
FileUtils.rm_rf(testball)
|
|
||||||
FileUtils.rm_rf(HOMEBREW_CELLAR/"testball")
|
|
||||||
FileUtils.rm_rf(CoreTap.instance.formula_dir/"testball.rb")
|
|
||||||
end
|
|
||||||
|
|
||||||
it "cleans up file if outdated" do
|
it "cleans up file if outdated" do
|
||||||
allow(Utils::Bottles).to receive(:file_outdated?).with(any_args).and_return(true)
|
allow(Utils::Bottles).to receive(:file_outdated?).with(any_args).and_return(true)
|
||||||
described_class.cleanup_cache
|
described_class.cleanup_cache
|
||||||
@ -257,10 +251,10 @@ describe Homebrew::Cleanup do
|
|||||||
foo.mkpath
|
foo.mkpath
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:foo) { mktmpdir/"foo.rb" }
|
let(:foo) { HOMEBREW_CACHE/"foo" }
|
||||||
|
|
||||||
it "returns true when path_modified_time < days_default" do
|
it "returns true when path_modified_time < days_default" do
|
||||||
allow_any_instance_of(Pathname).to receive(:mtime).and_return(Time.now - 60 * 60 * 24 * 2)
|
allow_any_instance_of(Pathname).to receive(:mtime).and_return(Time.now - sec_in_a_day * 2)
|
||||||
expect(described_class.prune?(foo, days_default: "1")).to be_truthy
|
expect(described_class.prune?(foo, days_default: "1")).to be_truthy
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user