Merge pull request #4068 from reitermarkus/spec

Refactor and fix style for some specs.
This commit is contained in:
Markus Reiter 2018-04-21 18:26:02 +02:00 committed by GitHub
commit 1669111bec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 407 additions and 341 deletions

View File

@ -88,3 +88,7 @@ Style/HashSyntax:
# so many of these in formulae but none in here
Style/TrailingBodyOnMethodDefinition:
Enabled: true
Rspec/ExpectActual:
Exclude:
- 'test/missing_formula_spec.rb'

View File

@ -32,7 +32,7 @@ class PATH
end
def to_ary
@paths
@paths.dup.to_ary
end
alias to_a to_ary

View File

@ -60,7 +60,7 @@ module Homebrew
rescue FormulaUnavailableError => e
ofail e.message
# No formula with this name, try a missing formula lookup
if (reason = Homebrew::MissingFormula.reason(f))
if (reason = MissingFormula.reason(f))
$stderr.puts reason
end
end

View File

@ -257,7 +257,7 @@ module Homebrew
end
ofail e.message
if (reason = Homebrew::MissingFormula.reason(e.name))
if (reason = MissingFormula.reason(e.name))
$stderr.puts reason
return
end

View File

@ -64,7 +64,7 @@ module Homebrew
count = local_results.length + tap_results.length
ohai "Searching blacklisted, migrated and deleted formulae..."
if reason = Homebrew::MissingFormula.reason(query, silent: true)
if reason = MissingFormula.reason(query, silent: true)
if count.positive?
puts
puts "If you meant #{query.inspect} specifically:"

View File

@ -308,7 +308,7 @@ class FormulaAuditor
name = formula.name
if Homebrew::MissingFormula.blacklisted_reason(name)
if MissingFormula.blacklisted_reason(name)
problem "'#{name}' is blacklisted."
end

View File

@ -65,7 +65,7 @@ module Homebrew
# Don't allow blacklisted formula, or names that shadow aliases,
# unless --force is specified.
unless ARGV.force?
if reason = Homebrew::MissingFormula.blacklisted_reason(fc.name)
if reason = MissingFormula.blacklisted_reason(fc.name)
raise "#{fc.name} is blacklisted for creation.\n#{reason}\nIf you really want to create this formula use --force."
end

View File

@ -113,6 +113,7 @@ module Homebrew
end
unless OS.linux?
args << "--tag" << "~needs_linux"
files = files.reject { |p| p =~ %r{^test/os/linux(/.*|_spec\.rb)$} }
end

View File

@ -167,15 +167,15 @@ module Hardware
def intel_can_run?(arch)
case arch
when :ppc
when *PPC_32BIT_ARCHS
# Rosetta is still available
MacOS.version < :lion
when :ppc64
when *PPC_64BIT_ARCHS
# Rosetta never supported PPC64
false
when :x86_64
when *INTEL_64BIT_ARCHS
Hardware::CPU.is_64_bit?
when :i386
when *INTEL_32BIT_ARCHS
true
else # dunno
false
@ -184,9 +184,9 @@ module Hardware
def ppc_can_run?(arch)
case arch
when :ppc
when *PPC_32BIT_ARCHS
true
when :ppc64
when *PPC_64BIT_ARCHS
Hardware::CPU.is_64_bit?
else
# Intel is never supported

View File

@ -0,0 +1,15 @@
require "requirement"
class NonBinaryOsxfuseRequirement < Requirement
fatal true
satisfy(build_env: false) do
HOMEBREW_PREFIX.to_s != "/usr/local" || !OsxfuseRequirement.binary_osxfuse_installed?
end
def message
<<~EOS
osxfuse is already installed from the binary distribution and
conflicts with this formula.
EOS
end
end

View File

@ -19,15 +19,3 @@ class OsxfuseRequirement < Requirement
end
end
end
class NonBinaryOsxfuseRequirement < Requirement
fatal true
satisfy(build_env: false) { HOMEBREW_PREFIX.to_s != "/usr/local" || !OsxfuseRequirement.binary_osxfuse_installed? }
def message
<<~EOS
osxfuse is already installed from the binary distribution and
conflicts with this formula.
EOS
end
end

