From a4d4da64aab707e2f39fcc32fec6418cc39e8010 Mon Sep 17 00:00:00 2001 From: mansimarkaur Date: Thu, 27 Jul 2017 04:41:49 +0530 Subject: [PATCH] Added tests for os_prefix_ci --- Library/Homebrew/test/utils/analytics_spec.rb | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Library/Homebrew/test/utils/analytics_spec.rb diff --git a/Library/Homebrew/test/utils/analytics_spec.rb b/Library/Homebrew/test/utils/analytics_spec.rb new file mode 100644 index 0000000000..cee09e2861 --- /dev/null +++ b/Library/Homebrew/test/utils/analytics_spec.rb @@ -0,0 +1,34 @@ +require "utils/analytics" + +describe Utils::Analytics do + describe "::os_prefix_ci" do + context "when anonymous_os_prefix_ci is not set" do + it "returns OS_VERSION and prefix when HOMEBREW_PREFIX is not /usr/local" do + expect(described_class.os_prefix_ci).to include("#{OS_VERSION}, non-/usr/local") + end + + it "includes CI when ENV['CI'] is set" do + allow(ENV).to receive(:[]).with("CI").and_return("true") + expect(described_class.os_prefix_ci).to include("CI") + end + + it "does not include prefix when HOMEBREW_PREFIX is usr/local" do + allow(HOMEBREW_PREFIX).to receive(:to_s).and_return("/usr/local") + expect(described_class.os_prefix_ci).not_to include("non-/usr/local") + end + end + + context "when anonymous_os_prefix_ci is set" do + let(:anonymous_os_prefix_ci) { "macOS 10.11.6, non-/usr/local, CI" } + + it "returns anonymous_os_prefix_ci" do + described_class.instance_variable_set(:@anonymous_os_prefix_ci, anonymous_os_prefix_ci) + expect(described_class.os_prefix_ci).to eq(anonymous_os_prefix_ci) + end + end + end + + describe "::" do + + end +end \ No newline at end of file