aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMarkus Reiter2017-02-24 17:00:53 +0100
committerGitHub2017-02-24 17:00:53 +0100
commit1f6ae07c44b33a36441f111bab3a72571f6a0995 (patch)
treeae6a3b151dd22d20ebbea2777154dc80dd582279 /Library
parent56f6dd0711097e124549c7b9ae61058d3ab6d4a4 (diff)
parentada6a1b09e04ed3ab6758adfb231bc31b332442c (diff)
downloadbrew-1f6ae07c44b33a36441f111bab3a72571f6a0995.tar.bz2
Merge pull request #2142 from reitermarkus/spec-link
Convert `brew link` test to spec.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/test/cmd/link_spec.rb56
-rw-r--r--Library/Homebrew/test/link_test.rb23
2 files changed, 56 insertions, 23 deletions
diff --git a/Library/Homebrew/test/cmd/link_spec.rb b/Library/Homebrew/test/cmd/link_spec.rb
new file mode 100644
index 000000000..7b85c96dc
--- /dev/null
+++ b/Library/Homebrew/test/cmd/link_spec.rb
@@ -0,0 +1,56 @@
+describe "brew link", :integration_test do
+ it "fails when no argument is given" do
+ expect { brew "link" }
+ .to output(/This command requires a keg argument/).to_stderr
+ .and not_to_output.to_stdout
+ .and be_a_failure
+ end
+
+ it "does not fail if the given Formula is already linked" do
+ setup_test_formula "testball1"
+
+ shutup do
+ expect { brew "install", "testball1" }.to be_a_success
+ expect { brew "link", "testball1" }.to be_a_success
+ end
+ end
+
+ it "links a given Formula" do
+ setup_test_formula "testball1"
+
+ shutup do
+ expect { brew "install", "testball1" }.to be_a_success
+ expect { brew "unlink", "testball1" }.to be_a_success
+ end
+
+ expect { brew "link", "--dry-run", "testball1" }
+ .to output(/Would link/).to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
+
+ expect { brew "link", "--dry-run", "--overwrite", "testball1" }
+ .to output(/Would remove/).to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
+
+ expect { brew "link", "testball1" }
+ .to output(/Linking/).to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
+ end
+
+ it "refuses to link keg-only Formulae" do
+ setup_test_formula "testball1", <<-EOS.undent
+ keg_only "just because"
+ EOS
+
+ shutup do
+ expect { brew "install", "testball1" }.to be_a_success
+ end
+
+ expect { brew "link", "testball1" }
+ .to output(/testball1 is keg-only/).to_stderr
+ .and output(/Note that doing so can interfere with building software\./).to_stdout
+ .and be_a_success
+ end
+end
diff --git a/Library/Homebrew/test/link_test.rb b/Library/Homebrew/test/link_test.rb
deleted file mode 100644
index 062caa0c0..000000000
--- a/Library/Homebrew/test/link_test.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestLink < IntegrationCommandTestCase
- def test_link
- assert_match "This command requires a keg argument", cmd_fail("link")
-
- setup_test_formula "testball1"
- cmd("install", "testball1")
- cmd("link", "testball1")
-
- cmd("unlink", "testball1")
- assert_match "Would link", cmd("link", "--dry-run", "testball1")
- assert_match "Would remove",
- cmd("link", "--dry-run", "--overwrite", "testball1")
- assert_match "Linking", cmd("link", "testball1")
-
- setup_test_formula "testball2", <<-EOS.undent
- keg_only "just because"
- EOS
- cmd("install", "testball2")
- assert_match "testball2 is keg-only", cmd("link", "testball2")
- end
-end