Improved tests for svn_available?
This commit is contained in:
parent
13fb14a95f
commit
cf96d8d970
@ -2,11 +2,17 @@ require "utils/svn"
|
||||
|
||||
describe Utils do
|
||||
describe "#self.svn_available?" do
|
||||
it "processes value when @svn is not defined" do
|
||||
it "returns true if svn --version command succeeds" do
|
||||
allow_any_instance_of(Process::Status).to receive(:success?).and_return(true)
|
||||
expect(described_class.svn_available?).to be_truthy
|
||||
end
|
||||
|
||||
it "returns value of @svn when @svn is defined" do
|
||||
it "returns false if svn --version command does not succeed" do
|
||||
allow_any_instance_of(Process::Status).to receive(:success?).and_return(false)
|
||||
expect(described_class.svn_available?).to be_falsey
|
||||
end
|
||||
|
||||
it "returns svn version if already set" do
|
||||
described_class.instance_variable_set(:@svn, true)
|
||||
expect(described_class.svn_available?).to be_truthy
|
||||
end
|
||||
@ -15,17 +21,16 @@ describe Utils do
|
||||
describe "#self.svn_remote_exists" do
|
||||
let(:url) { "https://dl.bintray.com/homebrew/mirror/" }
|
||||
|
||||
it "gives true when @svn is false" do
|
||||
allow_any_instance_of(Process::Status).to receive(:success?).and_return(false)
|
||||
it "returns true when svn is not available" do
|
||||
described_class.instance_variable_set(:@svn, false)
|
||||
expect(described_class.svn_remote_exists(url)).to be_truthy
|
||||
end
|
||||
|
||||
it "gives false when url is obscure" do
|
||||
expect(described_class.svn_remote_exists(url)).to be_falsy
|
||||
it "returns false when remote does not exist" do
|
||||
expect(described_class.svn_remote_exists(url)).to be_falsey
|
||||
end
|
||||
|
||||
it "gives true when quiet_system succeeds with given url" do
|
||||
it "returns true when remote exists" do
|
||||
allow_any_instance_of(Process::Status).to receive(:success?).and_return(true)
|
||||
expect(described_class.svn_remote_exists(url)).to be_truthy
|
||||
end
|
||||
|
@ -1,7 +1,6 @@
|
||||
module Utils
|
||||
def self.svn_available?
|
||||
return @svn if instance_variable_defined?(:@svn)
|
||||
@svn = quiet_system HOMEBREW_SHIMS_PATH/"scm/svn", "--version"
|
||||
@svn ||= quiet_system HOMEBREW_SHIMS_PATH/"scm/svn", "--version"
|
||||
end
|
||||
|
||||
def self.svn_remote_exists(url)
|
||||
|
Loading…
x
Reference in New Issue
Block a user