View File

@ -0,0 +1,3 @@
if OS.mac?
require "extend/os/mac/requirements/non_binary_osxfuse_requirement"
end

View File

@ -2,7 +2,7 @@ module Hardware
class CPU
INTEL_32BIT_ARCHS = [:i386].freeze
INTEL_64BIT_ARCHS = [:x86_64].freeze
PPC_32BIT_ARCHS = [:ppc, :ppc7400, :ppc7450, :ppc970].freeze
PPC_32BIT_ARCHS = [:ppc, :ppc32, :ppc7400, :ppc7450, :ppc970].freeze
PPC_64BIT_ARCHS = [:ppc64].freeze
class << self
@ -118,9 +118,9 @@ module Hardware
if is_32_bit?
arch_32_bit == arch
elsif intel?
[:i386, :x86_64].include? arch
(INTEL_32BIT_ARCHS + INTEL_64BIT_ARCHS).include?(arch)
elsif ppc?
[:ppc, :ppc64].include? arch
(PPC_32BIT_ARCHS + PPC_64BIT_ARCHS).include?(arch)
else
false
end

View File

@ -0,0 +1,7 @@
require "requirement"
class NonBinaryOsxfuseRequirement < Requirement
fatal false
end
require "extend/os/requirements/non_binary_osxfuse_requirement"

View File

@ -5,8 +5,4 @@ class OsxfuseRequirement < Requirement
fatal true
end
class NonBinaryOsxfuseRequirement < Requirement
fatal false
end
require "extend/os/requirements/osxfuse_requirement"

View File

@ -36,7 +36,7 @@ GEM
rspec-support (3.7.1)
rspec-wait (0.0.9)
rspec (>= 3, < 4)
rubocop (0.54.0)
rubocop (0.55.0)
parallel (~> 1.10)
parser (>= 2.5)
powerpack (~> 0.1)
@ -62,7 +62,7 @@ DEPENDENCIES
rspec-its
rspec-retry
rspec-wait
rubocop (= 0.54.0)
rubocop (= 0.55.0)
simplecov
BUNDLED WITH

View File

@ -23,6 +23,13 @@ describe PATH do
it "returns a PATH array" do
expect(described_class.new("/path1", "/path2").to_ary).to eq(["/path1", "/path2"])
end
it "does not allow mutating the original" do
path = described_class.new("/path1", "/path2")
path.to_ary << "/path3"
expect(path).not_to include("/path3")
end
end
describe "#to_str" do
@ -61,6 +68,12 @@ describe PATH do
end
end
describe "#==" do
it "always returns false when comparing against something which does not respons to `#to_ary` or `#to_str`" do
expect(described_class.new).not_to eq Object.new
end
end
describe "#include?" do
it "returns true if a path is included" do
path = described_class.new("/path1", "/path2")

View File

