aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authormansimarkaur2017-08-26 02:01:45 +0530
committermansimarkaur2017-08-27 01:18:41 +0530
commit01714b17ee4abd08082ef5a37810a7b21ec80d6a (patch)
tree077fd2408039715d1fe05c9e65b27884fa5dd0ed /Library
parent5f7a93bcebf2f18f4740f0fd5e676555880c5d71 (diff)
downloadbrew-01714b17ee4abd08082ef5a37810a7b21ec80d6a.tar.bz2
Used let for sec_in_a_day and removed redundant after(:each) block
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/test/cleanup_spec.rb18
1 files changed, 6 insertions, 12 deletions
diff --git a/Library/Homebrew/test/cleanup_spec.rb b/Library/Homebrew/test/cleanup_spec.rb
index 3e9cdc79c..da262c5ca 100644
--- a/Library/Homebrew/test/cleanup_spec.rb
+++ b/Library/Homebrew/test/cleanup_spec.rb
@@ -5,6 +5,7 @@ require "pathname"
describe Homebrew::Cleanup do
let(:ds_store) { Pathname.new("#{HOMEBREW_PREFIX}/Library/.DS_Store") }
+ let(:sec_in_a_day) { 60 * 60 * 24 }
around(:each) do |example|
begin
@@ -118,13 +119,13 @@ describe Homebrew::Cleanup do
end
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
expect(path).not_to exist
end
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
expect(path).to exist
end
@@ -199,7 +200,7 @@ describe Homebrew::Cleanup do
foo = (HOMEBREW_CACHE/"--foo")
foo.mkpath
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
expect(foo).not_to exist
end
@@ -223,13 +224,6 @@ describe Homebrew::Cleanup do
FileUtils.touch(CoreTap.instance.formula_dir/"testball.rb")
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
allow(Utils::Bottles).to receive(:file_outdated?).with(any_args).and_return(true)
described_class.cleanup_cache
@@ -257,10 +251,10 @@ describe Homebrew::Cleanup do
foo.mkpath
end
- let(:foo) { mktmpdir/"foo.rb" }
+ let(:foo) { HOMEBREW_CACHE/"foo" }
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
end