aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMarkus Reiter2017-02-24 17:07:16 +0100
committerGitHub2017-02-24 17:07:16 +0100
commit30f5e3850c5de97fe056ccd5dd018928dc7a50cc (patch)
tree810f28f6bd92748a9becf9be549c5e48594c852c /Library
parentefa675f532467d44256bc6f1187413a051d4dd4e (diff)
parent657d3f2adebcf60ac09b9bb98b28d366923e1fea (diff)
downloadbrew-30f5e3850c5de97fe056ccd5dd018928dc7a50cc.tar.bz2
Merge pull request #2140 from reitermarkus/spec-reinstall
Convert `brew reinstall` test to spec.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/test/cmd/reinstall_spec.rb47
-rw-r--r--Library/Homebrew/test/reinstall_pinned_test.rb15
-rw-r--r--Library/Homebrew/test/reinstall_test.rb24
3 files changed, 47 insertions, 39 deletions
diff --git a/Library/Homebrew/test/cmd/reinstall_spec.rb b/Library/Homebrew/test/cmd/reinstall_spec.rb
new file mode 100644
index 000000000..74d36bbb8
--- /dev/null
+++ b/Library/Homebrew/test/cmd/reinstall_spec.rb
@@ -0,0 +1,47 @@
+require "extend/ENV"
+
+describe "brew reinstall", :integration_test do
+ let(:bin) { (HOMEBREW_PREFIX/"bin").realpath }
+ let(:path) { "#{bin}#{File::PATH_SEPARATOR}#{ENV["PATH"]}" }
+
+ before(:each) do
+ setup_test_formula "testball"
+
+ shutup do
+ expect { brew "install", "testball", "--with-foo" }.to be_a_success
+ end
+ end
+
+ it "reinstalls a Formula" do
+ foo_dir = HOMEBREW_CELLAR/"testball/0.1/foo"
+ expect(foo_dir).to exist
+ foo_dir.rmtree
+
+ expect { brew "reinstall", "testball", "PATH" => path }
+ .to output(/Reinstalling testball --with-foo/).to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
+
+ expect(foo_dir).to exist
+ end
+
+ it "reinstalls a Formula even when one of the options is invalid" do
+ expect { brew "reinstall", "testball", "--with-fo", "PATH" => path }
+ .to output(/Reinstalling testball --with-foo/).to_stdout
+ .and output(/testball: this formula has no \-\-with-fo option so it will be ignored!/).to_stderr
+ .and be_a_success
+ end
+
+ it "refuses to reinstall a pinned Formula, but doesn't fail" do
+ (HOMEBREW_CELLAR/"testball/0.1").mkpath
+ HOMEBREW_PINNED_KEGS.mkpath
+ FileUtils.ln_s HOMEBREW_CELLAR/"testball/0.1", HOMEBREW_PINNED_KEGS/"testball"
+
+ expect { brew "reinstall", "testball" }
+ .to output(/testball is pinned. You must unpin it to reinstall./).to_stderr
+ .and not_to_output.to_stdout
+ .and be_a_success
+
+ HOMEBREW_PINNED_KEGS.rmtree
+ end
+end
diff --git a/Library/Homebrew/test/reinstall_pinned_test.rb b/Library/Homebrew/test/reinstall_pinned_test.rb
deleted file mode 100644
index 80f5518ea..000000000
--- a/Library/Homebrew/test/reinstall_pinned_test.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestReinstallPinned < IntegrationCommandTestCase
- def test_reinstall_pinned
- setup_test_formula "testball"
-
- HOMEBREW_CELLAR.join("testball/0.1").mkpath
- HOMEBREW_PINNED_KEGS.mkpath
- FileUtils.ln_s HOMEBREW_CELLAR.join("testball/0.1"), HOMEBREW_PINNED_KEGS/"testball"
-
- assert_match "testball is pinned. You must unpin it to reinstall.", cmd("reinstall", "testball")
-
- HOMEBREW_PINNED_KEGS.rmtree
- end
-end
diff --git a/Library/Homebrew/test/reinstall_test.rb b/Library/Homebrew/test/reinstall_test.rb
deleted file mode 100644
index 2906983c3..000000000
--- a/Library/Homebrew/test/reinstall_test.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestReinstall < IntegrationCommandTestCase
- def test_reinstall
- setup_test_formula "testball"
-
- cmd("install", "testball", "--with-foo")
- foo_dir = HOMEBREW_CELLAR/"testball/0.1/foo"
- assert foo_dir.exist?
- foo_dir.rmtree
- assert_match "Reinstalling testball --with-foo",
- cmd("reinstall", "testball")
- assert foo_dir.exist?
- end
-
- def test_reinstall_with_invalid_option
- setup_test_formula "testball"
-
- cmd("install", "testball", "--with-foo")
-
- assert_match "testball: this formula has no --with-fo option so it will be ignored!",
- cmd("reinstall", "testball", "--with-fo")
- end
-end