@ -7,7 +7,7 @@ describe Formulary do
let(:formula_path) { CoreTap.new.formula_dir/"#{formula_name}.rb" }
let(:formula_content) do
<<~EOS
class #{subject.class_s(formula_name)} < Formula
class #{described_class.class_s(formula_name)} < Formula
url "file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1.tbz"
sha256 TESTBALL_SHA256
@ -29,18 +29,27 @@ describe Formulary do
describe "::class_s" do
it "replaces '+' with 'x'" do
expect(subject.class_s("foo++")).to eq("Fooxx")
expect(described_class.class_s("foo++")).to eq("Fooxx")
end
it "converts a string to PascalCase" do
expect(subject.class_s("shell.fm")).to eq("ShellFm")
expect(subject.class_s("s-lang")).to eq("SLang")
expect(subject.class_s("pkg-config")).to eq("PkgConfig")
expect(subject.class_s("foo_bar")).to eq("FooBar")
it "converts a string with dots to PascalCase" do
expect(described_class.class_s("shell.fm")).to eq("ShellFm")
end
it "converts a string with hyphens to PascalCase" do
expect(described_class.class_s("pkg-config")).to eq("PkgConfig")
end
it "converts a string with a single letter separated by a hyphen to PascalCase" do
expect(described_class.class_s("s-lang")).to eq("SLang")
end
it "converts a string with underscores to PascalCase" do
expect(described_class.class_s("foo_bar")).to eq("FooBar")
end
it "replaces '@' with 'AT'" do
expect(subject.class_s("openssl@1.1")).to eq("OpensslAT11")
expect(described_class.class_s("openssl@1.1")).to eq("OpensslAT11")
end
end
@ -50,135 +59,163 @@ describe Formulary do
end
it "returns a Formula" do
expect(subject.factory(formula_name)).to be_kind_of(Formula)
expect(described_class.factory(formula_name)).to be_kind_of(Formula)
end
it "returns a Formula when given a fully qualified name" do
expect(subject.factory("homebrew/core/#{formula_name}")).to be_kind_of(Formula)
expect(described_class.factory("homebrew/core/#{formula_name}")).to be_kind_of(Formula)
end
it "raises an error if the Formula cannot be found" do
expect {
subject.factory("not_existed_formula")
described_class.factory("not_existed_formula")
}.to raise_error(FormulaUnavailableError)
end
context "if the Formula has the wrong class" do
context "when the Formula has the wrong class" do
let(:formula_name) { "giraffe" }
let(:formula_content) do
<<~EOS
class Wrong#{subject.class_s(formula_name)} < Formula
class Wrong#{described_class.class_s(formula_name)} < Formula
end
EOS
end
it "raises an error" do
expect {
subject.factory(formula_name)
described_class.factory(formula_name)
}.to raise_error(FormulaClassUnavailableError)
end
end
it "returns a Formula when given a path" do
expect(subject.factory(formula_path)).to be_kind_of(Formula)
expect(described_class.factory(formula_path)).to be_kind_of(Formula)
end
it "returns a Formula when given a URL" do
formula = subject.factory("file://#{formula_path}")
formula = described_class.factory("file://#{formula_path}")
expect(formula).to be_kind_of(Formula)
end
it "returns a Formula when given a bottle" do
formula = subject.factory(bottle)
context "when given a bottle" do
subject(:formula) { described_class.factory(bottle) }
it "returns a Formula" do
expect(formula).to be_kind_of(Formula)
end
it "calling #local_bottle_path on the returned Formula returns the bottle path" do
expect(formula.local_bottle_path).to eq(bottle.realpath)
end
end
it "returns a Formula when given an alias" do
alias_dir = CoreTap.instance.alias_dir
context "when given an alias" do
subject(:formula) { described_class.factory("foo") }
let(:alias_dir) { CoreTap.instance.alias_dir.tap(&:mkpath) }
let(:alias_path) { alias_dir/"foo" }
before do
alias_dir.mkpath
alias_path = alias_dir/"foo"
FileUtils.ln_s formula_path, alias_path
result = subject.factory("foo")
expect(result).to be_kind_of(Formula)
expect(result.alias_path).to eq(alias_path.to_s)
end
it "returns a Formula" do
expect(formula).to be_kind_of(Formula)
end
it "calling #alias_path on the returned Formula returns the alias path" do
expect(formula.alias_path).to eq(alias_path.to_s)
end
end
context "with installed Formula" do
let(:formula) { subject.factory(formula_path) }
let(:formula) { described_class.factory(formula_path) }
let(:installer) { FormulaInstaller.new(formula) }
it "returns a Formula when given a rack" do
installer.install
f = subject.from_rack(formula.rack)
f = described_class.from_rack(formula.rack)
expect(f).to be_kind_of(Formula)
expect(f.build).to be_kind_of(Tab)
end
it "returns a Formula when given a Keg" do
installer.install
keg = Keg.new(formula.prefix)
f = subject.from_keg(keg)
f = described_class.from_keg(keg)
expect(f).to be_kind_of(Formula)
expect(f.build).to be_kind_of(Tab)
end
end
context "from Tap" do
context "when loading from Tap" do
let(:tap) { Tap.new("homebrew", "foo") }
let(:another_tap) { Tap.new("homebrew", "bar") }
let(:formula_path) { tap.path/"#{formula_name}.rb" }
it "returns a Formula when given a name" do
expect(subject.factory(formula_name)).to be_kind_of(Formula)
expect(described_class.factory(formula_name)).to be_kind_of(Formula)
end
it "returns a Formula from an Alias path" do
alias_dir = tap.path/"Aliases"
alias_dir.mkpath
FileUtils.ln_s formula_path, alias_dir/"bar"
expect(subject.factory("bar")).to be_kind_of(Formula)
expect(described_class.factory("bar")).to be_kind_of(Formula)
end
it "raises an error when the Formula cannot be found" do
expect {
subject.factory("#{tap}/not_existed_formula")
described_class.factory("#{tap}/not_existed_formula")
}.to raise_error(TapFormulaUnavailableError)
end
it "returns a Formula when given a fully qualified name" do
expect(subject.factory("#{tap}/#{formula_name}")).to be_kind_of(Formula)
expect(described_class.factory("#{tap}/#{formula_name}")).to be_kind_of(Formula)
end
it "raises an error if a Formula is in multiple Taps" do
begin
another_tap = Tap.new("homebrew", "bar")
(another_tap.path/"#{formula_name}.rb").write formula_content
expect {
subject.factory(formula_name)
described_class.factory(formula_name)
}.to raise_error(TapFormulaAmbiguityError)
ensure
another_tap.path.rmtree
end
end
end
end
specify "::from_contents" do
expect(subject.from_contents(formula_name, formula_path, formula_content)).to be_kind_of(Formula)
expect(described_class.from_contents(formula_name, formula_path, formula_content)).to be_kind_of(Formula)
end
specify "::to_rack" do
expect(subject.to_rack(formula_name)).to eq(HOMEBREW_CELLAR/formula_name)
describe "::to_rack" do
alias_matcher :exist, :be_exist
(HOMEBREW_CELLAR/formula_name).mkpath
expect(subject.to_rack(formula_name)).to eq(HOMEBREW_CELLAR/formula_name)
let(:rack_path) { HOMEBREW_CELLAR/formula_name }
context "when the Rack does not exist" do
it "returns the Rack" do
expect(described_class.to_rack(formula_name)).to eq(rack_path)
end
end
context "when the Rack exists" do
before do
rack_path.mkpath
end
it "returns the Rack" do
expect(described_class.to_rack(formula_name)).to eq(rack_path)
end
end
it "raises an error if the Formula is not available" do
expect {
subject.to_rack("a/b/#{formula_name}")
described_class.to_rack("a/b/#{formula_name}")
}.to raise_error(TapFormulaUnavailableError)
end
end
describe "::find_with_priority" do
let(:core_path) { CoreTap.new.formula_dir/"#{formula_name}.rb" }
@ -191,27 +228,21 @@ describe Formulary do
end
it "prioritizes core Formulae" do
formula = subject.find_with_priority(formula_name)
expect(formula).to be_kind_of(Formula)
formula = described_class.find_with_priority(formula_name)
expect(formula.path).to eq(core_path)
end
it "prioritizes Formulae from pinned Taps" do
begin
tap.pin
formula = subject.find_with_priority(formula_name)
expect(formula).to be_kind_of(Formula)
formula = described_class.find_with_priority(formula_name)
expect(formula.path).to eq(tap_path.realpath)
ensure
tap.pinned_symlink_path.parent.parent.rmtree
end
end
end
describe "::core_path" do
it "returns the path to a Formula in the core tap" do
name = "foo-bar"
expect(subject.core_path(name))
expect(described_class.core_path(name))
.to eq(Pathname.new("#{HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-core/Formula/#{name}.rb"))
end
end

