Skip to content
Snippets Groups Projects
Commit 83c42279 authored by Markus Reiter's avatar Markus Reiter
Browse files

Convert `formula_installer_bottle` test to spec.

parent 14ae87d5
No related branches found
No related tags found
No related merge requests found
require "testing_env"
require "formula" require "formula"
require "formula_installer" require "formula_installer"
require "keg" require "keg"
...@@ -6,22 +5,28 @@ require "tab" ...@@ -6,22 +5,28 @@ require "tab"
require "test/support/fixtures/testball" require "test/support/fixtures/testball"
require "test/support/fixtures/testball_bottle" require "test/support/fixtures/testball_bottle"
class InstallBottleTests < Homebrew::TestCase RSpec::Matchers.alias_matcher :pour_bottle, :be_pour_bottle
def temporary_bottle_install(formula)
refute_predicate formula, :installed?
assert_predicate formula, :bottled?
assert_predicate formula, :pour_bottle?
installer = FormulaInstaller.new(formula) 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 { installer.install } shutup do
described_class.new(formula).install
end
keg = Keg.new(formula.prefix) keg = Keg.new(formula.prefix)
assert_predicate formula, :installed? expect(formula).to be_installed
begin begin
assert_predicate Tab.for_keg(keg), :poured_from_bottle expect(Tab.for_keg(keg)).to be_poured_from_bottle
yield formula yield formula
ensure ensure
...@@ -31,48 +36,46 @@ class InstallBottleTests < Homebrew::TestCase ...@@ -31,48 +36,46 @@ class InstallBottleTests < Homebrew::TestCase
formula.bottle.clear_cache formula.bottle.clear_cache
end end
refute_predicate keg, :exist? expect(keg).not_to exist
refute_predicate formula, :installed? expect(formula).not_to be_installed
end end
def test_a_basic_bottle_install specify "basic bottle install" do
DevelopmentTools.stubs(:installed?).returns(false) allow(DevelopmentTools).to receive(:installed?).and_return(false)
temporary_bottle_install(TestballBottle.new) do |f| temporarily_install_bottle(TestballBottle.new) do |f|
# Copied directly from test_formula_installer.rb as we expect # Copied directly from formula_installer_spec.rb
# the same behavior # as we expect the same behavior.
# Test that things made it into the Keg # Test that things made it into the Keg
assert_predicate f.bin, :directory? expect(f.bin).to be_a_directory
assert_predicate f.libexec, :directory? expect(f.libexec).to be_a_directory
refute_predicate f.prefix+"main.c", :exist? expect(f.prefix/"main.c").not_to exist
# Test that things make it into the Cellar # Test that things made it into the Cellar
keg = Keg.new f.prefix keg = Keg.new f.prefix
keg.link keg.link
bin = HOMEBREW_PREFIX+"bin" bin = HOMEBREW_PREFIX/"bin"
assert_predicate bin, :directory? expect(bin).to be_a_directory
end end
end end
def test_build_tools_error specify "build tools error" do
DevelopmentTools.stubs(:installed?).returns(false) allow(DevelopmentTools).to receive(:installed?).and_return(false)
# Testball doesn't have a bottle block, so use it to test this behavior # Testball doesn't have a bottle block, so use it to test this behavior
formula = Testball.new formula = Testball.new
refute_predicate formula, :installed? expect(formula).not_to be_installed
refute_predicate formula, :bottled? expect(formula).not_to be_bottled
installer = FormulaInstaller.new(formula) expect {
FormulaInstaller.new(formula).install
assert_raises(BuildToolsError) do }.to raise_error(BuildToolsError)
installer.install
end
refute_predicate formula, :installed? expect(formula).not_to be_installed
end 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