diff options
| author | Markus Reiter | 2017-02-28 10:34:21 +0100 | 
|---|---|---|
| committer | GitHub | 2017-02-28 10:34:21 +0100 | 
| commit | e723bdeaaea8b9aa9b4cd81d95b2ccfef35a5ce6 (patch) | |
| tree | 29cbae570d2c2185bb1955071604c5b816d47509 /Library/Homebrew | |
| parent | 5498f5369c22f1550a105050f2cb3bc12c83d598 (diff) | |
| parent | 83c422794a4cbd0544ca8b967c23235c8edef034 (diff) | |
| download | brew-e723bdeaaea8b9aa9b4cd81d95b2ccfef35a5ce6.tar.bz2 | |
Merge pull request #2227 from reitermarkus/spec-formula_installer_bottle
Convert `formula_installer_bottle` test to spec.
Diffstat (limited to 'Library/Homebrew')
| -rw-r--r-- | Library/Homebrew/test/formula_installer_bottle_spec.rb | 81 | ||||
| -rw-r--r-- | Library/Homebrew/test/formula_installer_bottle_test.rb | 78 | 
2 files changed, 81 insertions, 78 deletions
diff --git a/Library/Homebrew/test/formula_installer_bottle_spec.rb b/Library/Homebrew/test/formula_installer_bottle_spec.rb new file mode 100644 index 000000000..8409e1ac7 --- /dev/null +++ b/Library/Homebrew/test/formula_installer_bottle_spec.rb @@ -0,0 +1,81 @@ +require "formula" +require "formula_installer" +require "keg" +require "tab" +require "test/support/fixtures/testball" +require "test/support/fixtures/testball_bottle" + +RSpec::Matchers.alias_matcher :pour_bottle, :be_pour_bottle + +describe FormulaInstaller do +  matcher :be_poured_from_bottle do +    match(&:poured_from_bottle) +  end + +  def temporarily_install_bottle(formula) +    expect(formula).not_to be_installed +    expect(formula).to be_bottled +    expect(formula).to pour_bottle + +    shutup do +      described_class.new(formula).install +    end + +    keg = Keg.new(formula.prefix) + +    expect(formula).to be_installed + +    begin +      expect(Tab.for_keg(keg)).to be_poured_from_bottle + +      yield formula +    ensure +      keg.unlink +      keg.uninstall +      formula.clear_cache +      formula.bottle.clear_cache +    end + +    expect(keg).not_to exist +    expect(formula).not_to be_installed +  end + +  specify "basic bottle install" do +    allow(DevelopmentTools).to receive(:installed?).and_return(false) + +    temporarily_install_bottle(TestballBottle.new) do |f| +      # Copied directly from formula_installer_spec.rb +      # as we expect the same behavior. + +      # Test that things made it into the Keg +      expect(f.bin).to be_a_directory + +      expect(f.libexec).to be_a_directory + +      expect(f.prefix/"main.c").not_to exist + +      # Test that things made it into the Cellar +      keg = Keg.new f.prefix +      keg.link + +      bin = HOMEBREW_PREFIX/"bin" +      expect(bin).to be_a_directory +    end +  end + +  specify "build tools error" do +    allow(DevelopmentTools).to receive(:installed?).and_return(false) + +    # Testball doesn't have a bottle block, so use it to test this behavior +    formula = Testball.new + +    expect(formula).not_to be_installed +    expect(formula).not_to be_bottled + +    expect { +      FormulaInstaller.new(formula).install +    }.to raise_error(BuildToolsError) + +    expect(formula).not_to be_installed +  end +end diff --git a/Library/Homebrew/test/formula_installer_bottle_test.rb b/Library/Homebrew/test/formula_installer_bottle_test.rb deleted file mode 100644 index 6a891f159..000000000 --- a/Library/Homebrew/test/formula_installer_bottle_test.rb +++ /dev/null @@ -1,78 +0,0 @@ -require "testing_env" -require "formula" -require "formula_installer" -require "keg" -require "tab" -require "test/support/fixtures/testball" -require "test/support/fixtures/testball_bottle" - -class InstallBottleTests < Homebrew::TestCase -  def temporary_bottle_install(formula) -    refute_predicate formula, :installed? -    assert_predicate formula, :bottled? -    assert_predicate formula, :pour_bottle? - -    installer = FormulaInstaller.new(formula) - -    shutup { installer.install } - -    keg = Keg.new(formula.prefix) - -    assert_predicate formula, :installed? - -    begin -      assert_predicate Tab.for_keg(keg), :poured_from_bottle - -      yield formula -    ensure -      keg.unlink -      keg.uninstall -      formula.clear_cache -      formula.bottle.clear_cache -    end - -    refute_predicate keg, :exist? -    refute_predicate formula, :installed? -  end - -  def test_a_basic_bottle_install -    DevelopmentTools.stubs(:installed?).returns(false) - -    temporary_bottle_install(TestballBottle.new) do |f| -      # Copied directly from test_formula_installer.rb as we expect -      # the same behavior - -      # Test that things made it into the Keg -      assert_predicate f.bin, :directory? - -      assert_predicate f.libexec, :directory? - -      refute_predicate f.prefix+"main.c", :exist? - -      # Test that things make it into the Cellar -      keg = Keg.new f.prefix -      keg.link - -      bin = HOMEBREW_PREFIX+"bin" -      assert_predicate bin, :directory? -    end -  end - -  def test_build_tools_error -    DevelopmentTools.stubs(:installed?).returns(false) - -    # Testball doesn't have a bottle block, so use it to test this behavior -    formula = Testball.new - -    refute_predicate formula, :installed? -    refute_predicate formula, :bottled? - -    installer = FormulaInstaller.new(formula) - -    assert_raises(BuildToolsError) do -      installer.install -    end - -    refute_predicate formula, :installed? -  end -end  | 