View File

@ -0,0 +1,114 @@
require "hardware"
describe Hardware::CPU do
describe "::type" do
let(:cpu_types) {
[
:intel,
:ppc,
:dunno,
]
}
it "returns the current CPU's type as a symbol, or :dunno if it cannot be detected" do
expect(cpu_types).to include(described_class.type)
end
end
describe "::family" do
let(:cpu_families) {
[
:core,
:core2,
:penryn,
:nehalem,
:arrandale,
:sandybridge,
:ivybridge,
:haswell,
:broadwell,
:skylake,
:kabylake,
:dunno,
]
}
it "returns the current CPU's family name as a symbol, or :dunno if it cannot be detected" do
expect(cpu_families).to include described_class.family
end
end
describe "::can_run?" do
subject { described_class }
matcher :be_able_to_run do |arch|
match do |expected|
allow(expected).to receive(:type).and_return type
allow(expected).to receive(:bits).and_return bits
expect(expected.can_run?(arch)).to be true
end
end
let(:type) { described_class.type }
let(:bits) { described_class.bits }
before do
allow(described_class).to receive(:type).and_return type
allow(described_class).to receive(:bits).and_return bits
end
context "when on an 32-bit Intel machine" do
let(:type) { :intel }
let(:bits) { 32 }
it { is_expected.to be_able_to_run :i386 }
it { is_expected.not_to be_able_to_run :x86_64 }
it { is_expected.not_to be_able_to_run :ppc32 }
it { is_expected.not_to be_able_to_run :ppc64 }
end
context "when on an 64-bit Intel machine" do
let(:type) { :intel }
let(:bits) { 64 }
it { is_expected.to be_able_to_run :i386 }
it { is_expected.to be_able_to_run :x86_64 }
it { is_expected.not_to be_able_to_run :ppc32 }
it { is_expected.not_to be_able_to_run :ppc64 }
end
context "when on a 32-bit PowerPC machine" do
let(:type) { :ppc }
let(:bits) { 32 }
it { is_expected.not_to be_able_to_run :i386 }
it { is_expected.not_to be_able_to_run :x86_64 }
it { is_expected.to be_able_to_run :ppc32 }
it { is_expected.not_to be_able_to_run :ppc64 }
end
context "when on a 64-bit PowerPC machine" do
let(:type) { :ppc }
let(:bits) { 64 }
it { is_expected.not_to be_able_to_run :i386 }
it { is_expected.not_to be_able_to_run :x86_64 }
it { is_expected.to be_able_to_run :ppc32 }
it { is_expected.to be_able_to_run :ppc64 }
end
context "when the CPU type is unknown" do
let(:type) { :dunno }
it { is_expected.not_to be_able_to_run :i386 }
it { is_expected.not_to be_able_to_run :x86_64 }
it { is_expected.not_to be_able_to_run :ppc32 }
it { is_expected.not_to be_able_to_run :ppc64 }
end
context "when the architecture is unknown" do
it { is_expected.not_to be_able_to_run :blah }
end
end
end

