Used already existing clear_git_available_cache to remove @git
This commit is contained in:
parent
c695dffd37
commit
784250d550
@ -4,37 +4,36 @@ describe Git do
|
||||
before(:each) do
|
||||
git = HOMEBREW_SHIMS_PATH/"scm/git"
|
||||
|
||||
@file = "blah.rb"
|
||||
|
||||
HOMEBREW_CACHE.cd do
|
||||
system git, "init"
|
||||
|
||||
File.open(@file, "w") { |f| f.write("blah") }
|
||||
system git, "add", HOMEBREW_CACHE/@file
|
||||
File.open(file, "w") { |f| f.write("blah") }
|
||||
system git, "add", HOMEBREW_CACHE/file
|
||||
system git, "commit", "-m", "'File added'"
|
||||
@h1 = `git rev-parse HEAD`
|
||||
|
||||
File.open(@file, "w") { |f| f.write("brew") }
|
||||
system git, "add", HOMEBREW_CACHE/@file
|
||||
File.open(file, "w") { |f| f.write("brew") }
|
||||
system git, "add", HOMEBREW_CACHE/file
|
||||
system git, "commit", "-m", "'written to File'"
|
||||
@h2 = `git rev-parse HEAD`
|
||||
end
|
||||
end
|
||||
|
||||
let(:file) { "blah.rb" }
|
||||
let(:hash1) { @h1[0..6] }
|
||||
let(:hash2) { @h2[0..6] }
|
||||
|
||||
describe "#last_revision_commit_of_file" do
|
||||
it "gives last revision commit when before_commit is nil" do
|
||||
expect(
|
||||
described_class.last_revision_commit_of_file(HOMEBREW_CACHE, @file),
|
||||
described_class.last_revision_commit_of_file(HOMEBREW_CACHE, file),
|
||||
).to eq(hash1)
|
||||
end
|
||||
|
||||
it "gives revision commit based on before_commit when it is not nil" do
|
||||
expect(
|
||||
described_class.last_revision_commit_of_file(HOMEBREW_CACHE,
|
||||
@file,
|
||||
file,
|
||||
before_commit: hash2),
|
||||
).to eq(hash2)
|
||||
end
|
||||
@ -44,13 +43,13 @@ describe Git do
|
||||
it "returns last revision of file" do
|
||||
expect(
|
||||
described_class.last_revision_of_file(HOMEBREW_CACHE,
|
||||
HOMEBREW_CACHE/@file),
|
||||
HOMEBREW_CACHE/file),
|
||||
).to eq("blah")
|
||||
end
|
||||
|
||||
it "returns last revision of file based on before_commit" do
|
||||
expect(
|
||||
described_class.last_revision_of_file(HOMEBREW_CACHE, HOMEBREW_CACHE/@file,
|
||||
described_class.last_revision_of_file(HOMEBREW_CACHE, HOMEBREW_CACHE/file,
|
||||
before_commit: "0..3"),
|
||||
).to eq("brew")
|
||||
end
|
||||
@ -59,7 +58,7 @@ end
|
||||
|
||||
describe Utils do
|
||||
before(:each) do
|
||||
described_class.clear_git_version_cache
|
||||
described_class.clear_git_available_cache
|
||||
end
|
||||
|
||||
describe "::git_available?" do
|
||||
@ -148,20 +147,4 @@ describe Utils do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "::clear_git_available_cache" do
|
||||
it "removes @git_path and @git_version if defined" do
|
||||
described_class.clear_git_available_cache
|
||||
|
||||
expect(described_class.instance_variable_get(:@git_path)).to be_nil
|
||||
expect(described_class.instance_variable_get(:@git_version)).to be_nil
|
||||
end
|
||||
|
||||
it "removes @git if defined" do
|
||||
described_class.git_available?
|
||||
described_class.clear_git_available_cache
|
||||
|
||||
expect(described_class.instance_variable_get(:@git)).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -26,10 +26,6 @@ module Git
|
||||
end
|
||||
|
||||
module Utils
|
||||
def self.clear_git_version_cache
|
||||
remove_instance_variable(:@git) if instance_variable_defined?(:@git)
|
||||
end
|
||||
|
||||
def self.git_available?
|
||||
return @git if instance_variable_defined?(:@git)
|
||||
@git = quiet_system HOMEBREW_SHIMS_PATH/"scm/git", "--version"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user