Added tests for git_available?
This commit is contained in:
parent
d91036e891
commit
657b6ef7fb
@ -45,3 +45,22 @@ describe Git do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe Utils do
|
||||||
|
describe "::git_available?" do
|
||||||
|
it "returns true if git --version command succeeds" do
|
||||||
|
allow_any_instance_of(Process::Status).to receive(:success?).and_return(true)
|
||||||
|
expect(described_class.git_available?).to be_truthy
|
||||||
|
end
|
||||||
|
|
||||||
|
it "returns false if git --version command does not succeed" do
|
||||||
|
allow_any_instance_of(Process::Status).to receive(:success?).and_return(false)
|
||||||
|
expect(described_class.git_available?).to be_falsey
|
||||||
|
end
|
||||||
|
|
||||||
|
it "returns git version if already set" do
|
||||||
|
described_class.instance_variable_set(:@git, true)
|
||||||
|
expect(described_class.git_available?).to be_truthy
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|||||||
@ -27,7 +27,8 @@ end
|
|||||||
|
|
||||||
module Utils
|
module Utils
|
||||||
def self.git_available?
|
def self.git_available?
|
||||||
@git ||= quiet_system HOMEBREW_SHIMS_PATH/"scm/git", "--version"
|
return @git if instance_variable_defined?(:@git)
|
||||||
|
@git = quiet_system HOMEBREW_SHIMS_PATH/"scm/git", "--version"
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.git_path
|
def self.git_path
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user