View File

@ -1,87 +0,0 @@
require "hardware"
module Hardware
describe CPU do
describe "::type" do
it "returns the current CPU's type as a symbol, or :dunno if it cannot be detected" do
expect(
[
:intel,
:ppc,
:dunno,
],
).to include(described_class.type)
end
end
describe "::family" do
it "returns the current CPU's family name as a symbol, or :dunno if it cannot be detected" do
skip "Needs an Intel CPU." unless described_class.intel?
expect(
[
:core,
:core2,
:penryn,
:nehalem,
:arrandale,
:sandybridge,
:ivybridge,
:haswell,
:broadwell,
:skylake,
:kabylake,
:dunno,
],
).to include(described_class.family)
end
end
describe "::can_run?" do
it "reports that Intel machines can run Intel executables" do
allow(Hardware::CPU).to receive(:type).and_return :intel
allow(Hardware::CPU).to receive(:bits).and_return 64
expect(Hardware::CPU.can_run?(:i386)).to be true
expect(Hardware::CPU.can_run?(:x86_64)).to be true
end
it "reports that PowerPC machines can run PowerPC executables" do
allow(Hardware::CPU).to receive(:type).and_return :ppc
allow(Hardware::CPU).to receive(:bits).and_return 64
expect(Hardware::CPU.can_run?(:ppc)).to be true
expect(Hardware::CPU.can_run?(:ppc64)).to be true
end
it "reports that 32-bit Intel machines can't run x86_64 executables" do
allow(Hardware::CPU).to receive(:type).and_return :intel
allow(Hardware::CPU).to receive(:bits).and_return 32
expect(Hardware::CPU.can_run?(:x86_64)).to be false
end
it "reports that 32-bit PowerPC machines can't run ppc64 executables" do
allow(Hardware::CPU).to receive(:type).and_return :ppc
allow(Hardware::CPU).to receive(:bits).and_return 32
expect(Hardware::CPU.can_run?(:ppc64)).to be false
end
it "identifies that Intel and PowerPC machines can't run each others' executables" do
allow(Hardware::CPU).to receive(:type).and_return :ppc
expect(Hardware::CPU.can_run?(:i386)).to be false
expect(Hardware::CPU.can_run?(:x86_64)).to be false
allow(Hardware::CPU).to receive(:type).and_return :intel
expect(Hardware::CPU.can_run?(:ppc)).to be false
expect(Hardware::CPU.can_run?(:ppc64)).to be false
end
it "returns false for unknown CPU types" do
allow(Hardware::CPU).to receive(:type).and_return :dunno
expect(Hardware::CPU.can_run?(:i386)).to be false
end
it "returns false for unknown arches" do
expect(Hardware::CPU.can_run?(:blah)).to be false
end
end
end
end

View File

@ -17,17 +17,6 @@ describe Keg do
keg
end
around do |example|
begin
@old_stdout = $stdout
$stdout = StringIO.new
example.run
ensure
$stdout = @old_stdout
end
end
let(:dst) { HOMEBREW_PREFIX/"bin"/"helloworld" }
let(:nonexistent) { Pathname.new("/some/nonexistent/path") }
let(:mode) { OpenStruct.new }
@ -96,13 +85,15 @@ describe Keg do
it "only prints what would be done" do
mode.dry_run = true
expect {
expect(keg.link(mode)).to eq(0)
expect(keg).not_to be_linked
}.to output(<<~EOF).to_stdout
#{HOMEBREW_PREFIX}/bin/goodbye_cruel_world
#{HOMEBREW_PREFIX}/bin/helloworld
#{HOMEBREW_PREFIX}/bin/hiworld
EOF
["hiworld", "helloworld", "goodbye_cruel_world"].each do |file|
expect($stdout.string).to match("#{HOMEBREW_PREFIX}/bin/#{file}")
end
expect($stdout.string.lines.count).to eq(3)
expect(keg).not_to be_linked
end
end
@ -145,10 +136,13 @@ describe Keg do
mode.overwrite = true
mode.dry_run = true
expect {
expect(keg.link(mode)).to eq(0)
expect(keg).not_to be_linked
}.to output(<<~EOF).to_stdout
#{dst}
EOF
expect($stdout.string).to eq("#{dst}\n")
expect(keg).not_to be_linked
end
end

View File

