From 13fb14a95f6d0c909451e94e96b14447ccabdfcb Mon Sep 17 00:00:00 2001 From: mansimarkaur Date: Thu, 27 Jul 2017 01:52:21 +0530 Subject: [PATCH] Added tests fir utils/svn --- Library/Homebrew/test/utils/svn_spec.rb | 33 +++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Library/Homebrew/test/utils/svn_spec.rb diff --git a/Library/Homebrew/test/utils/svn_spec.rb b/Library/Homebrew/test/utils/svn_spec.rb new file mode 100644 index 0000000000..35f8917aaf --- /dev/null +++ b/Library/Homebrew/test/utils/svn_spec.rb @@ -0,0 +1,33 @@ +require "utils/svn" + +describe Utils do + describe "#self.svn_available?" do + it "processes value when @svn is not defined" do + expect(described_class.svn_available?).to be_truthy + end + + it "returns value of @svn when @svn is defined" do + described_class.instance_variable_set(:@svn, true) + expect(described_class.svn_available?).to be_truthy + end + end + + 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) + 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 + end + + it "gives true when quiet_system succeeds with given url" do + allow_any_instance_of(Process::Status).to receive(:success?).and_return(true) + expect(described_class.svn_remote_exists(url)).to be_truthy + end + end +end