Skip to content
Snippets Groups Projects
Commit 2a750619 authored by Markus Reiter's avatar Markus Reiter Committed by GitHub
Browse files

Merge pull request #2208 from reitermarkus/spec-uninstall

Convert `brew uninstall` test to spec.
parents c66b840f 3ae115bf
No related branches found
No related tags found
No related merge requests found
require "cmd/uninstall"
describe "brew uninstall", :integration_test do
it "uninstalls a given Formula" do
shutup do
......@@ -10,3 +12,65 @@ describe "brew uninstall", :integration_test do
.and be_a_success
end
end
describe Homebrew do
let(:dependency) { formula("dependency") { url "f-1" } }
let(:dependent) do
formula("dependent") do
url "f-1"
depends_on "dependency"
end
end
let(:opts) { { dependency.rack => [Keg.new(dependency.installed_prefix)] } }
before(:each) do
[dependency, dependent].each do |f|
f.installed_prefix.mkpath
Keg.new(f.installed_prefix).optlink
end
tab = Tab.empty
tab.homebrew_version = "1.1.6"
tab.tabfile = dependent.installed_prefix/Tab::FILENAME
tab.runtime_dependencies = [
{ "full_name" => "dependency", "version" => "1" },
]
tab.write
stub_formula_loader dependency
stub_formula_loader dependent
end
describe "::handle_unsatisfied_dependents" do
specify "when developer" do
expect {
described_class.handle_unsatisfied_dependents(opts)
}.to output(/Warning/).to_stderr
expect(described_class).not_to have_failed
end
specify "when not developer" do
run_as_not_developer do
expect {
described_class.handle_unsatisfied_dependents(opts)
}.to output(/Error/).to_stderr
expect(described_class).to have_failed
end
end
specify "when not developer and --ignore-dependencies is specified" do
ARGV << "--ignore-dependencies"
run_as_not_developer do
expect {
described_class.handle_unsatisfied_dependents(opts)
}.not_to output.to_stderr
expect(described_class).not_to have_failed
end
end
end
end
require "testing_env"
require "cmd/uninstall"
class UninstallTests < Homebrew::TestCase
def setup
super
@dependency = formula("dependency") { url "f-1" }
@dependent = formula("dependent") do
url "f-1"
depends_on "dependency"
end
[@dependency, @dependent].each do |f|
f.installed_prefix.mkpath
Keg.new(f.installed_prefix).optlink
end
tab = Tab.empty
tab.homebrew_version = "1.1.6"
tab.tabfile = @dependent.installed_prefix/Tab::FILENAME
tab.runtime_dependencies = [
{ "full_name" => "dependency", "version" => "1" },
]
tab.write
stub_formula_loader @dependency
stub_formula_loader @dependent
end
def teardown
Homebrew.failed = false
super
end
def handle_unsatisfied_dependents
capture_stderr do
opts = { @dependency.rack => [Keg.new(@dependency.installed_prefix)] }
Homebrew.handle_unsatisfied_dependents(opts)
end
end
def test_check_for_testball_f2s_when_developer
assert_match "Warning", handle_unsatisfied_dependents
refute_predicate Homebrew, :failed?
end
def test_check_for_dependents_when_not_developer
run_as_not_developer do
assert_match "Error", handle_unsatisfied_dependents
assert_predicate Homebrew, :failed?
end
end
def test_check_for_dependents_when_ignore_dependencies
ARGV << "--ignore-dependencies"
run_as_not_developer do
assert_empty handle_unsatisfied_dependents
refute_predicate Homebrew, :failed?
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment