diff options
| author | Markus Reiter | 2017-02-27 16:49:13 +0100 | 
|---|---|---|
| committer | GitHub | 2017-02-27 16:49:13 +0100 | 
| commit | 2a750619b96c744961584bd40996ecb5c94fca3c (patch) | |
| tree | 481d237affc96da23bf9bc684a04a77bb7bff334 | |
| parent | c66b840f7ba26b84fa363674bab55f128e63a56b (diff) | |
| parent | 3ae115bfb370ed5c912f00ac5a7dfc294f1d68e4 (diff) | |
| download | brew-2a750619b96c744961584bd40996ecb5c94fca3c.tar.bz2 | |
Merge pull request #2208 from reitermarkus/spec-uninstall
Convert `brew uninstall` test to spec.
| -rw-r--r-- | Library/Homebrew/test/cmd/uninstall_spec.rb | 64 | ||||
| -rw-r--r-- | Library/Homebrew/test/uninstall_test.rb | 62 | 
2 files changed, 64 insertions, 62 deletions
diff --git a/Library/Homebrew/test/cmd/uninstall_spec.rb b/Library/Homebrew/test/cmd/uninstall_spec.rb index 65f69e802..b9a0d8d40 100644 --- a/Library/Homebrew/test/cmd/uninstall_spec.rb +++ b/Library/Homebrew/test/cmd/uninstall_spec.rb @@ -1,3 +1,5 @@ +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 diff --git a/Library/Homebrew/test/uninstall_test.rb b/Library/Homebrew/test/uninstall_test.rb deleted file mode 100644 index a9230ffac..000000000 --- a/Library/Homebrew/test/uninstall_test.rb +++ /dev/null @@ -1,62 +0,0 @@ -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  | 