@ -1,117 +1,85 @@
require "missing_formula"
describe Homebrew::MissingFormula do
context "::reason" do
describe "::reason" do
subject { described_class.reason("gem") }
it { is_expected.not_to be_nil }
end
context "::blacklisted_reason" do
matcher(:be_blacklisted) do
describe "::blacklisted_reason" do
matcher :be_blacklisted do
match do |expected|
described_class.blacklisted_reason(expected)
end
end
context "rubygems" do
%w[gem rubygem rubygems].each do |s|
subject { s }
specify "RubyGems is blacklisted" do
expect(%w[gem rubygem rubygems]).to all be_blacklisted
end
it { is_expected.to be_blacklisted }
specify "LaTeX is blacklisted" do
expect(%w[latex tex tex-live texlive TexLive]).to all be_blacklisted
end
specify "pip is blacklisted" do
expect("pip").to be_blacklisted
end
specify "PIL is blacklisted" do
expect("pil").to be_blacklisted
end
specify "MacRuby is blacklisted" do
expect("MacRuby").to be_blacklisted
end
specify "lzma is blacklisted" do
expect(%w[lzma liblzma]).to all be_blacklisted
end
specify "gtest is blacklisted" do
expect(%w[gtest googletest google-test]).to all be_blacklisted
end
specify "gmock is blacklisted" do
expect(%w[gmock googlemock google-mock]).to all be_blacklisted
end
specify "sshpass is blacklisted" do
expect("sshpass").to be_blacklisted
end
specify "gsutil is blacklisted" do
expect("gsutil").to be_blacklisted
end
specify "gfortran is blacklisted" do
expect("gfortran").to be_blacklisted
end
specify "play is blacklisted" do
expect("play").to be_blacklisted
end
specify "haskell-platform is blacklisted" do
expect("haskell-platform").to be_blacklisted
end
specify "mysqldump-secure is blacklisted" do
expect("mysqldump-secure").to be_blacklisted
end
specify "ngrok is blacklisted" do
expect("ngrok").to be_blacklisted
end
specify "Xcode is blacklisted", :needs_macos do
expect(%w[xcode Xcode]).to all be_blacklisted
end
end
context "latex" do
%w[latex tex tex-live texlive TexLive].each do |s|
subject { s }
it { is_expected.to be_blacklisted }
end
end
context "pip" do
subject { "pip" }
it { is_expected.to be_blacklisted }
end
context "pil" do
subject { "pil" }
it { is_expected.to be_blacklisted }
end
context "macruby" do
subject { "MacRuby" }
it { is_expected.to be_blacklisted }
end
context "lzma" do
%w[lzma liblzma].each do |s|
subject { s }
it { is_expected.to be_blacklisted }
end
end
context "gtest" do
%w[gtest googletest google-test].each do |s|
subject { s }
it { is_expected.to be_blacklisted }
end
end
context "gmock" do
%w[gmock googlemock google-mock].each do |s|
subject { s }
it { is_expected.to be_blacklisted }
end
end
context "sshpass" do
subject { "sshpass" }
it { is_expected.to be_blacklisted }
end
context "gsutil" do
subject { "gsutil" }
it { is_expected.to be_blacklisted }
end
context "gfortran" do
subject { "gfortran" }
it { is_expected.to be_blacklisted }
end
context "play" do
subject { "play" }
it { is_expected.to be_blacklisted }
end
context "haskell-platform" do
subject { "haskell-platform" }
it { is_expected.to be_blacklisted }
end
context "xcode", :needs_macos do
%w[xcode Xcode].each do |s|
subject { s }
it { is_expected.to be_blacklisted }
end
end
end
context "::tap_migration_reason" do
describe "::tap_migration_reason" do
subject { described_class.tap_migration_reason(formula) }
before do
@ -136,7 +104,7 @@ describe Homebrew::MissingFormula do
end
end
context "::deleted_reason" do
describe "::deleted_reason" do
subject { described_class.deleted_reason(formula, silent: true) }
before do

View File

@ -1,9 +0,0 @@
require "requirements/osxfuse_requirement"
describe OsxfuseRequirement do
subject { described_class.new([]) }
describe "#message" do
its(:message) { is_expected.to match("libfuse is required to install this formula") }
end
end

View File

@ -1,36 +0,0 @@
require "requirements/osxfuse_requirement"
describe OsxfuseRequirement do
subject { described_class.new([]) }
describe "::binary_osxfuse_installed?" do
it "returns false if fuse.h does not exist" do
allow(File).to receive(:exist?).and_return(false)
expect(described_class).not_to be_binary_osxfuse_installed
end
it "returns false if osxfuse include directory is a symlink" do
allow(File).to receive(:exist?).and_return(true)
allow(File).to receive(:symlink?).and_return(true)
expect(described_class).not_to be_binary_osxfuse_installed
end
end
describe "environment" do
it "adds the fuse directories to the appropriate paths" do
expect(ENV).to receive(:append_path).with("PKG_CONFIG_PATH", any_args)
expect(ENV).to receive(:append_path).with("HOMEBREW_LIBRARY_PATHS", any_args)
expect(ENV).to receive(:append_path).with("HOMEBREW_INCLUDE_PATHS", any_args)
subject.modify_build_environment
end
end
end
describe NonBinaryOsxfuseRequirement do
subject { described_class.new([]) }
describe "#message" do
msg = /osxfuse is already installed from the binary distribution/
its(:message) { is_expected.to match(msg) }
end
end

