aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test/cmd
diff options
context:
space:
mode:
authorMike McQuaid2017-02-23 09:12:18 +0000
committerGitHub2017-02-23 09:12:18 +0000
commit1a436b4d24d50011bc444cf5d2016f5c0f808dec (patch)
tree9659fbe8f1ed557e74ddaf7fde9c3c8ff8821da2 /Library/Homebrew/test/cmd
parent5e9057500419d1a2b41efe784e9f12ae232e7f6e (diff)
parent3f8e52e5742cdd3d992ddee79741a4c4e45ab4bf (diff)
downloadbrew-1a436b4d24d50011bc444cf5d2016f5c0f808dec.tar.bz2
Merge branch 'master' into mirror_audit
Diffstat (limited to 'Library/Homebrew/test/cmd')
-rw-r--r--Library/Homebrew/test/cmd/analytics_spec.rb52
-rw-r--r--Library/Homebrew/test/cmd/search_remote_tap_spec.rb19
2 files changed, 71 insertions, 0 deletions
diff --git a/Library/Homebrew/test/cmd/analytics_spec.rb b/Library/Homebrew/test/cmd/analytics_spec.rb
new file mode 100644
index 000000000..aed3a7a33
--- /dev/null
+++ b/Library/Homebrew/test/cmd/analytics_spec.rb
@@ -0,0 +1,52 @@
+describe "brew analytics", :integration_test do
+ before(:each) do
+ HOMEBREW_REPOSITORY.cd do
+ shutup do
+ system "git", "init"
+ end
+ end
+ end
+
+ it "is disabled when HOMEBREW_NO_ANALYTICS is set" do
+ expect { brew "analytics", "HOMEBREW_NO_ANALYTICS" => "1" }
+ .to output(/Analytics is disabled \(by HOMEBREW_NO_ANALYTICS\)/).to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
+ end
+
+ context "when HOMEBREW_NO_ANALYTICS is unset" do
+ it "is disabled after running `brew analytics off`" do
+ brew "analytics", "off"
+ expect { brew "analytics", "HOMEBREW_NO_ANALYTICS" => nil }
+ .to output(/Analytics is disabled/).to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
+ end
+
+ it "is enabled after running `brew analytics on`" do
+ brew "analytics", "on"
+ expect { brew "analytics", "HOMEBREW_NO_ANALYTICS" => nil }
+ .to output(/Analytics is enabled/).to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
+ end
+ end
+
+ it "fails when running `brew analytics on off`" do
+ expect { brew "analytics", "on", "off" }
+ .to output(/Invalid usage/).to_stderr
+ .and not_to_output.to_stdout
+ .and be_a_failure
+ end
+
+ it "fails when running `brew analytics testball`" do
+ expect { brew "analytics", "testball" }
+ .to output(/Invalid usage/).to_stderr
+ .and not_to_output.to_stdout
+ .and be_a_failure
+ end
+
+ it "can generate a new UUID" do
+ expect { brew "analytics", "regenerate-uuid" }.to be_a_success
+ end
+end
diff --git a/Library/Homebrew/test/cmd/search_remote_tap_spec.rb b/Library/Homebrew/test/cmd/search_remote_tap_spec.rb
new file mode 100644
index 000000000..99c2cc20b
--- /dev/null
+++ b/Library/Homebrew/test/cmd/search_remote_tap_spec.rb
@@ -0,0 +1,19 @@
+require "cmd/search"
+
+describe Homebrew do
+ specify "#search_tap" do
+ json_response = {
+ "tree" => [
+ {
+ "path" => "Formula/not-a-formula.rb",
+ "type" => "blob",
+ },
+ ],
+ }
+
+ allow(GitHub).to receive(:open).and_yield(json_response)
+
+ expect(described_class.search_tap("homebrew", "not-a-tap", "not-a-formula"))
+ .to eq(["homebrew/not-a-tap/not-a-formula"])
+ end
+end