View File

@ -1,18 +0,0 @@
require "requirements/linux_requirement"
require "requirements/macos_requirement"
describe LinuxRequirement do
describe "#satisfied?" do
it "returns true if OS is Linux" do
expect(subject.satisfied?).to eq(OS.linux?)
end
end
end
describe MacOSRequirement do
describe "#satisfied?" do
it "returns true if OS is macOS" do
expect(subject.satisfied?).to eq(OS.mac?)
end
end
end

View File

@ -0,0 +1,11 @@
require "requirements/linux_requirement"
describe LinuxRequirement do
subject(:requirement) { described_class.new }
describe "#satisfied?" do
it "returns true on Linux" do
expect(requirement.satisfied?).to eq(OS.linux?)
end
end
end

View File

@ -0,0 +1,11 @@
require "requirements/macos_requirement"
describe MacOSRequirement do
subject(:requirement) { described_class.new }
describe "#satisfied?" do
it "returns true on macOS" do
expect(requirement.satisfied?).to eq(OS.mac?)
end
end
end

View File

@ -0,0 +1,9 @@
require "requirements/non_binary_osxfuse_requirement"
describe NonBinaryOsxfuseRequirement, :needs_macos do
subject { described_class.new([]) }
describe "#message" do
its(:message) { is_expected.to match("osxfuse is already installed from the binary distribution") }
end
end

View File

@ -0,0 +1,50 @@
require "requirements/osxfuse_requirement"
describe OsxfuseRequirement do
subject(:requirement) { described_class.new([]) }
describe "::binary_osxfuse_installed?", :needs_macos do
alias_matcher :have_binary_osxfuse_installed, :be_binary_osxfuse_installed
it "returns false if fuse.h does not exist" do
allow(File).to receive(:exist?).and_return(false)
expect(described_class).not_to have_binary_osxfuse_installed
end
it "returns false if osxfuse include directory is a symlink" do
allow(File).to receive(:exist?).and_return(true)
allow(File).to receive(:symlink?).and_return(true)
expect(described_class).not_to have_binary_osxfuse_installed
end
end
describe "#modify_build_environment", :needs_macos do
it "adds the fuse directories to PKG_CONFIG_PATH" do
allow(ENV).to receive(:append_path)
requirement.modify_build_environment
expect(ENV).to have_received(:append_path).with("PKG_CONFIG_PATH", any_args)
end
it "adds the fuse directories to HOMEBREW_LIBRARY_PATHS" do
allow(ENV).to receive(:append_path)
requirement.modify_build_environment
expect(ENV).to have_received(:append_path).with("HOMEBREW_LIBRARY_PATHS", any_args)
end
it "adds the fuse directories to HOMEBREW_INCLUDE_PATHS" do
allow(ENV).to receive(:append_path)
requirement.modify_build_environment
expect(ENV).to have_received(:append_path).with("HOMEBREW_INCLUDE_PATHS", any_args)
end
end
describe "#message" do
it "prompts for installation of 'libfuse' on Linux", :needs_linux do
expect(requirement.message).to match("libfuse is required to install this formula")
end
it "prompts for installation of 'osxFuse' on macOS", :needs_macos do
expect(requirement.message).to match("osxfuse.github.io")
end
end
end

View File

@ -130,6 +130,7 @@ RSpec.configure do |config|
HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-foo",
HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-services",
HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-shallow",
HOMEBREW_LIBRARY/"PinnedTaps",
HOMEBREW_REPOSITORY/".git",
CoreTap.instance.path/".git",
CoreTap.instance.alias_dir,