style: remove RSpec/NamedSubject violations
This commit is contained in:
parent
3e00b3ea28
commit
af40e072b0
@ -4,9 +4,9 @@
|
||||
require "extend/ENV"
|
||||
|
||||
shared_examples EnvActivation do
|
||||
subject { env.extend(described_class) }
|
||||
subject(:env) { env_activation.extend(described_class) }
|
||||
|
||||
let(:env) { {}.extend(EnvActivation) }
|
||||
let(:env_activation) { {}.extend(EnvActivation) }
|
||||
|
||||
it "supports switching compilers" do
|
||||
subject.clang
|
||||
@ -180,28 +180,28 @@ describe Superenv do
|
||||
include_examples EnvActivation
|
||||
|
||||
it "initializes deps" do
|
||||
expect(subject.deps).to eq([])
|
||||
expect(subject.keg_only_deps).to eq([])
|
||||
expect(env.deps).to eq([])
|
||||
expect(env.keg_only_deps).to eq([])
|
||||
end
|
||||
|
||||
describe "#cxx11" do
|
||||
it "supports gcc-5" do
|
||||
subject["HOMEBREW_CC"] = "gcc-5"
|
||||
subject.cxx11
|
||||
expect(subject["HOMEBREW_CCCFG"]).to include("x")
|
||||
env["HOMEBREW_CC"] = "gcc-5"
|
||||
env.cxx11
|
||||
expect(env["HOMEBREW_CCCFG"]).to include("x")
|
||||
end
|
||||
|
||||
example "supports gcc-6" do
|
||||
subject["HOMEBREW_CC"] = "gcc-6"
|
||||
subject.cxx11
|
||||
expect(subject["HOMEBREW_CCCFG"]).to include("x")
|
||||
env["HOMEBREW_CC"] = "gcc-6"
|
||||
env.cxx11
|
||||
expect(env["HOMEBREW_CCCFG"]).to include("x")
|
||||
end
|
||||
|
||||
it "supports clang" do
|
||||
subject["HOMEBREW_CC"] = "clang"
|
||||
subject.cxx11
|
||||
expect(subject["HOMEBREW_CCCFG"]).to include("x")
|
||||
expect(subject["HOMEBREW_CCCFG"]).to include("g")
|
||||
env["HOMEBREW_CC"] = "clang"
|
||||
env.cxx11
|
||||
expect(env["HOMEBREW_CCCFG"]).to include("x")
|
||||
expect(env["HOMEBREW_CCCFG"]).to include("g")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -43,11 +43,11 @@ describe BuildEnvironment do
|
||||
end
|
||||
|
||||
describe BuildEnvironment::DSL do
|
||||
subject { double.extend(described_class) }
|
||||
subject(:build_environment_dsl) { double.extend(described_class) }
|
||||
|
||||
context "single argument" do
|
||||
before do
|
||||
subject.instance_eval do
|
||||
build_environment_dsl.instance_eval do
|
||||
env :userpaths
|
||||
end
|
||||
end
|
||||
@ -57,7 +57,7 @@ describe BuildEnvironment do
|
||||
|
||||
context "multiple arguments" do
|
||||
before do
|
||||
subject.instance_eval do
|
||||
build_environment_dsl.instance_eval do
|
||||
env :userpaths, :std
|
||||
end
|
||||
end
|
||||
|
||||
@ -8,7 +8,7 @@ describe BuildOptions do
|
||||
alias_matcher :be_built_with, :be_with
|
||||
alias_matcher :be_built_without, :be_without
|
||||
|
||||
subject { described_class.new(args, opts) }
|
||||
subject(:build_options) { described_class.new(args, opts) }
|
||||
|
||||
let(:bad_build) { described_class.new(bad_args, opts) }
|
||||
let(:args) { Options.create(%w[--with-foo --with-bar --without-qux]) }
|
||||
@ -16,22 +16,22 @@ describe BuildOptions do
|
||||
let(:bad_args) { Options.create(%w[--with-foo --with-bar --without-bas --without-qux --without-abc]) }
|
||||
|
||||
specify "#with?" do
|
||||
expect(subject).to be_built_with("foo")
|
||||
expect(subject).to be_built_with("bar")
|
||||
expect(subject).to be_built_with("baz")
|
||||
expect(build_options).to be_built_with("foo")
|
||||
expect(build_options).to be_built_with("bar")
|
||||
expect(build_options).to be_built_with("baz")
|
||||
end
|
||||
|
||||
specify "#without?" do
|
||||
expect(subject).to be_built_without("qux")
|
||||
expect(subject).to be_built_without("xyz")
|
||||
expect(build_options).to be_built_without("qux")
|
||||
expect(build_options).to be_built_without("xyz")
|
||||
end
|
||||
|
||||
specify "#used_options" do
|
||||
expect(subject.used_options).to include("--with-foo")
|
||||
expect(subject.used_options).to include("--with-bar")
|
||||
expect(build_options.used_options).to include("--with-foo")
|
||||
expect(build_options.used_options).to include("--with-bar")
|
||||
end
|
||||
|
||||
specify "#unused_options" do
|
||||
expect(subject.unused_options).to include("--without-baz")
|
||||
expect(build_options.unused_options).to include("--without-baz")
|
||||
end
|
||||
end
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
require "cache_store"
|
||||
|
||||
describe CacheStoreDatabase do
|
||||
subject { described_class.new(:sample) }
|
||||
subject(:sample_db) { described_class.new(:sample) }
|
||||
|
||||
describe "self.use" do
|
||||
let(:type) { :test }
|
||||
@ -22,12 +22,12 @@ describe CacheStoreDatabase do
|
||||
|
||||
it "sets the value in the `CacheStoreDatabase`" do
|
||||
allow(File).to receive(:write)
|
||||
allow(subject).to receive(:created?).and_return(true)
|
||||
allow(subject).to receive(:db).and_return(db)
|
||||
allow(sample_db).to receive(:created?).and_return(true)
|
||||
allow(sample_db).to receive(:db).and_return(db)
|
||||
|
||||
expect(db).to receive(:has_key?).with(:foo).and_return(false)
|
||||
expect(db).not_to have_key(:foo)
|
||||
subject.set(:foo, "bar")
|
||||
sample_db.set(:foo, "bar")
|
||||
end
|
||||
end
|
||||
|
||||
@ -36,11 +36,11 @@ describe CacheStoreDatabase do
|
||||
let(:db) { double("db", :[] => "bar") }
|
||||
|
||||
it "gets value in the `CacheStoreDatabase` corresponding to the key" do
|
||||
allow(subject).to receive(:created?).and_return(true)
|
||||
allow(sample_db).to receive(:created?).and_return(true)
|
||||
expect(db).to receive(:has_key?).with(:foo).and_return(true)
|
||||
allow(subject).to receive(:db).and_return(db)
|
||||
allow(sample_db).to receive(:db).and_return(db)
|
||||
expect(db).to have_key(:foo)
|
||||
expect(subject.get(:foo)).to eq("bar")
|
||||
expect(sample_db.get(:foo)).to eq("bar")
|
||||
end
|
||||
end
|
||||
|
||||
@ -48,17 +48,17 @@ describe CacheStoreDatabase do
|
||||
let(:db) { double("db", :[] => nil) }
|
||||
|
||||
before do
|
||||
allow(subject).to receive(:created?).and_return(false)
|
||||
allow(subject).to receive(:db).and_return(db)
|
||||
allow(sample_db).to receive(:created?).and_return(false)
|
||||
allow(sample_db).to receive(:db).and_return(db)
|
||||
end
|
||||
|
||||
it "does not get value in the `CacheStoreDatabase` corresponding to key" do
|
||||
expect(subject.get(:foo)).not_to be("bar")
|
||||
expect(sample_db.get(:foo)).not_to be("bar")
|
||||
end
|
||||
|
||||
it "does not call `db[]` if `CacheStoreDatabase.created?` is `false`" do
|
||||
expect(db).not_to receive(:[])
|
||||
subject.get(:foo)
|
||||
sample_db.get(:foo)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -68,13 +68,13 @@ describe CacheStoreDatabase do
|
||||
let(:db) { double("db", :[] => { foo: "bar" }) }
|
||||
|
||||
before do
|
||||
allow(subject).to receive(:created?).and_return(true)
|
||||
allow(subject).to receive(:db).and_return(db)
|
||||
allow(sample_db).to receive(:created?).and_return(true)
|
||||
allow(sample_db).to receive(:db).and_return(db)
|
||||
end
|
||||
|
||||
it "deletes value in the `CacheStoreDatabase` corresponding to the key" do
|
||||
expect(db).to receive(:delete).with(:foo)
|
||||
subject.delete(:foo)
|
||||
sample_db.delete(:foo)
|
||||
end
|
||||
end
|
||||
|
||||
@ -82,13 +82,13 @@ describe CacheStoreDatabase do
|
||||
let(:db) { double("db", delete: nil) }
|
||||
|
||||
before do
|
||||
allow(subject).to receive(:created?).and_return(false)
|
||||
allow(subject).to receive(:db).and_return(db)
|
||||
allow(sample_db).to receive(:created?).and_return(false)
|
||||
allow(sample_db).to receive(:db).and_return(db)
|
||||
end
|
||||
|
||||
it "does not call `db.delete` if `CacheStoreDatabase.created?` is `false`" do
|
||||
expect(db).not_to receive(:delete)
|
||||
subject.delete(:foo)
|
||||
sample_db.delete(:foo)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -96,17 +96,17 @@ describe CacheStoreDatabase do
|
||||
describe "#write_if_dirty!" do
|
||||
context "database open" do
|
||||
it "does not raise an error when `close` is called on the database" do
|
||||
expect { subject.write_if_dirty! }.not_to raise_error(NoMethodError)
|
||||
expect { sample_db.write_if_dirty! }.not_to raise_error(NoMethodError)
|
||||
end
|
||||
end
|
||||
|
||||
context "database not open" do
|
||||
before do
|
||||
subject.instance_variable_set(:@db, nil)
|
||||
sample_db.instance_variable_set(:@db, nil)
|
||||
end
|
||||
|
||||
it "does not raise an error when `close` is called on the database" do
|
||||
expect { subject.write_if_dirty! }.not_to raise_error(NoMethodError)
|
||||
expect { sample_db.write_if_dirty! }.not_to raise_error(NoMethodError)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -115,7 +115,7 @@ describe CacheStoreDatabase do
|
||||
let(:cache_path) { Pathname("path/to/homebrew/cache/sample.json") }
|
||||
|
||||
before do
|
||||
allow(subject).to receive(:cache_path).and_return(cache_path)
|
||||
allow(sample_db).to receive(:cache_path).and_return(cache_path)
|
||||
end
|
||||
|
||||
context "`cache_path.exist?` returns `true`" do
|
||||
@ -124,7 +124,7 @@ describe CacheStoreDatabase do
|
||||
end
|
||||
|
||||
it "returns `true`" do
|
||||
expect(subject.created?).to be(true)
|
||||
expect(sample_db.created?).to be(true)
|
||||
end
|
||||
end
|
||||
|
||||
@ -134,7 +134,7 @@ describe CacheStoreDatabase do
|
||||
end
|
||||
|
||||
it "returns `false`" do
|
||||
expect(subject.created?).to be(false)
|
||||
expect(sample_db.created?).to be(false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -106,7 +106,7 @@ describe Cask::Audit, :cask do
|
||||
end
|
||||
|
||||
describe "#run!" do
|
||||
subject { audit.run! }
|
||||
subject(:run) { audit.run! }
|
||||
|
||||
def tmp_cask(name, text)
|
||||
path = Pathname.new "#{dir}/#{name}.rb"
|
||||
@ -149,7 +149,7 @@ describe Cask::Audit, :cask do
|
||||
let(:cask_token) { "Upper-Case" }
|
||||
|
||||
it "fails" do
|
||||
expect(subject).to fail_with(/lowercase/)
|
||||
expect(run).to fail_with(/lowercase/)
|
||||
end
|
||||
end
|
||||
|
||||
@ -157,7 +157,7 @@ describe Cask::Audit, :cask do
|
||||
let(:cask_token) { "ascii⌘" }
|
||||
|
||||
it "fails" do
|
||||
expect(subject).to fail_with(/contains non-ascii characters/)
|
||||
expect(run).to fail_with(/contains non-ascii characters/)
|
||||
end
|
||||
end
|
||||
|
||||
@ -165,7 +165,7 @@ describe Cask::Audit, :cask do
|
||||
let(:cask_token) { "app++" }
|
||||
|
||||
it "fails" do
|
||||
expect(subject).to fail_with(/\+ should be replaced by -plus-/)
|
||||
expect(run).to fail_with(/\+ should be replaced by -plus-/)
|
||||
end
|
||||
end
|
||||
|
||||
@ -173,7 +173,7 @@ describe Cask::Audit, :cask do
|
||||
let(:cask_token) { "app@stuff" }
|
||||
|
||||
it "fails" do
|
||||
expect(subject).to fail_with(/@ should be replaced by -at-/)
|
||||
expect(run).to fail_with(/@ should be replaced by -at-/)
|
||||
end
|
||||
end
|
||||
|
||||
@ -181,7 +181,7 @@ describe Cask::Audit, :cask do
|
||||
let(:cask_token) { "app stuff" }
|
||||
|
||||
it "fails" do
|
||||
expect(subject).to fail_with(/whitespace should be replaced by hyphens/)
|
||||
expect(run).to fail_with(/whitespace should be replaced by hyphens/)
|
||||
end
|
||||
end
|
||||
|
||||
@ -189,7 +189,7 @@ describe Cask::Audit, :cask do
|
||||
let(:cask_token) { "app_stuff" }
|
||||
|
||||
it "fails" do
|
||||
expect(subject).to fail_with(/underscores should be replaced by hyphens/)
|
||||
expect(run).to fail_with(/underscores should be replaced by hyphens/)
|
||||
end
|
||||
end
|
||||
|
||||
@ -197,7 +197,7 @@ describe Cask::Audit, :cask do
|
||||
let(:cask_token) { "app(stuff)" }
|
||||
|
||||
it "fails" do
|
||||
expect(subject).to fail_with(/alphanumeric characters and hyphens/)
|
||||
expect(run).to fail_with(/alphanumeric characters and hyphens/)
|
||||
end
|
||||
end
|
||||
|
||||
@ -205,7 +205,7 @@ describe Cask::Audit, :cask do
|
||||
let(:cask_token) { "app--stuff" }
|
||||
|
||||
it "fails" do
|
||||
expect(subject).to fail_with(/should not contain double hyphens/)
|
||||
expect(run).to fail_with(/should not contain double hyphens/)
|
||||
end
|
||||
end
|
||||
|
||||
@ -213,7 +213,7 @@ describe Cask::Audit, :cask do
|
||||
let(:cask_token) { "-app" }
|
||||
|
||||
it "fails" do
|
||||
expect(subject).to fail_with(/should not have leading or trailing hyphens/)
|
||||
expect(run).to fail_with(/should not have leading or trailing hyphens/)
|
||||
end
|
||||
end
|
||||
|
||||
@ -221,7 +221,7 @@ describe Cask::Audit, :cask do
|
||||
let(:cask_token) { "app-" }
|
||||
|
||||
it "fails" do
|
||||
expect(subject).to fail_with(/should not have leading or trailing hyphens/)
|
||||
expect(run).to fail_with(/should not have leading or trailing hyphens/)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -247,7 +247,7 @@ describe Cask::Audit, :cask do
|
||||
let(:cask_token) { "token.app" }
|
||||
|
||||
it "fails" do
|
||||
expect(subject).to fail_with(/token contains .app/)
|
||||
expect(run).to fail_with(/token contains .app/)
|
||||
end
|
||||
end
|
||||
|
||||
@ -257,13 +257,13 @@ describe Cask::Audit, :cask do
|
||||
it "fails if the cask is from an official tap" do
|
||||
allow(cask).to receive(:tap).and_return(Tap.fetch("homebrew/cask"))
|
||||
|
||||
expect(subject).to fail_with(/token contains version designation/)
|
||||
expect(run).to fail_with(/token contains version designation/)
|
||||
end
|
||||
|
||||
it "does not fail if the cask is from the `cask-versions` tap" do
|
||||
allow(cask).to receive(:tap).and_return(Tap.fetch("homebrew/cask-versions"))
|
||||
|
||||
expect(subject).to pass
|
||||
expect(run).to pass
|
||||
end
|
||||
end
|
||||
|
||||
@ -271,7 +271,7 @@ describe Cask::Audit, :cask do
|
||||
let(:cask_token) { "token-launcher" }
|
||||
|
||||
it "fails" do
|
||||
expect(subject).to fail_with(/token mentions launcher/)
|
||||
expect(run).to fail_with(/token mentions launcher/)
|
||||
end
|
||||
end
|
||||
|
||||
@ -279,7 +279,7 @@ describe Cask::Audit, :cask do
|
||||
let(:cask_token) { "token-desktop" }
|
||||
|
||||
it "fails" do
|
||||
expect(subject).to fail_with(/token mentions desktop/)
|
||||
expect(run).to fail_with(/token mentions desktop/)
|
||||
end
|
||||
end
|
||||
|
||||
@ -287,7 +287,7 @@ describe Cask::Audit, :cask do
|
||||
let(:cask_token) { "token-osx" }
|
||||
|
||||
it "fails" do
|
||||
expect(subject).to fail_with(/token mentions platform/)
|
||||
expect(run).to fail_with(/token mentions platform/)
|
||||
end
|
||||
end
|
||||
|
||||
@ -295,7 +295,7 @@ describe Cask::Audit, :cask do
|
||||
let(:cask_token) { "token-x86" }
|
||||
|
||||
it "fails" do
|
||||
expect(subject).to fail_with(/token mentions architecture/)
|
||||
expect(run).to fail_with(/token mentions architecture/)
|
||||
end
|
||||
end
|
||||
|
||||
@ -303,7 +303,7 @@ describe Cask::Audit, :cask do
|
||||
let(:cask_token) { "token-java" }
|
||||
|
||||
it "fails" do
|
||||
expect(subject).to fail_with(/cask token mentions framework/)
|
||||
expect(run).to fail_with(/cask token mentions framework/)
|
||||
end
|
||||
end
|
||||
|
||||
@ -311,7 +311,7 @@ describe Cask::Audit, :cask do
|
||||
let(:cask_token) { "java" }
|
||||
|
||||
it "does not fail" do
|
||||
expect(subject).to pass
|
||||
expect(run).to pass
|
||||
end
|
||||
end
|
||||
|
||||
@ -328,7 +328,7 @@ describe Cask::Audit, :cask do
|
||||
let(:new_cask) { true }
|
||||
|
||||
it "fails" do
|
||||
expect(subject).to fail_with("#{cask_token} is listed in tap_migrations.json")
|
||||
expect(run).to fail_with("#{cask_token} is listed in tap_migrations.json")
|
||||
end
|
||||
end
|
||||
|
||||
@ -336,7 +336,7 @@ describe Cask::Audit, :cask do
|
||||
let(:new_cask) { false }
|
||||
|
||||
it "does not fail" do
|
||||
expect(subject).to pass
|
||||
expect(run).to pass
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -382,9 +382,9 @@ describe Cask::Audit, :cask do
|
||||
|
||||
context "when cask locale is invalid" do
|
||||
it "error with invalid locale" do
|
||||
expect(subject).to fail_with(/Locale 'ZH-CN' is invalid\./)
|
||||
expect(subject).to fail_with(/Locale 'zh-' is invalid\./)
|
||||
expect(subject).to fail_with(/Locale 'zh-cn' is invalid\./)
|
||||
expect(run).to fail_with(/Locale 'ZH-CN' is invalid\./)
|
||||
expect(run).to fail_with(/Locale 'zh-' is invalid\./)
|
||||
expect(run).to fail_with(/Locale 'zh-cn' is invalid\./)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -797,7 +797,7 @@ describe Cask::Audit, :cask do
|
||||
|
||||
context "when doing the audit" do
|
||||
it "evaluates the block" do
|
||||
expect(subject).to fail_with(/Boom/)
|
||||
expect(run).to fail_with(/Boom/)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -812,7 +812,7 @@ describe Cask::Audit, :cask do
|
||||
|
||||
it "warns about duplicates" do
|
||||
expect(audit).to receive(:core_formula_names).and_return(formula_names)
|
||||
expect(subject).to warn_with(/possible duplicate/)
|
||||
expect(run).to warn_with(/possible duplicate/)
|
||||
end
|
||||
end
|
||||
|
||||
@ -836,12 +836,12 @@ describe Cask::Audit, :cask do
|
||||
|
||||
it "when download and verification succeed it does not fail" do
|
||||
expect(download_double).to receive(:fetch)
|
||||
expect(subject).to pass
|
||||
expect(run).to pass
|
||||
end
|
||||
|
||||
it "when download fails it fails" do
|
||||
expect(download_double).to receive(:fetch).and_raise(StandardError.new(message))
|
||||
expect(subject).to fail_with(/#{message}/)
|
||||
expect(run).to fail_with(/#{message}/)
|
||||
end
|
||||
end
|
||||
|
||||
@ -850,7 +850,7 @@ describe Cask::Audit, :cask do
|
||||
|
||||
it "fails the audit" do
|
||||
expect(cask).to receive(:tap).and_raise(StandardError.new)
|
||||
expect(subject).to fail_with(/exception while auditing/)
|
||||
expect(run).to fail_with(/exception while auditing/)
|
||||
end
|
||||
end
|
||||
|
||||
@ -873,7 +873,7 @@ describe Cask::Audit, :cask do
|
||||
let(:new_cask) { true }
|
||||
|
||||
it "fails" do
|
||||
expect(subject).to fail_with(/should have a description/)
|
||||
expect(run).to fail_with(/should have a description/)
|
||||
end
|
||||
end
|
||||
|
||||
@ -881,7 +881,7 @@ describe Cask::Audit, :cask do
|
||||
let(:new_cask) { false }
|
||||
|
||||
it "warns" do
|
||||
expect(subject).to warn_with(/should have a description/)
|
||||
expect(run).to warn_with(/should have a description/)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -903,7 +903,7 @@ describe Cask::Audit, :cask do
|
||||
end
|
||||
|
||||
it "passes" do
|
||||
expect(subject).to pass
|
||||
expect(run).to pass
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
describe Cask::DSL::Appcast do
|
||||
subject { described_class.new(url, params) }
|
||||
subject(:appcast) { described_class.new(url, params) }
|
||||
|
||||
let(:url) { "https://brew.sh" }
|
||||
let(:uri) { URI(url) }
|
||||
@ -10,7 +10,7 @@ describe Cask::DSL::Appcast do
|
||||
|
||||
describe "#to_s" do
|
||||
it "returns the parsed URI string" do
|
||||
expect(subject.to_s).to eq("https://brew.sh")
|
||||
expect(appcast.to_s).to eq("https://brew.sh")
|
||||
end
|
||||
end
|
||||
|
||||
@ -19,7 +19,7 @@ describe Cask::DSL::Appcast do
|
||||
|
||||
context "with empty parameters" do
|
||||
it "returns an YAML serialized array composed of the URI and parameters" do
|
||||
expect(subject.to_yaml).to eq(yaml)
|
||||
expect(appcast.to_yaml).to eq(yaml)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -5,17 +5,17 @@ require "formula"
|
||||
require "caveats"
|
||||
|
||||
describe Caveats do
|
||||
subject { described_class.new(f) }
|
||||
subject(:caveats) { described_class.new(f) }
|
||||
|
||||
let(:f) { formula { url "foo-1.0" } }
|
||||
|
||||
specify "#f" do
|
||||
expect(subject.f).to eq(f)
|
||||
expect(caveats.f).to eq(f)
|
||||
end
|
||||
|
||||
describe "#empty?" do
|
||||
it "returns true if the Formula has no caveats" do
|
||||
expect(subject).to be_empty
|
||||
expect(caveats).to be_empty
|
||||
end
|
||||
|
||||
it "returns false if the Formula has caveats" do
|
||||
|
||||
@ -7,7 +7,7 @@ require "formula"
|
||||
describe Cleaner do
|
||||
include FileUtils
|
||||
|
||||
subject { described_class.new(f) }
|
||||
subject(:cleaner) { described_class.new(f) }
|
||||
|
||||
let(:f) { formula("cleaner_test") { url "foo-1.0" } }
|
||||
|
||||
@ -28,7 +28,7 @@ describe Cleaner do
|
||||
cp Dir["#{TEST_FIXTURE_DIR}/elf/libhello.so.0"], f.lib
|
||||
end
|
||||
|
||||
subject.clean
|
||||
cleaner.clean
|
||||
|
||||
if OS.mac?
|
||||
expect((f.bin/"a.out").stat.mode).to eq(0100555)
|
||||
@ -42,7 +42,7 @@ describe Cleaner do
|
||||
end
|
||||
|
||||
it "prunes the prefix if it is empty" do
|
||||
subject.clean
|
||||
cleaner.clean
|
||||
expect(f.prefix).not_to be_a_directory
|
||||
end
|
||||
|
||||
@ -50,7 +50,7 @@ describe Cleaner do
|
||||
subdir = f.bin/"subdir"
|
||||
subdir.mkpath
|
||||
|
||||
subject.clean
|
||||
cleaner.clean
|
||||
|
||||
expect(f.bin).not_to be_a_directory
|
||||
expect(subdir).not_to be_a_directory
|
||||
@ -63,7 +63,7 @@ describe Cleaner do
|
||||
dir.mkpath
|
||||
ln_s dir.basename, symlink
|
||||
|
||||
subject.clean
|
||||
cleaner.clean
|
||||
|
||||
expect(dir).not_to exist
|
||||
expect(symlink).not_to be_a_symlink
|
||||
@ -77,7 +77,7 @@ describe Cleaner do
|
||||
dir.mkpath
|
||||
ln_s dir.basename, symlink
|
||||
|
||||
subject.clean
|
||||
cleaner.clean
|
||||
|
||||
expect(dir).not_to exist
|
||||
expect(symlink).not_to be_a_symlink
|
||||
@ -88,7 +88,7 @@ describe Cleaner do
|
||||
symlink = f.prefix/"symlink"
|
||||
ln_s "target", symlink
|
||||
|
||||
subject.clean
|
||||
cleaner.clean
|
||||
|
||||
expect(symlink).not_to be_a_symlink
|
||||
end
|
||||
@ -99,7 +99,7 @@ describe Cleaner do
|
||||
f.lib.mkpath
|
||||
touch file
|
||||
|
||||
subject.clean
|
||||
cleaner.clean
|
||||
|
||||
expect(file).not_to exist
|
||||
end
|
||||
@ -110,7 +110,7 @@ describe Cleaner do
|
||||
(f.lib/"perl5/darwin-thread-multi-2level").mkpath
|
||||
touch file
|
||||
|
||||
subject.clean
|
||||
cleaner.clean
|
||||
|
||||
expect(file).not_to exist
|
||||
end
|
||||
@ -121,7 +121,7 @@ describe Cleaner do
|
||||
(f.lib/"perl5/darwin-thread-multi-2level/auto/test").mkpath
|
||||
touch file
|
||||
|
||||
subject.clean
|
||||
cleaner.clean
|
||||
|
||||
expect(file).not_to exist
|
||||
end
|
||||
@ -132,7 +132,7 @@ describe Cleaner do
|
||||
f.lib.mkpath
|
||||
touch file
|
||||
|
||||
subject.clean
|
||||
cleaner.clean
|
||||
|
||||
expect(file).not_to exist
|
||||
end
|
||||
@ -143,7 +143,7 @@ describe Cleaner do
|
||||
f.class.skip_clean "bin"
|
||||
f.bin.mkpath
|
||||
|
||||
subject.clean
|
||||
cleaner.clean
|
||||
|
||||
expect(f.bin).to be_a_directory
|
||||
end
|
||||
@ -153,7 +153,7 @@ describe Cleaner do
|
||||
subdir = f.bin/"subdir"
|
||||
subdir.mkpath
|
||||
|
||||
subject.clean
|
||||
cleaner.clean
|
||||
|
||||
expect(f.bin).to be_a_directory
|
||||
expect(subdir).to be_a_directory
|
||||
@ -164,7 +164,7 @@ describe Cleaner do
|
||||
symlink = f.prefix/"symlink"
|
||||
ln_s "target", symlink
|
||||
|
||||
subject.clean
|
||||
cleaner.clean
|
||||
|
||||
expect(symlink).to be_a_symlink
|
||||
end
|
||||
@ -177,7 +177,7 @@ describe Cleaner do
|
||||
dir.mkpath
|
||||
ln_s dir.basename, symlink
|
||||
|
||||
subject.clean
|
||||
cleaner.clean
|
||||
|
||||
expect(dir).not_to exist
|
||||
expect(symlink).to be_a_symlink
|
||||
@ -192,7 +192,7 @@ describe Cleaner do
|
||||
dir.mkpath
|
||||
ln_s dir.basename, symlink
|
||||
|
||||
subject.clean
|
||||
cleaner.clean
|
||||
|
||||
expect(dir).not_to exist
|
||||
expect(symlink).to be_a_symlink
|
||||
@ -206,7 +206,7 @@ describe Cleaner do
|
||||
f.lib.mkpath
|
||||
touch file
|
||||
|
||||
subject.clean
|
||||
cleaner.clean
|
||||
|
||||
expect(file).to exist
|
||||
end
|
||||
@ -217,7 +217,7 @@ describe Cleaner do
|
||||
|
||||
dir.mkpath
|
||||
|
||||
subject.clean
|
||||
cleaner.clean
|
||||
|
||||
expect(dir).to be_a_directory
|
||||
end
|
||||
@ -230,7 +230,7 @@ describe Cleaner do
|
||||
dir1.mkpath
|
||||
dir2.mkpath
|
||||
|
||||
subject.clean
|
||||
cleaner.clean
|
||||
|
||||
expect(dir1).to exist
|
||||
expect(dir2).not_to exist
|
||||
|
||||
@ -31,6 +31,8 @@ describe Homebrew::Cleanup::CleanupRefinement do
|
||||
end
|
||||
|
||||
describe Homebrew::Cleanup do
|
||||
subject(:cleanup) { described_class.new }
|
||||
|
||||
let(:ds_store) { Pathname.new("#{HOMEBREW_CELLAR}/.DS_Store") }
|
||||
let(:lock_file) { Pathname.new("#{HOMEBREW_LOCKS}/foo") }
|
||||
|
||||
@ -49,7 +51,7 @@ describe Homebrew::Cleanup do
|
||||
|
||||
describe "::cleanup" do
|
||||
it "removes .DS_Store and lock files" do
|
||||
subject.clean!
|
||||
cleanup.clean!
|
||||
|
||||
expect(ds_store).not_to exist
|
||||
expect(lock_file).not_to exist
|
||||
@ -65,7 +67,7 @@ describe Homebrew::Cleanup do
|
||||
it "doesn't remove the lock file if it is locked" do
|
||||
lock_file.open(File::RDWR | File::CREAT).flock(File::LOCK_EX | File::LOCK_NB)
|
||||
|
||||
subject.clean!
|
||||
cleanup.clean!
|
||||
|
||||
expect(lock_file).to exist
|
||||
end
|
||||
@ -89,13 +91,13 @@ describe Homebrew::Cleanup do
|
||||
end
|
||||
|
||||
it "doesn't remove any kegs" do
|
||||
subject.cleanup_formula f2
|
||||
cleanup.cleanup_formula f2
|
||||
expect(f1.installed_kegs.size).to eq(2)
|
||||
end
|
||||
|
||||
it "lists the unremovable kegs" do
|
||||
subject.cleanup_formula f2
|
||||
expect(subject.unremovable_kegs).to contain_exactly(f1.installed_kegs[0])
|
||||
cleanup.cleanup_formula f2
|
||||
expect(cleanup.unremovable_kegs).to contain_exactly(f1.installed_kegs[0])
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -133,7 +135,7 @@ describe Homebrew::Cleanup do
|
||||
expect(f3).to be_latest_version_installed
|
||||
expect(f4).to be_latest_version_installed
|
||||
|
||||
subject.cleanup_formula f3
|
||||
cleanup.cleanup_formula f3
|
||||
|
||||
expect(f1).not_to be_latest_version_installed
|
||||
expect(f2).not_to be_latest_version_installed
|
||||
@ -154,7 +156,7 @@ describe Homebrew::Cleanup do
|
||||
|
||||
FileUtils.touch download
|
||||
|
||||
subject.cleanup_cask(cask)
|
||||
cleanup.cleanup_cask(cask)
|
||||
|
||||
expect(download).not_to exist
|
||||
end
|
||||
@ -164,7 +166,7 @@ describe Homebrew::Cleanup do
|
||||
|
||||
FileUtils.touch download
|
||||
|
||||
subject.cleanup_cask(cask)
|
||||
cleanup.cleanup_cask(cask)
|
||||
|
||||
expect(download).to exist
|
||||
end
|
||||
@ -178,7 +180,7 @@ describe Homebrew::Cleanup do
|
||||
|
||||
FileUtils.touch download
|
||||
|
||||
subject.cleanup_cask(cask)
|
||||
cleanup.cleanup_cask(cask)
|
||||
|
||||
expect(download).to exist
|
||||
end
|
||||
@ -189,7 +191,7 @@ describe Homebrew::Cleanup do
|
||||
allow(download).to receive(:ctime).and_return(30.days.ago - 1.hour)
|
||||
allow(download).to receive(:mtime).and_return(30.days.ago - 1.hour)
|
||||
|
||||
subject.cleanup_cask(cask)
|
||||
cleanup.cleanup_cask(cask)
|
||||
|
||||
expect(download).not_to exist
|
||||
end
|
||||
@ -211,14 +213,14 @@ describe Homebrew::Cleanup do
|
||||
it "cleans up logs if older than 30 days" do
|
||||
allow_any_instance_of(Pathname).to receive(:ctime).and_return(31.days.ago)
|
||||
allow_any_instance_of(Pathname).to receive(:mtime).and_return(31.days.ago)
|
||||
subject.cleanup_logs
|
||||
cleanup.cleanup_logs
|
||||
expect(path).not_to exist
|
||||
end
|
||||
|
||||
it "does not clean up logs less than 30 days old" do
|
||||
allow_any_instance_of(Pathname).to receive(:ctime).and_return(15.days.ago)
|
||||
allow_any_instance_of(Pathname).to receive(:mtime).and_return(15.days.ago)
|
||||
subject.cleanup_logs
|
||||
cleanup.cleanup_logs
|
||||
expect(path).to exist
|
||||
end
|
||||
end
|
||||
@ -228,7 +230,7 @@ describe Homebrew::Cleanup do
|
||||
incomplete = (HOMEBREW_CACHE/"something.incomplete")
|
||||
incomplete.mkpath
|
||||
|
||||
subject.cleanup_cache
|
||||
cleanup.cleanup_cache
|
||||
|
||||
expect(incomplete).not_to exist
|
||||
end
|
||||
@ -237,7 +239,7 @@ describe Homebrew::Cleanup do
|
||||
cargo_cache = (HOMEBREW_CACHE/"cargo_cache")
|
||||
cargo_cache.mkpath
|
||||
|
||||
subject.cleanup_cache
|
||||
cleanup.cleanup_cache
|
||||
|
||||
expect(cargo_cache).not_to exist
|
||||
end
|
||||
@ -246,7 +248,7 @@ describe Homebrew::Cleanup do
|
||||
go_cache = (HOMEBREW_CACHE/"go_cache")
|
||||
go_cache.mkpath
|
||||
|
||||
subject.cleanup_cache
|
||||
cleanup.cleanup_cache
|
||||
|
||||
expect(go_cache).not_to exist
|
||||
end
|
||||
@ -255,7 +257,7 @@ describe Homebrew::Cleanup do
|
||||
glide_home = (HOMEBREW_CACHE/"glide_home")
|
||||
glide_home.mkpath
|
||||
|
||||
subject.cleanup_cache
|
||||
cleanup.cleanup_cache
|
||||
|
||||
expect(glide_home).not_to exist
|
||||
end
|
||||
@ -264,7 +266,7 @@ describe Homebrew::Cleanup do
|
||||
java_cache = (HOMEBREW_CACHE/"java_cache")
|
||||
java_cache.mkpath
|
||||
|
||||
subject.cleanup_cache
|
||||
cleanup.cleanup_cache
|
||||
|
||||
expect(java_cache).not_to exist
|
||||
end
|
||||
@ -273,7 +275,7 @@ describe Homebrew::Cleanup do
|
||||
npm_cache = (HOMEBREW_CACHE/"npm_cache")
|
||||
npm_cache.mkpath
|
||||
|
||||
subject.cleanup_cache
|
||||
cleanup.cleanup_cache
|
||||
|
||||
expect(npm_cache).not_to exist
|
||||
end
|
||||
@ -282,7 +284,7 @@ describe Homebrew::Cleanup do
|
||||
gclient_cache = (HOMEBREW_CACHE/"gclient_cache")
|
||||
gclient_cache.mkpath
|
||||
|
||||
subject.cleanup_cache
|
||||
cleanup.cleanup_cache
|
||||
|
||||
expect(gclient_cache).not_to exist
|
||||
end
|
||||
@ -343,7 +345,7 @@ describe Homebrew::Cleanup do
|
||||
|
||||
it "cleans up file if outdated" do
|
||||
allow(Utils::Bottles).to receive(:file_outdated?).with(any_args).and_return(true)
|
||||
subject.cleanup_cache
|
||||
cleanup.cleanup_cache
|
||||
expect(bottle).not_to exist
|
||||
expect(testball).not_to exist
|
||||
expect(testball_resource).not_to exist
|
||||
@ -357,7 +359,7 @@ describe Homebrew::Cleanup do
|
||||
end
|
||||
|
||||
it "cleans up file if stale" do
|
||||
subject.cleanup_cache
|
||||
cleanup.cleanup_cache
|
||||
expect(bottle).not_to exist
|
||||
expect(testball).not_to exist
|
||||
expect(testball_resource).not_to exist
|
||||
|
||||
@ -33,16 +33,16 @@ describe Homebrew do
|
||||
let(:remote) { "https://github.com/Homebrew/homebrew-core" }
|
||||
|
||||
specify "::github_remote_path" do
|
||||
expect(subject.github_remote_path(remote, "Formula/git.rb"))
|
||||
expect(described_class.github_remote_path(remote, "Formula/git.rb"))
|
||||
.to eq("https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/git.rb")
|
||||
|
||||
expect(subject.github_remote_path("#{remote}.git", "Formula/git.rb"))
|
||||
expect(described_class.github_remote_path("#{remote}.git", "Formula/git.rb"))
|
||||
.to eq("https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/git.rb")
|
||||
|
||||
expect(subject.github_remote_path("git@github.com:user/repo", "foo.rb"))
|
||||
expect(described_class.github_remote_path("git@github.com:user/repo", "foo.rb"))
|
||||
.to eq("https://github.com/user/repo/blob/HEAD/foo.rb")
|
||||
|
||||
expect(subject.github_remote_path("https://mywebsite.com", "foo/bar.rb"))
|
||||
expect(described_class.github_remote_path("https://mywebsite.com", "foo/bar.rb"))
|
||||
.to eq("https://mywebsite.com/foo/bar.rb")
|
||||
end
|
||||
end
|
||||
|
||||
@ -5,7 +5,7 @@ require "compilers"
|
||||
require "software_spec"
|
||||
|
||||
describe CompilerSelector do
|
||||
subject { described_class.new(software_spec, versions, compilers) }
|
||||
subject(:selector) { described_class.new(software_spec, versions, compilers) }
|
||||
|
||||
let(:compilers) { [:clang, :gnu] }
|
||||
let(:software_spec) { SoftwareSpec.new }
|
||||
@ -29,23 +29,23 @@ describe CompilerSelector do
|
||||
|
||||
describe "#compiler" do
|
||||
it "defaults to cc" do
|
||||
expect(subject.compiler).to eq(cc)
|
||||
expect(selector.compiler).to eq(cc)
|
||||
end
|
||||
|
||||
it "returns clang if it fails with non-Apple gcc" do
|
||||
software_spec.fails_with(gcc: "7")
|
||||
expect(subject.compiler).to eq(:clang)
|
||||
expect(selector.compiler).to eq(:clang)
|
||||
end
|
||||
|
||||
it "still returns gcc-7 if it fails with gcc without a specific version" do
|
||||
software_spec.fails_with(:clang)
|
||||
expect(subject.compiler).to eq("gcc-7")
|
||||
expect(selector.compiler).to eq("gcc-7")
|
||||
end
|
||||
|
||||
it "returns gcc-6 if gcc formula offers gcc-6" do
|
||||
software_spec.fails_with(:clang)
|
||||
allow(Formulary).to receive(:factory).with("gcc").and_return(double(version: "6.0"))
|
||||
expect(subject.compiler).to eq("gcc-6")
|
||||
expect(selector.compiler).to eq("gcc-6")
|
||||
end
|
||||
|
||||
it "raises an error when gcc or llvm is missing" do
|
||||
@ -53,7 +53,7 @@ describe CompilerSelector do
|
||||
software_spec.fails_with(gcc: "7")
|
||||
software_spec.fails_with(gcc: "6")
|
||||
|
||||
expect { subject.compiler }.to raise_error(CompilerSelectionError)
|
||||
expect { selector.compiler }.to raise_error(CompilerSelectionError)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -6,23 +6,23 @@ require "dependable"
|
||||
describe Dependable do
|
||||
alias_matcher :be_a_build_dependency, :be_build
|
||||
|
||||
subject { double(tags: tags).extend(described_class) }
|
||||
subject(:dependable) { double(tags: tags).extend(described_class) }
|
||||
|
||||
let(:tags) { ["foo", "bar", :build] }
|
||||
|
||||
specify "#options" do
|
||||
expect(subject.options.as_flags.sort).to eq(%w[--foo --bar].sort)
|
||||
expect(dependable.options.as_flags.sort).to eq(%w[--foo --bar].sort)
|
||||
end
|
||||
|
||||
specify "#build?" do
|
||||
expect(subject).to be_a_build_dependency
|
||||
expect(dependable).to be_a_build_dependency
|
||||
end
|
||||
|
||||
specify "#optional?" do
|
||||
expect(subject).not_to be_optional
|
||||
expect(dependable).not_to be_optional
|
||||
end
|
||||
|
||||
specify "#recommended?" do
|
||||
expect(subject).not_to be_recommended
|
||||
expect(dependable).not_to be_recommended
|
||||
end
|
||||
end
|
||||
|
||||
@ -5,40 +5,42 @@ require "dependencies"
|
||||
require "dependency"
|
||||
|
||||
describe Dependencies do
|
||||
subject(:dependencies) { described_class.new }
|
||||
|
||||
describe "#<<" do
|
||||
it "returns itself" do
|
||||
expect(subject << Dependency.new("foo")).to eq(subject)
|
||||
expect(dependencies << Dependency.new("foo")).to eq(dependencies)
|
||||
end
|
||||
|
||||
it "preserves order" do
|
||||
hash = { 0 => "foo", 1 => "bar", 2 => "baz" }
|
||||
|
||||
subject << Dependency.new(hash[0])
|
||||
subject << Dependency.new(hash[1])
|
||||
subject << Dependency.new(hash[2])
|
||||
dependencies << Dependency.new(hash[0])
|
||||
dependencies << Dependency.new(hash[1])
|
||||
dependencies << Dependency.new(hash[2])
|
||||
|
||||
subject.each_with_index do |dep, i|
|
||||
dependencies.each_with_index do |dep, i|
|
||||
expect(dep.name).to eq(hash[i])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
specify "#*" do
|
||||
subject << Dependency.new("foo")
|
||||
subject << Dependency.new("bar")
|
||||
expect(subject * ", ").to eq("foo, bar")
|
||||
dependencies << Dependency.new("foo")
|
||||
dependencies << Dependency.new("bar")
|
||||
expect(dependencies * ", ").to eq("foo, bar")
|
||||
end
|
||||
|
||||
specify "#to_a" do
|
||||
dep = Dependency.new("foo")
|
||||
subject << dep
|
||||
expect(subject.to_a).to eq([dep])
|
||||
dependencies << dep
|
||||
expect(dependencies.to_a).to eq([dep])
|
||||
end
|
||||
|
||||
specify "#to_ary" do
|
||||
dep = Dependency.new("foo")
|
||||
subject << dep
|
||||
expect(subject.to_ary).to eq([dep])
|
||||
dependencies << dep
|
||||
expect(dependencies.to_ary).to eq([dep])
|
||||
end
|
||||
|
||||
specify "type helpers" do
|
||||
@ -47,12 +49,12 @@ describe Dependencies do
|
||||
baz = Dependency.new("baz", [:build])
|
||||
qux = Dependency.new("qux", [:recommended])
|
||||
quux = Dependency.new("quux")
|
||||
subject << foo << bar << baz << qux << quux
|
||||
expect(subject.required).to eq([foo, quux])
|
||||
expect(subject.optional).to eq([bar])
|
||||
expect(subject.build).to eq([baz])
|
||||
expect(subject.recommended).to eq([qux])
|
||||
expect(subject.default.sort_by(&:name)).to eq([foo, baz, quux, qux].sort_by(&:name))
|
||||
dependencies << foo << bar << baz << qux << quux
|
||||
expect(dependencies.required).to eq([foo, quux])
|
||||
expect(dependencies.optional).to eq([bar])
|
||||
expect(dependencies.build).to eq([baz])
|
||||
expect(dependencies.recommended).to eq([qux])
|
||||
expect(dependencies.default.sort_by(&:name)).to eq([foo, baz, quux, qux].sort_by(&:name))
|
||||
end
|
||||
|
||||
specify "equality" do
|
||||
@ -74,16 +76,16 @@ describe Dependencies do
|
||||
end
|
||||
|
||||
specify "#empty?" do
|
||||
expect(subject).to be_empty
|
||||
expect(dependencies).to be_empty
|
||||
|
||||
subject << Dependency.new("foo")
|
||||
expect(subject).not_to be_empty
|
||||
dependencies << Dependency.new("foo")
|
||||
expect(dependencies).not_to be_empty
|
||||
end
|
||||
|
||||
specify "#inspect" do
|
||||
expect(subject.inspect).to eq("#<Dependencies: []>")
|
||||
expect(dependencies.inspect).to eq("#<Dependencies: []>")
|
||||
|
||||
subject << Dependency.new("foo")
|
||||
expect(subject.inspect).to eq("#<Dependencies: [#<Dependency: \"foo\" []>]>")
|
||||
dependencies << Dependency.new("foo")
|
||||
expect(dependencies.inspect).to eq("#<Dependencies: [#<Dependency: \"foo\" []>]>")
|
||||
end
|
||||
end
|
||||
|
||||
@ -6,102 +6,104 @@ require "dependency_collector"
|
||||
describe DependencyCollector do
|
||||
alias_matcher :be_a_build_requirement, :be_build
|
||||
|
||||
subject(:collector) { described_class.new }
|
||||
|
||||
def find_dependency(name)
|
||||
subject.deps.find { |dep| dep.name == name }
|
||||
collector.deps.find { |dep| dep.name == name }
|
||||
end
|
||||
|
||||
def find_requirement(klass)
|
||||
subject.requirements.find { |req| req.is_a? klass }
|
||||
collector.requirements.find { |req| req.is_a? klass }
|
||||
end
|
||||
|
||||
describe "#add" do
|
||||
specify "dependency creation" do
|
||||
subject.add "foo" => :build
|
||||
subject.add "bar" => ["--universal", :optional]
|
||||
collector.add "foo" => :build
|
||||
collector.add "bar" => ["--universal", :optional]
|
||||
expect(find_dependency("foo")).to be_an_instance_of(Dependency)
|
||||
expect(find_dependency("bar").tags.count).to eq(2)
|
||||
end
|
||||
|
||||
it "returns the created dependency" do
|
||||
expect(subject.add("foo")).to eq(Dependency.new("foo"))
|
||||
expect(collector.add("foo")).to eq(Dependency.new("foo"))
|
||||
end
|
||||
|
||||
specify "requirement creation" do
|
||||
subject.add :xcode
|
||||
collector.add :xcode
|
||||
expect(find_requirement(XcodeRequirement)).to be_an_instance_of(XcodeRequirement)
|
||||
end
|
||||
|
||||
it "deduplicates requirements" do
|
||||
2.times { subject.add :xcode }
|
||||
expect(subject.requirements.count).to eq(1)
|
||||
2.times { collector.add :xcode }
|
||||
expect(collector.requirements.count).to eq(1)
|
||||
end
|
||||
|
||||
specify "requirement tags" do
|
||||
subject.add xcode: :build
|
||||
collector.add xcode: :build
|
||||
expect(find_requirement(XcodeRequirement)).to be_a_build_requirement
|
||||
end
|
||||
|
||||
it "doesn't mutate the dependency spec" do
|
||||
spec = { "foo" => :optional }
|
||||
copy = spec.dup
|
||||
subject.add(spec)
|
||||
collector.add(spec)
|
||||
expect(spec).to eq(copy)
|
||||
end
|
||||
|
||||
it "creates a resource dependency from a CVS URL" do
|
||||
resource = Resource.new
|
||||
resource.url(":pserver:anonymous:@brew.sh:/cvsroot/foo/bar", using: :cvs)
|
||||
expect(subject.add(resource)).to eq(Dependency.new("cvs", [:build, :test]))
|
||||
expect(collector.add(resource)).to eq(Dependency.new("cvs", [:build, :test]))
|
||||
end
|
||||
|
||||
it "creates a resource dependency from a '.7z' URL" do
|
||||
resource = Resource.new
|
||||
resource.url("https://brew.sh/foo.7z")
|
||||
expect(subject.add(resource)).to eq(Dependency.new("p7zip", [:build, :test]))
|
||||
expect(collector.add(resource)).to eq(Dependency.new("p7zip", [:build, :test]))
|
||||
end
|
||||
|
||||
it "creates a resource dependency from a '.gz' URL" do
|
||||
resource = Resource.new
|
||||
resource.url("https://brew.sh/foo.tar.gz")
|
||||
expect(subject.add(resource)).to be nil
|
||||
expect(collector.add(resource)).to be nil
|
||||
end
|
||||
|
||||
it "creates a resource dependency from a '.lz' URL" do
|
||||
resource = Resource.new
|
||||
resource.url("https://brew.sh/foo.lz")
|
||||
expect(subject.add(resource)).to eq(Dependency.new("lzip", [:build, :test]))
|
||||
expect(collector.add(resource)).to eq(Dependency.new("lzip", [:build, :test]))
|
||||
end
|
||||
|
||||
it "creates a resource dependency from a '.lha' URL" do
|
||||
resource = Resource.new
|
||||
resource.url("https://brew.sh/foo.lha")
|
||||
expect(subject.add(resource)).to eq(Dependency.new("lha", [:build, :test]))
|
||||
expect(collector.add(resource)).to eq(Dependency.new("lha", [:build, :test]))
|
||||
end
|
||||
|
||||
it "creates a resource dependency from a '.lzh' URL" do
|
||||
resource = Resource.new
|
||||
resource.url("https://brew.sh/foo.lzh")
|
||||
expect(subject.add(resource)).to eq(Dependency.new("lha", [:build, :test]))
|
||||
expect(collector.add(resource)).to eq(Dependency.new("lha", [:build, :test]))
|
||||
end
|
||||
|
||||
it "creates a resource dependency from a '.rar' URL" do
|
||||
resource = Resource.new
|
||||
resource.url("https://brew.sh/foo.rar")
|
||||
expect(subject.add(resource)).to eq(Dependency.new("unrar", [:build, :test]))
|
||||
expect(collector.add(resource)).to eq(Dependency.new("unrar", [:build, :test]))
|
||||
end
|
||||
|
||||
it "raises a TypeError for unknown classes" do
|
||||
expect { subject.add(Class.new) }.to raise_error(TypeError)
|
||||
expect { collector.add(Class.new) }.to raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "raises a TypeError for unknown Types" do
|
||||
expect { subject.add(Object.new) }.to raise_error(TypeError)
|
||||
expect { collector.add(Object.new) }.to raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "raises a TypeError for a Resource with an unknown download strategy" do
|
||||
resource = Resource.new
|
||||
resource.download_strategy = Class.new
|
||||
expect { subject.add(resource) }.to raise_error(TypeError)
|
||||
expect { collector.add(resource) }.to raise_error(TypeError)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -103,13 +103,13 @@ describe Dependency do
|
||||
end
|
||||
|
||||
describe TapDependency do
|
||||
subject { described_class.new("foo/bar/dog") }
|
||||
subject(:dependency) { described_class.new("foo/bar/dog") }
|
||||
|
||||
specify "#tap" do
|
||||
expect(subject.tap).to eq(Tap.new("foo", "bar"))
|
||||
expect(dependency.tap).to eq(Tap.new("foo", "bar"))
|
||||
end
|
||||
|
||||
specify "#option_names" do
|
||||
expect(subject.option_names).to eq(%w[dog])
|
||||
expect(dependency.option_names).to eq(%w[dog])
|
||||
end
|
||||
end
|
||||
|
||||
@ -4,25 +4,25 @@
|
||||
require "descriptions"
|
||||
|
||||
describe Descriptions do
|
||||
subject { described_class.new(descriptions_hash) }
|
||||
subject(:descriptions) { described_class.new(descriptions_hash) }
|
||||
|
||||
let(:descriptions_hash) { {} }
|
||||
|
||||
it "can print description for a core Formula" do
|
||||
descriptions_hash["homebrew/core/foo"] = "Core foo"
|
||||
expect { subject.print }.to output("foo: Core foo\n").to_stdout
|
||||
expect { descriptions.print }.to output("foo: Core foo\n").to_stdout
|
||||
end
|
||||
|
||||
it "can print description for an external Formula" do
|
||||
descriptions_hash["somedev/external/foo"] = "External foo"
|
||||
expect { subject.print }.to output("foo: External foo\n").to_stdout
|
||||
expect { descriptions.print }.to output("foo: External foo\n").to_stdout
|
||||
end
|
||||
|
||||
it "can print descriptions for duplicate Formulae" do
|
||||
descriptions_hash["homebrew/core/foo"] = "Core foo"
|
||||
descriptions_hash["somedev/external/foo"] = "External foo"
|
||||
|
||||
expect { subject.print }.to output(
|
||||
expect { descriptions.print }.to output(
|
||||
<<~EOS,
|
||||
homebrew/core/foo: Core foo
|
||||
somedev/external/foo: External foo
|
||||
@ -35,7 +35,7 @@ describe Descriptions do
|
||||
descriptions_hash["somedev/external/foo"] = "External foo"
|
||||
descriptions_hash["otherdev/external/foo"] = "Other external foo"
|
||||
|
||||
expect { subject.print }.to output(
|
||||
expect { descriptions.print }.to output(
|
||||
<<~EOS,
|
||||
homebrew/core/foo: Core foo
|
||||
otherdev/external/foo: Other external foo
|
||||
|
||||
@ -4,9 +4,11 @@
|
||||
require "diagnostic"
|
||||
|
||||
describe Homebrew::Diagnostic::Checks do
|
||||
subject(:checks) { described_class.new }
|
||||
|
||||
specify "#inject_file_list" do
|
||||
expect(subject.inject_file_list([], "foo:\n")).to eq("foo:\n")
|
||||
expect(subject.inject_file_list(%w[/a /b], "foo:\n")).to eq("foo:\n /a\n /b\n")
|
||||
expect(checks.inject_file_list([], "foo:\n")).to eq("foo:\n")
|
||||
expect(checks.inject_file_list(%w[/a /b], "foo:\n")).to eq("foo:\n /a\n /b\n")
|
||||
end
|
||||
|
||||
specify "#check_for_anaconda" do
|
||||
@ -22,7 +24,7 @@ describe Homebrew::Diagnostic::Checks do
|
||||
|
||||
ENV["PATH"] = "#{path}#{File::PATH_SEPARATOR}#{ENV["PATH"]}"
|
||||
|
||||
expect(subject.check_for_anaconda).to match("Anaconda")
|
||||
expect(checks.check_for_anaconda).to match("Anaconda")
|
||||
end
|
||||
end
|
||||
|
||||
@ -40,7 +42,7 @@ describe Homebrew::Diagnostic::Checks do
|
||||
dirs.each do |dir|
|
||||
modes[dir] = dir.stat.mode & 0777
|
||||
dir.chmod 0555
|
||||
expect(subject.check_access_directories).to match(dir.to_s)
|
||||
expect(checks.check_access_directories).to match(dir.to_s)
|
||||
end
|
||||
ensure
|
||||
modes.each do |dir, mode|
|
||||
@ -60,7 +62,7 @@ describe Homebrew::Diagnostic::Checks do
|
||||
# HOMEBREW_PREFIX/bin/
|
||||
(bin/File.basename(Dir["/usr/bin/*"].first)).mkpath
|
||||
|
||||
expect(subject.check_user_path_1)
|
||||
expect(checks.check_user_path_1)
|
||||
.to match("/usr/bin occurs before #{HOMEBREW_PREFIX}/bin")
|
||||
end
|
||||
|
||||
@ -68,8 +70,8 @@ describe Homebrew::Diagnostic::Checks do
|
||||
ENV["PATH"] = ENV["PATH"].gsub \
|
||||
%r{(?:^|#{File::PATH_SEPARATOR})#{HOMEBREW_PREFIX}/bin}o, ""
|
||||
|
||||
expect(subject.check_user_path_1).to be nil
|
||||
expect(subject.check_user_path_2)
|
||||
expect(checks.check_user_path_1).to be nil
|
||||
expect(checks.check_user_path_2)
|
||||
.to match("Homebrew's \"bin\" was not found in your PATH.")
|
||||
end
|
||||
|
||||
@ -80,9 +82,9 @@ describe Homebrew::Diagnostic::Checks do
|
||||
ENV["HOMEBREW_PATH"].gsub(/(?:^|#{Regexp.escape(File::PATH_SEPARATOR)})#{Regexp.escape(sbin)}/, "")
|
||||
(sbin/"something").mkpath
|
||||
|
||||
expect(subject.check_user_path_1).to be nil
|
||||
expect(subject.check_user_path_2).to be nil
|
||||
expect(subject.check_user_path_3)
|
||||
expect(checks.check_user_path_1).to be nil
|
||||
expect(checks.check_user_path_2).to be nil
|
||||
expect(checks.check_user_path_3)
|
||||
.to match("Homebrew's \"sbin\" was not found in your PATH")
|
||||
ensure
|
||||
sbin.rmtree
|
||||
@ -96,7 +98,7 @@ describe Homebrew::Diagnostic::Checks do
|
||||
ENV["HOMEBREW_PATH"] = ENV["PATH"] =
|
||||
"#{path}#{File::PATH_SEPARATOR}#{ENV["PATH"]}"
|
||||
|
||||
expect(subject.check_for_config_scripts)
|
||||
expect(checks.check_for_config_scripts)
|
||||
.to match('"config" scripts exist')
|
||||
end
|
||||
end
|
||||
@ -107,7 +109,7 @@ describe Homebrew::Diagnostic::Checks do
|
||||
mktmpdir do |path|
|
||||
FileUtils.ln_s path, HOMEBREW_CELLAR
|
||||
|
||||
expect(subject.check_for_symlinked_cellar).to match(path)
|
||||
expect(checks.check_for_symlinked_cellar).to match(path)
|
||||
end
|
||||
ensure
|
||||
HOMEBREW_CELLAR.unlink
|
||||
@ -116,7 +118,7 @@ describe Homebrew::Diagnostic::Checks do
|
||||
|
||||
specify "#check_tmpdir" do
|
||||
ENV["TMPDIR"] = "/i/don/t/exis/t"
|
||||
expect(subject.check_tmpdir).to match("doesn't exist")
|
||||
expect(checks.check_tmpdir).to match("doesn't exist")
|
||||
end
|
||||
|
||||
specify "#check_for_external_cmd_name_conflict" do
|
||||
@ -130,7 +132,7 @@ describe Homebrew::Diagnostic::Checks do
|
||||
|
||||
allow(Tap).to receive(:cmd_directories).and_return([path1, path2])
|
||||
|
||||
expect(subject.check_for_external_cmd_name_conflict)
|
||||
expect(checks.check_for_external_cmd_name_conflict)
|
||||
.to match("brew-foo")
|
||||
end
|
||||
end
|
||||
@ -138,7 +140,7 @@ describe Homebrew::Diagnostic::Checks do
|
||||
|
||||
specify "#check_homebrew_prefix" do
|
||||
allow(Homebrew).to receive(:default_prefix?).and_return(false)
|
||||
expect(subject.check_homebrew_prefix)
|
||||
expect(checks.check_homebrew_prefix)
|
||||
.to match("Your Homebrew's prefix is not #{Homebrew::DEFAULT_PREFIX}")
|
||||
end
|
||||
end
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
require "download_strategy"
|
||||
|
||||
describe AbstractDownloadStrategy do
|
||||
subject { described_class.new(url, name, version, **specs) }
|
||||
subject(:strategy) { described_class.new(url, name, version, **specs) }
|
||||
|
||||
let(:specs) { {} }
|
||||
let(:name) { "foo" }
|
||||
@ -17,7 +17,7 @@ describe AbstractDownloadStrategy do
|
||||
FileUtils.touch "foo", mtime: Time.now - 10
|
||||
FileUtils.touch "bar", mtime: Time.now - 100
|
||||
FileUtils.ln_s "not-exist", "baz"
|
||||
expect(subject.source_modified_time).to eq(File.mtime("foo"))
|
||||
expect(strategy.source_modified_time).to eq(File.mtime("foo"))
|
||||
end
|
||||
end
|
||||
|
||||
@ -25,13 +25,13 @@ describe AbstractDownloadStrategy do
|
||||
let(:specs) { { bottle: true } }
|
||||
|
||||
it "extends Pourable" do
|
||||
expect(subject).to be_a_kind_of(AbstractDownloadStrategy::Pourable)
|
||||
expect(strategy).to be_a_kind_of(AbstractDownloadStrategy::Pourable)
|
||||
end
|
||||
end
|
||||
|
||||
context "without specs[:bottle]" do
|
||||
it "is does not extend Pourable" do
|
||||
expect(subject).not_to be_a_kind_of(AbstractDownloadStrategy::Pourable)
|
||||
expect(strategy).not_to be_a_kind_of(AbstractDownloadStrategy::Pourable)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -50,20 +50,20 @@ describe VCSDownloadStrategy do
|
||||
end
|
||||
|
||||
describe GitHubGitDownloadStrategy do
|
||||
subject { described_class.new(url, name, version) }
|
||||
subject(:strategy) { described_class.new(url, name, version) }
|
||||
|
||||
let(:name) { "brew" }
|
||||
let(:url) { "https://github.com/homebrew/brew.git" }
|
||||
let(:version) { nil }
|
||||
|
||||
it "parses the URL and sets the corresponding instance variables" do
|
||||
expect(subject.instance_variable_get(:@user)).to eq("homebrew")
|
||||
expect(subject.instance_variable_get(:@repo)).to eq("brew")
|
||||
expect(strategy.instance_variable_get(:@user)).to eq("homebrew")
|
||||
expect(strategy.instance_variable_get(:@repo)).to eq("brew")
|
||||
end
|
||||
end
|
||||
|
||||
describe GitDownloadStrategy do
|
||||
subject { described_class.new(url, name, version) }
|
||||
subject(:strategy) { described_class.new(url, name, version) }
|
||||
|
||||
let(:name) { "baz" }
|
||||
let(:url) { "https://github.com/homebrew/foo" }
|
||||
@ -93,7 +93,7 @@ describe GitDownloadStrategy do
|
||||
cached_location.cd do
|
||||
setup_git_repo
|
||||
end
|
||||
expect(subject.source_modified_time.to_i).to eq(1_485_115_153)
|
||||
expect(strategy.source_modified_time.to_i).to eq(1_485_115_153)
|
||||
end
|
||||
end
|
||||
|
||||
@ -103,7 +103,7 @@ describe GitDownloadStrategy do
|
||||
FileUtils.touch "LICENSE"
|
||||
git_commit_all
|
||||
end
|
||||
expect(subject.last_commit).to eq("f68266e")
|
||||
expect(strategy.last_commit).to eq("f68266e")
|
||||
end
|
||||
|
||||
describe "#fetch_last_commit" do
|
||||
@ -122,13 +122,13 @@ describe GitDownloadStrategy do
|
||||
git_commit_all
|
||||
end
|
||||
|
||||
expect(subject.fetch_last_commit).to eq("f68266e")
|
||||
expect(strategy.fetch_last_commit).to eq("f68266e")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe CurlDownloadStrategy do
|
||||
subject { described_class.new(url, name, version, **specs) }
|
||||
subject(:strategy) { described_class.new(url, name, version, **specs) }
|
||||
|
||||
let(:name) { "foo" }
|
||||
let(:url) { "https://example.com/foo.tar.gz" }
|
||||
@ -136,15 +136,15 @@ describe CurlDownloadStrategy do
|
||||
let(:specs) { { user: "download:123456" } }
|
||||
|
||||
it "parses the opts and sets the corresponding args" do
|
||||
expect(subject.send(:_curl_args)).to eq(["--user", "download:123456"])
|
||||
expect(strategy.send(:_curl_args)).to eq(["--user", "download:123456"])
|
||||
end
|
||||
|
||||
describe "#cached_location" do
|
||||
subject { described_class.new(url, name, version, **specs).cached_location }
|
||||
subject(:location) { described_class.new(url, name, version, **specs).cached_location }
|
||||
|
||||
context "when URL ends with file" do
|
||||
it {
|
||||
expect(subject).to eq(
|
||||
expect(location).to eq(
|
||||
HOMEBREW_CACHE/"downloads/3d1c0ae7da22be9d83fb1eb774df96b7c4da71d3cf07e1cb28555cf9a5e5af70--foo.tar.gz",
|
||||
)
|
||||
}
|
||||
@ -154,7 +154,7 @@ describe CurlDownloadStrategy do
|
||||
let(:url) { "https://example.com/foo.tar.gz/from/this/mirror" }
|
||||
|
||||
it {
|
||||
expect(subject).to eq(
|
||||
expect(location).to eq(
|
||||
HOMEBREW_CACHE/"downloads/1ab61269ba52c83994510b1e28dd04167a2f2e8393a35a9c50c1f7d33fd8f619--foo.tar.gz",
|
||||
)
|
||||
}
|
||||
@ -163,12 +163,12 @@ describe CurlDownloadStrategy do
|
||||
|
||||
describe "#fetch" do
|
||||
before do
|
||||
subject.temporary_path.dirname.mkpath
|
||||
FileUtils.touch subject.temporary_path
|
||||
strategy.temporary_path.dirname.mkpath
|
||||
FileUtils.touch strategy.temporary_path
|
||||
end
|
||||
|
||||
it "calls curl with default arguments" do
|
||||
expect(subject).to receive(:curl).with(
|
||||
expect(strategy).to receive(:curl).with(
|
||||
"--location",
|
||||
"--remote-time",
|
||||
"--continue-at", "0",
|
||||
@ -177,21 +177,21 @@ describe CurlDownloadStrategy do
|
||||
an_instance_of(Hash)
|
||||
)
|
||||
|
||||
subject.fetch
|
||||
strategy.fetch
|
||||
end
|
||||
|
||||
context "with an explicit user agent" do
|
||||
let(:specs) { { user_agent: "Mozilla/25.0.1" } }
|
||||
|
||||
it "adds the appropriate curl args" do
|
||||
expect(subject).to receive(:system_command).with(
|
||||
expect(strategy).to receive(:system_command).with(
|
||||
/curl/,
|
||||
hash_including(args: array_including_cons("--user-agent", "Mozilla/25.0.1")),
|
||||
)
|
||||
.at_least(:once)
|
||||
.and_return(instance_double(SystemCommand::Result, success?: true, stdout: "", assert_success!: nil))
|
||||
|
||||
subject.fetch
|
||||
strategy.fetch
|
||||
end
|
||||
end
|
||||
|
||||
@ -201,7 +201,7 @@ describe CurlDownloadStrategy do
|
||||
let(:specs) { { user_agent: :fake } }
|
||||
|
||||
it "adds the appropriate curl args" do
|
||||
expect(subject).to receive(:system_command).with(
|
||||
expect(strategy).to receive(:system_command).with(
|
||||
/curl/,
|
||||
hash_including(args: array_including_cons(
|
||||
"--user-agent",
|
||||
@ -211,7 +211,7 @@ describe CurlDownloadStrategy do
|
||||
.at_least(:once)
|
||||
.and_return(instance_double(SystemCommand::Result, success?: true, stdout: "", assert_success!: nil))
|
||||
|
||||
subject.fetch
|
||||
strategy.fetch
|
||||
end
|
||||
end
|
||||
|
||||
@ -226,14 +226,14 @@ describe CurlDownloadStrategy do
|
||||
}
|
||||
|
||||
it "adds the appropriate curl args and does not URL-encode the cookies" do
|
||||
expect(subject).to receive(:system_command).with(
|
||||
expect(strategy).to receive(:system_command).with(
|
||||
/curl/,
|
||||
hash_including(args: array_including_cons("-b", "coo=k/e;mon=ster")),
|
||||
)
|
||||
.at_least(:once)
|
||||
.and_return(instance_double(SystemCommand::Result, success?: true, stdout: "", assert_success!: nil))
|
||||
|
||||
subject.fetch
|
||||
strategy.fetch
|
||||
end
|
||||
end
|
||||
|
||||
@ -241,14 +241,14 @@ describe CurlDownloadStrategy do
|
||||
let(:specs) { { referer: "https://somehost/also" } }
|
||||
|
||||
it "adds the appropriate curl args" do
|
||||
expect(subject).to receive(:system_command).with(
|
||||
expect(strategy).to receive(:system_command).with(
|
||||
/curl/,
|
||||
hash_including(args: array_including_cons("-e", "https://somehost/also")),
|
||||
)
|
||||
.at_least(:once)
|
||||
.and_return(instance_double(SystemCommand::Result, success?: true, stdout: "", assert_success!: nil))
|
||||
|
||||
subject.fetch
|
||||
strategy.fetch
|
||||
end
|
||||
end
|
||||
|
||||
@ -258,14 +258,14 @@ describe CurlDownloadStrategy do
|
||||
let(:specs) { { headers: ["foo", "bar"] } }
|
||||
|
||||
it "adds the appropriate curl args" do
|
||||
expect(subject).to receive(:system_command).with(
|
||||
expect(strategy).to receive(:system_command).with(
|
||||
/curl/,
|
||||
hash_including(args: array_including_cons("--header", "foo").and(array_including_cons("--header", "bar"))),
|
||||
)
|
||||
.at_least(:once)
|
||||
.and_return(instance_double(SystemCommand::Result, success?: true, stdout: "", assert_success!: nil))
|
||||
|
||||
subject.fetch
|
||||
strategy.fetch
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -315,7 +315,7 @@ describe CurlDownloadStrategy do
|
||||
end
|
||||
|
||||
describe CurlPostDownloadStrategy do
|
||||
subject { described_class.new(url, name, version, **specs) }
|
||||
subject(:strategy) { described_class.new(url, name, version, **specs) }
|
||||
|
||||
let(:name) { "foo" }
|
||||
let(:url) { "https://example.com/foo.tar.gz" }
|
||||
@ -324,8 +324,8 @@ describe CurlPostDownloadStrategy do
|
||||
|
||||
describe "#fetch" do
|
||||
before do
|
||||
subject.temporary_path.dirname.mkpath
|
||||
FileUtils.touch subject.temporary_path
|
||||
strategy.temporary_path.dirname.mkpath
|
||||
FileUtils.touch strategy.temporary_path
|
||||
end
|
||||
|
||||
context "with :using and :data specified" do
|
||||
@ -340,14 +340,14 @@ describe CurlPostDownloadStrategy do
|
||||
}
|
||||
|
||||
it "adds the appropriate curl args" do
|
||||
expect(subject).to receive(:system_command).with(
|
||||
expect(strategy).to receive(:system_command).with(
|
||||
/curl/,
|
||||
hash_including(args: array_including_cons("-d", "form=data").and(array_including_cons("-d", "is=good"))),
|
||||
)
|
||||
.at_least(:once)
|
||||
.and_return(instance_double(SystemCommand::Result, success?: true, stdout: "", assert_success!: nil))
|
||||
|
||||
subject.fetch
|
||||
strategy.fetch
|
||||
end
|
||||
end
|
||||
|
||||
@ -355,21 +355,21 @@ describe CurlPostDownloadStrategy do
|
||||
let(:specs) { { using: :post } }
|
||||
|
||||
it "adds the appropriate curl args" do
|
||||
expect(subject).to receive(:system_command).with(
|
||||
expect(strategy).to receive(:system_command).with(
|
||||
/curl/,
|
||||
hash_including(args: array_including_cons("-X", "POST")),
|
||||
)
|
||||
.at_least(:once)
|
||||
.and_return(instance_double(SystemCommand::Result, success?: true, stdout: "", assert_success!: nil))
|
||||
|
||||
subject.fetch
|
||||
strategy.fetch
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe SubversionDownloadStrategy do
|
||||
subject { described_class.new(url, name, version, **specs) }
|
||||
subject(:strategy) { described_class.new(url, name, version, **specs) }
|
||||
|
||||
let(:name) { "foo" }
|
||||
let(:url) { "https://example.com/foo.tar.gz" }
|
||||
@ -381,9 +381,9 @@ describe SubversionDownloadStrategy do
|
||||
let(:specs) { { trust_cert: true } }
|
||||
|
||||
it "adds the appropriate svn args" do
|
||||
expect(subject).to receive(:system_command!)
|
||||
expect(strategy).to receive(:system_command!)
|
||||
.with("svn", hash_including(args: array_including("--trust-server-cert", "--non-interactive")))
|
||||
subject.fetch
|
||||
strategy.fetch
|
||||
end
|
||||
end
|
||||
|
||||
@ -391,10 +391,10 @@ describe SubversionDownloadStrategy do
|
||||
let(:specs) { { revision: "10" } }
|
||||
|
||||
it "adds svn arguments for :revision" do
|
||||
expect(subject).to receive(:system_command!)
|
||||
expect(strategy).to receive(:system_command!)
|
||||
.with("svn", hash_including(args: array_including_cons("-r", "10")))
|
||||
|
||||
subject.fetch
|
||||
strategy.fetch
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -402,7 +402,7 @@ end
|
||||
|
||||
describe DownloadStrategyDetector do
|
||||
describe "::detect" do
|
||||
subject { described_class.detect(url, strategy) }
|
||||
subject(:strategy_detector) { described_class.detect(url, strategy) }
|
||||
|
||||
let(:url) { Object.new }
|
||||
let(:strategy) { nil }
|
||||
@ -420,7 +420,7 @@ describe DownloadStrategyDetector do
|
||||
end
|
||||
|
||||
it "defaults to curl" do
|
||||
expect(subject).to eq(CurlDownloadStrategy)
|
||||
expect(strategy_detector).to eq(CurlDownloadStrategy)
|
||||
end
|
||||
|
||||
it "raises an error when passed an unrecognized strategy" do
|
||||
|
||||
@ -47,7 +47,7 @@ describe ErrorDuringExecution do
|
||||
end
|
||||
|
||||
its(:to_s) {
|
||||
expect(subject.to_s).to eq <<~EOS
|
||||
expect(error.to_s).to eq <<~EOS
|
||||
Failure while executing; `false` exited with 1. Here's the output:
|
||||
This still worked.
|
||||
#{Formatter.error("Here something went wrong.\n")}
|
||||
@ -59,7 +59,7 @@ describe ErrorDuringExecution do
|
||||
let(:command) { ["env", "PATH=/bin", "cat", "with spaces"] }
|
||||
|
||||
its(:to_s) {
|
||||
expect(subject.to_s)
|
||||
expect(error.to_s)
|
||||
.to eq 'Failure while executing; `env PATH=/bin cat with\ spaces` exited with 1.'
|
||||
}
|
||||
end
|
||||
|
||||
@ -26,29 +26,29 @@ describe NoSuchKegError do
|
||||
end
|
||||
|
||||
describe FormulaValidationError do
|
||||
subject { described_class.new("foo", "sha257", "magic") }
|
||||
subject(:error) { described_class.new("foo", "sha257", "magic") }
|
||||
|
||||
its(:to_s) {
|
||||
expect(subject.to_s).to eq(%q(invalid attribute for formula 'foo': sha257 ("magic")))
|
||||
expect(error.to_s).to eq(%q(invalid attribute for formula 'foo': sha257 ("magic")))
|
||||
}
|
||||
end
|
||||
|
||||
describe FormulaUnavailableError do
|
||||
subject { described_class.new("foo") }
|
||||
subject(:error) { described_class.new("foo") }
|
||||
|
||||
describe "#dependent_s" do
|
||||
it "returns nil if there is no dependent" do
|
||||
expect(subject.dependent_s).to be nil
|
||||
expect(error.dependent_s).to be nil
|
||||
end
|
||||
|
||||
it "returns nil if it depended on by itself" do
|
||||
subject.dependent = "foo"
|
||||
expect(subject.dependent_s).to be nil
|
||||
error.dependent = "foo"
|
||||
expect(error.dependent_s).to be nil
|
||||
end
|
||||
|
||||
it "returns a string if there is a dependent" do
|
||||
subject.dependent = "foobar"
|
||||
expect(subject.dependent_s).to eq(" (dependency of foobar)")
|
||||
error.dependent = "foobar"
|
||||
expect(error.dependent_s).to eq(" (dependency of foobar)")
|
||||
end
|
||||
end
|
||||
|
||||
@ -58,11 +58,11 @@ describe FormulaUnavailableError do
|
||||
|
||||
context "with a dependent" do
|
||||
before do
|
||||
subject.dependent = "foobar"
|
||||
error.dependent = "foobar"
|
||||
end
|
||||
|
||||
its(:to_s) {
|
||||
expect(subject.to_s).to eq('No available formula with the name "foo" (dependency of foobar).')
|
||||
expect(error.to_s).to eq('No available formula with the name "foo" (dependency of foobar).')
|
||||
}
|
||||
end
|
||||
end
|
||||
@ -76,7 +76,7 @@ describe TapFormulaUnavailableError do
|
||||
end
|
||||
|
||||
describe FormulaClassUnavailableError do
|
||||
subject { described_class.new("foo", "foo.rb", "Foo", list) }
|
||||
subject(:error) { described_class.new("foo", "foo.rb", "Foo", list) }
|
||||
|
||||
let(:mod) do
|
||||
Module.new do
|
||||
@ -90,7 +90,7 @@ describe FormulaClassUnavailableError do
|
||||
let(:list) { [] }
|
||||
|
||||
its(:to_s) {
|
||||
expect(subject.to_s).to match(/Expected to find class Foo, but found no classes\./)
|
||||
expect(error.to_s).to match(/Expected to find class Foo, but found no classes\./)
|
||||
}
|
||||
end
|
||||
|
||||
@ -98,7 +98,7 @@ describe FormulaClassUnavailableError do
|
||||
let(:list) { [mod.const_get(:Bar)] }
|
||||
|
||||
its(:to_s) {
|
||||
expect(subject.to_s).to match(/Expected to find class Foo, but only found: Bar \(not derived from Formula!\)\./)
|
||||
expect(error.to_s).to match(/Expected to find class Foo, but only found: Bar \(not derived from Formula!\)\./)
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@ require "utils/tty"
|
||||
|
||||
describe Formatter do
|
||||
describe "::columns" do
|
||||
subject { described_class.columns(input) }
|
||||
subject(:columns) { described_class.columns(input) }
|
||||
|
||||
let(:input) {
|
||||
%w[
|
||||
@ -21,7 +21,7 @@ describe Formatter do
|
||||
allow_any_instance_of(IO).to receive(:tty?).and_return(false)
|
||||
allow(Tty).to receive(:width).and_return(10)
|
||||
|
||||
expect(subject).to eq(
|
||||
expect(columns).to eq(
|
||||
"aa\n" \
|
||||
"bbb\n" \
|
||||
"ccc\n" \
|
||||
@ -34,7 +34,7 @@ describe Formatter do
|
||||
allow_any_instance_of(IO).to receive(:tty?).and_return(true)
|
||||
allow(Tty).to receive(:width).and_return(10)
|
||||
|
||||
expect(subject).to eq(
|
||||
expect(columns).to eq(
|
||||
"aa ccc\n" \
|
||||
"bbb dd\n",
|
||||
)
|
||||
@ -44,7 +44,7 @@ describe Formatter do
|
||||
allow_any_instance_of(IO).to receive(:tty?).and_return(true)
|
||||
allow(Tty).to receive(:width).and_return(20)
|
||||
|
||||
expect(subject).to eq(
|
||||
expect(columns).to eq(
|
||||
"aa bbb ccc dd\n",
|
||||
)
|
||||
end
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
require "formula_pin"
|
||||
|
||||
describe FormulaPin do
|
||||
subject { described_class.new(formula) }
|
||||
subject(:formula_pin) { described_class.new(formula) }
|
||||
|
||||
let(:name) { "double" }
|
||||
let(:formula) { double(Formula, name: name, rack: HOMEBREW_CELLAR/name) }
|
||||
@ -22,24 +22,24 @@ describe FormulaPin do
|
||||
end
|
||||
|
||||
it "is not pinnable by default" do
|
||||
expect(subject).not_to be_pinnable
|
||||
expect(formula_pin).not_to be_pinnable
|
||||
end
|
||||
|
||||
it "is pinnable if the Keg exists" do
|
||||
(formula.rack/"0.1").mkpath
|
||||
expect(subject).to be_pinnable
|
||||
expect(formula_pin).to be_pinnable
|
||||
end
|
||||
|
||||
specify "#pin and #unpin" do
|
||||
(formula.rack/"0.1").mkpath
|
||||
|
||||
subject.pin
|
||||
expect(subject).to be_pinned
|
||||
formula_pin.pin
|
||||
expect(formula_pin).to be_pinned
|
||||
expect(HOMEBREW_PINNED_KEGS/name).to be_a_directory
|
||||
expect(HOMEBREW_PINNED_KEGS.children.count).to eq(1)
|
||||
|
||||
subject.unpin
|
||||
expect(subject).not_to be_pinned
|
||||
formula_pin.unpin
|
||||
expect(formula_pin).not_to be_pinned
|
||||
expect(HOMEBREW_PINNED_KEGS).not_to be_a_directory
|
||||
end
|
||||
end
|
||||
|
||||
@ -13,16 +13,16 @@ describe Language::Node do
|
||||
end
|
||||
stub_formula_loader(node)
|
||||
expect(ENV).to receive(:prepend_path)
|
||||
subject.instance_variable_set(:@env_set, false)
|
||||
expect(subject.setup_npm_environment).to be_nil
|
||||
described_class.instance_variable_set(:@env_set, false)
|
||||
expect(described_class.setup_npm_environment).to be_nil
|
||||
|
||||
expect(subject.instance_variable_get(:@env_set)).to eq(true)
|
||||
expect(described_class.instance_variable_get(:@env_set)).to eq(true)
|
||||
expect(ENV).not_to receive(:prepend_path)
|
||||
expect(subject.setup_npm_environment).to be_nil
|
||||
expect(described_class.setup_npm_environment).to be_nil
|
||||
end
|
||||
|
||||
it "does not call prepend_path when node formula does not exist" do
|
||||
expect(subject.setup_npm_environment).to be_nil
|
||||
expect(described_class.setup_npm_environment).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
@ -32,7 +32,7 @@ describe Language::Node do
|
||||
path = Pathname("package.json")
|
||||
path.atomic_write("{\"scripts\":{\"prepare\": \"ls\", \"prepack\": \"ls\", \"test\": \"ls\"}}")
|
||||
allow(Utils).to receive(:popen_read).with(npm_pack_cmd).and_return(`echo pack.tgz`)
|
||||
subject.pack_for_installation
|
||||
described_class.pack_for_installation
|
||||
expect(path.read).not_to include("prepare")
|
||||
expect(path.read).not_to include("prepack")
|
||||
expect(path.read).to include("test")
|
||||
@ -45,25 +45,25 @@ describe Language::Node do
|
||||
|
||||
it "raises error with non zero exitstatus" do
|
||||
allow(Utils).to receive(:popen_read).with(npm_pack_cmd).and_return(`false`)
|
||||
expect { subject.std_npm_install_args(npm_install_arg) }.to \
|
||||
expect { described_class.std_npm_install_args(npm_install_arg) }.to \
|
||||
raise_error("npm failed to pack #{Dir.pwd}")
|
||||
end
|
||||
|
||||
it "raises error with empty npm pack output" do
|
||||
allow(Utils).to receive(:popen_read).with(npm_pack_cmd).and_return(`true`)
|
||||
expect { subject.std_npm_install_args(npm_install_arg) }.to \
|
||||
expect { described_class.std_npm_install_args(npm_install_arg) }.to \
|
||||
raise_error("npm failed to pack #{Dir.pwd}")
|
||||
end
|
||||
|
||||
it "does not raise error with a zero exitstatus" do
|
||||
allow(Utils).to receive(:popen_read).with(npm_pack_cmd).and_return(`echo pack.tgz`)
|
||||
resp = subject.std_npm_install_args(npm_install_arg)
|
||||
resp = described_class.std_npm_install_args(npm_install_arg)
|
||||
expect(resp).to include("--prefix=#{npm_install_arg}", "#{Dir.pwd}/pack.tgz")
|
||||
end
|
||||
end
|
||||
|
||||
specify "#local_npm_install_args" do
|
||||
resp = subject.local_npm_install_args
|
||||
resp = described_class.local_npm_install_args
|
||||
expect(resp).to include("-ddd", "--build-from-source", "--cache=#{HOMEBREW_CACHE}/npm_cache")
|
||||
end
|
||||
end
|
||||
|
||||
@ -8,28 +8,28 @@ require "utils/shebang"
|
||||
describe Language::Python, :needs_python do
|
||||
describe "#major_minor_version" do
|
||||
it "returns a Version for Python 2" do
|
||||
expect(subject).to receive(:major_minor_version).and_return(Version)
|
||||
subject.major_minor_version("python")
|
||||
expect(described_class).to receive(:major_minor_version).and_return(Version)
|
||||
described_class.major_minor_version("python")
|
||||
end
|
||||
end
|
||||
|
||||
describe "#site_packages" do
|
||||
it "gives a different location between PyPy and Python 2" do
|
||||
expect(subject.site_packages("python")).not_to eql(subject.site_packages("pypy"))
|
||||
expect(described_class.site_packages("python")).not_to eql(described_class.site_packages("pypy"))
|
||||
end
|
||||
end
|
||||
|
||||
describe "#homebrew_site_packages" do
|
||||
it "returns the Homebrew site packages location" do
|
||||
expect(subject).to receive(:site_packages).and_return(Pathname)
|
||||
subject.site_packages("python")
|
||||
expect(described_class).to receive(:site_packages).and_return(Pathname)
|
||||
described_class.site_packages("python")
|
||||
end
|
||||
end
|
||||
|
||||
describe "#user_site_packages" do
|
||||
it "can determine user site packages location" do
|
||||
expect(subject).to receive(:user_site_packages).and_return(Pathname)
|
||||
subject.user_site_packages("python")
|
||||
expect(described_class).to receive(:user_site_packages).and_return(Pathname)
|
||||
described_class.user_site_packages("python")
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -77,7 +77,7 @@ describe Language::Python::Shebang do
|
||||
end
|
||||
|
||||
describe Language::Python::Virtualenv::Virtualenv do
|
||||
subject { described_class.new(formula, dir, "python") }
|
||||
subject(:virtualenv) { described_class.new(formula, dir, "python") }
|
||||
|
||||
let(:dir) { mktmpdir }
|
||||
|
||||
@ -88,7 +88,7 @@ describe Language::Python::Virtualenv::Virtualenv do
|
||||
describe "#create" do
|
||||
it "creates a venv" do
|
||||
expect(formula).to receive(:system).with("python", "-m", "venv", dir)
|
||||
subject.create
|
||||
virtualenv.create
|
||||
end
|
||||
end
|
||||
|
||||
@ -98,7 +98,7 @@ describe Language::Python::Virtualenv::Virtualenv do
|
||||
.with(dir/"bin/pip", "install", "-v", "--no-deps",
|
||||
"--no-binary", ":all:", "--no-user", "--ignore-installed", "foo")
|
||||
.and_return(true)
|
||||
subject.pip_install "foo"
|
||||
virtualenv.pip_install "foo"
|
||||
end
|
||||
|
||||
it "accepts a multi-line strings" do
|
||||
@ -107,7 +107,7 @@ describe Language::Python::Virtualenv::Virtualenv do
|
||||
"--no-binary", ":all:", "--no-user", "--ignore-installed", "foo", "bar")
|
||||
.and_return(true)
|
||||
|
||||
subject.pip_install <<~EOS
|
||||
virtualenv.pip_install <<~EOS
|
||||
foo
|
||||
bar
|
||||
EOS
|
||||
@ -124,7 +124,7 @@ describe Language::Python::Virtualenv::Virtualenv do
|
||||
"--no-binary", ":all:", "--no-user", "--ignore-installed", "bar")
|
||||
.and_return(true)
|
||||
|
||||
subject.pip_install ["foo", "bar"]
|
||||
virtualenv.pip_install ["foo", "bar"]
|
||||
end
|
||||
|
||||
it "accepts a Resource" do
|
||||
@ -136,7 +136,7 @@ describe Language::Python::Virtualenv::Virtualenv do
|
||||
"--no-binary", ":all:", "--no-user", "--ignore-installed", Pathname.pwd)
|
||||
.and_return(true)
|
||||
|
||||
subject.pip_install res
|
||||
virtualenv.pip_install res
|
||||
end
|
||||
end
|
||||
|
||||
@ -155,10 +155,10 @@ describe Language::Python::Virtualenv::Virtualenv do
|
||||
FileUtils.touch src_bin/"kilroy"
|
||||
bin_after = Dir.glob(src_bin/"*")
|
||||
|
||||
expect(subject).to receive(:pip_install).with("foo")
|
||||
expect(virtualenv).to receive(:pip_install).with("foo")
|
||||
expect(Dir).to receive(:[]).with(src_bin/"*").twice.and_return(bin_before, bin_after)
|
||||
|
||||
subject.pip_install_and_link "foo"
|
||||
virtualenv.pip_install_and_link "foo"
|
||||
|
||||
expect(src_bin/"kilroy").to exist
|
||||
expect(dest_bin/"kilroy").to exist
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
require "linkage_cache_store"
|
||||
|
||||
describe LinkageCacheStore do
|
||||
subject { described_class.new(keg_name, database) }
|
||||
subject(:linkage_cache) { described_class.new(keg_name, database) }
|
||||
|
||||
let(:keg_name) { "keg_name" }
|
||||
let(:database) { double("database") }
|
||||
@ -13,14 +13,14 @@ describe LinkageCacheStore do
|
||||
context "`keg_name` exists in cache" do
|
||||
it "returns `true`" do
|
||||
expect(database).to receive(:get).with(keg_name).and_return("")
|
||||
expect(subject.keg_exists?).to be(true)
|
||||
expect(linkage_cache.keg_exists?).to be(true)
|
||||
end
|
||||
end
|
||||
|
||||
context "`keg_name` does not exist in cache" do
|
||||
it "returns `false`" do
|
||||
expect(database).to receive(:get).with(keg_name).and_return(nil)
|
||||
expect(subject.keg_exists?).to be(false)
|
||||
expect(linkage_cache.keg_exists?).to be(false)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -29,13 +29,13 @@ describe LinkageCacheStore do
|
||||
context "a `value` is a `Hash`" do
|
||||
it "sets the cache for the `keg_name`" do
|
||||
expect(database).to receive(:set).with(keg_name, anything)
|
||||
subject.update!(keg_files_dylibs: { key: ["value"] })
|
||||
linkage_cache.update!(keg_files_dylibs: { key: ["value"] })
|
||||
end
|
||||
end
|
||||
|
||||
context "a `value` is not a `Hash`" do
|
||||
it "raises a `TypeError` if a `value` is not a `Hash`" do
|
||||
expect { subject.update!(a_value: ["value"]) }.to raise_error(TypeError)
|
||||
expect { linkage_cache.update!(a_value: ["value"]) }.to raise_error(TypeError)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -43,7 +43,7 @@ describe LinkageCacheStore do
|
||||
describe "#delete!" do
|
||||
it "calls `delete` on the `database` with `keg_name` as parameter" do
|
||||
expect(database).to receive(:delete).with(keg_name)
|
||||
subject.delete!
|
||||
linkage_cache.delete!
|
||||
end
|
||||
end
|
||||
|
||||
@ -51,13 +51,13 @@ describe LinkageCacheStore do
|
||||
context "`HASH_LINKAGE_TYPES.include?(type)`" do
|
||||
it "returns a `Hash` of values" do
|
||||
expect(database).to receive(:get).with(keg_name).and_return(nil)
|
||||
expect(subject.fetch(:keg_files_dylibs)).to be_an_instance_of(Hash)
|
||||
expect(linkage_cache.fetch(:keg_files_dylibs)).to be_an_instance_of(Hash)
|
||||
end
|
||||
end
|
||||
|
||||
context "`type` not in `HASH_LINKAGE_TYPES`" do
|
||||
it "raises a `TypeError` if the `type` is not supported" do
|
||||
expect { subject.fetch(:bad_type) }.to raise_error(TypeError)
|
||||
expect { linkage_cache.fetch(:bad_type) }.to raise_error(TypeError)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -58,11 +58,11 @@ describe Locale do
|
||||
end
|
||||
|
||||
describe "#eql?" do
|
||||
subject { described_class.new("zh", "CN", "Hans") }
|
||||
subject(:locale) { described_class.new("zh", "CN", "Hans") }
|
||||
|
||||
context "all parts match" do
|
||||
it { is_expected.to eql("zh-CN-Hans") }
|
||||
it { is_expected.to eql(subject) }
|
||||
it { is_expected.to eql(locale) }
|
||||
end
|
||||
|
||||
context "only some parts match" do
|
||||
@ -74,8 +74,8 @@ describe Locale do
|
||||
end
|
||||
|
||||
it "does not raise if 'other' cannot be parsed" do
|
||||
expect { subject.eql?("zh_CN_Hans") }.not_to raise_error
|
||||
expect(subject.eql?("zh_CN_Hans")).to be false
|
||||
expect { locale.eql?("zh_CN_Hans") }.not_to raise_error
|
||||
expect(locale.eql?("zh_CN_Hans")).to be false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -4,17 +4,17 @@
|
||||
require "lock_file"
|
||||
|
||||
describe LockFile do
|
||||
subject { described_class.new("foo") }
|
||||
subject(:lock_file) { described_class.new("foo") }
|
||||
|
||||
describe "#lock" do
|
||||
it "does not raise an error when already locked" do
|
||||
subject.lock
|
||||
lock_file.lock
|
||||
|
||||
expect { subject.lock }.not_to raise_error
|
||||
expect { lock_file.lock }.not_to raise_error
|
||||
end
|
||||
|
||||
it "raises an error if a lock already exists" do
|
||||
subject.lock
|
||||
lock_file.lock
|
||||
|
||||
expect {
|
||||
described_class.new("foo").lock
|
||||
@ -24,12 +24,12 @@ describe LockFile do
|
||||
|
||||
describe "#unlock" do
|
||||
it "does not raise an error when already unlocked" do
|
||||
expect { subject.unlock }.not_to raise_error
|
||||
expect { lock_file.unlock }.not_to raise_error
|
||||
end
|
||||
|
||||
it "unlocks when locked" do
|
||||
subject.lock
|
||||
subject.unlock
|
||||
lock_file.lock
|
||||
lock_file.unlock
|
||||
|
||||
expect { described_class.new("foo").lock }.not_to raise_error
|
||||
end
|
||||
|
||||
@ -7,7 +7,7 @@ require "tab"
|
||||
require "keg"
|
||||
|
||||
describe Migrator do
|
||||
subject { described_class.new(new_formula) }
|
||||
subject(:migrator) { described_class.new(new_formula) }
|
||||
|
||||
let(:new_formula) { Testball.new("newname") }
|
||||
let(:old_formula) { Testball.new("oldname") }
|
||||
@ -41,7 +41,7 @@ describe Migrator do
|
||||
|
||||
old_pin.make_relative_symlink old_keg_record
|
||||
|
||||
subject # needs to be evaluated eagerly
|
||||
migrator # needs to be evaluated eagerly
|
||||
|
||||
(HOMEBREW_PREFIX/"bin").mkpath
|
||||
end
|
||||
@ -84,7 +84,7 @@ describe Migrator do
|
||||
|
||||
specify "#move_to_new_directory" do
|
||||
keg.unlink
|
||||
subject.move_to_new_directory
|
||||
migrator.move_to_new_directory
|
||||
|
||||
expect(new_keg_record).to be_a_directory
|
||||
expect(new_keg_record/"bin").to be_a_directory
|
||||
@ -97,7 +97,7 @@ describe Migrator do
|
||||
old_keg_record.parent.rmtree
|
||||
(new_keg_record/"bin").mkpath
|
||||
|
||||
subject.backup_oldname_cellar
|
||||
migrator.backup_oldname_cellar
|
||||
|
||||
expect(old_keg_record/"bin").to be_a_directory
|
||||
expect(old_keg_record/"bin").to be_a_directory
|
||||
@ -107,18 +107,18 @@ describe Migrator do
|
||||
(new_keg_record/"bin").mkpath
|
||||
expected_relative = new_keg_record.relative_path_from HOMEBREW_PINNED_KEGS
|
||||
|
||||
subject.repin
|
||||
migrator.repin
|
||||
|
||||
expect(subject.new_pin_record).to be_a_symlink
|
||||
expect(subject.new_pin_record.readlink).to eq(expected_relative)
|
||||
expect(subject.old_pin_record).not_to exist
|
||||
expect(migrator.new_pin_record).to be_a_symlink
|
||||
expect(migrator.new_pin_record.readlink).to eq(expected_relative)
|
||||
expect(migrator.old_pin_record).not_to exist
|
||||
end
|
||||
|
||||
specify "#unlink_oldname" do
|
||||
expect(HOMEBREW_LINKED_KEGS.children.count).to eq(1)
|
||||
expect((HOMEBREW_PREFIX/"opt").children.count).to eq(1)
|
||||
|
||||
subject.unlink_oldname
|
||||
migrator.unlink_oldname
|
||||
|
||||
expect(HOMEBREW_LINKED_KEGS).not_to exist
|
||||
expect(HOMEBREW_LIBRARY/"bin").not_to exist
|
||||
@ -133,7 +133,7 @@ describe Migrator do
|
||||
FileUtils.touch new_keg_record/"bin"/file
|
||||
end
|
||||
|
||||
subject.link_newname
|
||||
migrator.link_newname
|
||||
|
||||
expect(HOMEBREW_LINKED_KEGS.children.count).to eq(1)
|
||||
expect((HOMEBREW_PREFIX/"opt").children.count).to eq(1)
|
||||
@ -141,7 +141,7 @@ describe Migrator do
|
||||
|
||||
specify "#link_oldname_opt" do
|
||||
new_keg_record.mkpath
|
||||
subject.link_oldname_opt
|
||||
migrator.link_oldname_opt
|
||||
expect((HOMEBREW_PREFIX/"opt/oldname").realpath).to eq(new_keg_record.realpath)
|
||||
end
|
||||
|
||||
@ -149,7 +149,7 @@ describe Migrator do
|
||||
(new_keg_record/"bin").mkpath
|
||||
keg.unlink
|
||||
keg.uninstall
|
||||
subject.link_oldname_cellar
|
||||
migrator.link_oldname_cellar
|
||||
expect((HOMEBREW_CELLAR/"oldname").realpath).to eq(new_keg_record.parent.realpath)
|
||||
end
|
||||
|
||||
@ -159,7 +159,7 @@ describe Migrator do
|
||||
tab.tabfile = HOMEBREW_CELLAR/"newname/0.1/INSTALL_RECEIPT.json"
|
||||
tab.source["path"] = "/path/that/must/be/changed/by/update_tabs"
|
||||
tab.write
|
||||
subject.update_tabs
|
||||
migrator.update_tabs
|
||||
expect(Tab.for_keg(new_keg_record).source["path"]).to eq(new_formula.path.to_s)
|
||||
end
|
||||
|
||||
@ -169,7 +169,7 @@ describe Migrator do
|
||||
tab.source["path"] = old_formula.path.to_s
|
||||
tab.write
|
||||
|
||||
subject.migrate
|
||||
migrator.migrate
|
||||
|
||||
expect(new_keg_record).to exist
|
||||
expect(old_keg_record.parent).to be_a_symlink
|
||||
@ -187,7 +187,7 @@ describe Migrator do
|
||||
old_opt_record = HOMEBREW_PREFIX/"opt/oldname"
|
||||
old_opt_record.unlink if old_opt_record.symlink?
|
||||
old_opt_record.make_relative_symlink(new_keg_record)
|
||||
subject.unlink_oldname_opt
|
||||
migrator.unlink_oldname_opt
|
||||
expect(old_opt_record).not_to be_a_symlink
|
||||
end
|
||||
|
||||
@ -196,7 +196,7 @@ describe Migrator do
|
||||
keg.unlink
|
||||
keg.uninstall
|
||||
old_keg_record.parent.make_relative_symlink(new_keg_record.parent)
|
||||
subject.unlink_oldname_cellar
|
||||
migrator.unlink_oldname_cellar
|
||||
expect(old_keg_record.parent).not_to be_a_symlink
|
||||
end
|
||||
|
||||
@ -204,7 +204,7 @@ describe Migrator do
|
||||
(new_keg_record/"bin").mkpath
|
||||
keg.unlink
|
||||
keg.uninstall
|
||||
subject.backup_oldname_cellar
|
||||
migrator.backup_oldname_cellar
|
||||
expect(old_keg_record.subdirs).not_to be_empty
|
||||
end
|
||||
|
||||
@ -222,7 +222,7 @@ describe Migrator do
|
||||
describe "#backup_oldname" do
|
||||
context "when cellar exists" do
|
||||
it "backs up the old name" do
|
||||
subject.backup_oldname
|
||||
migrator.backup_oldname
|
||||
expect(old_keg_record.parent).to be_a_directory
|
||||
expect(old_keg_record.parent.subdirs).not_to be_empty
|
||||
expect(HOMEBREW_LINKED_KEGS/"oldname").to exist
|
||||
@ -237,7 +237,7 @@ describe Migrator do
|
||||
(new_keg_record/"bin").mkpath
|
||||
keg.unlink
|
||||
keg.uninstall
|
||||
subject.backup_oldname
|
||||
migrator.backup_oldname
|
||||
expect(old_keg_record.parent).to be_a_directory
|
||||
expect(old_keg_record.parent.subdirs).not_to be_empty
|
||||
expect(HOMEBREW_LINKED_KEGS/"oldname").to exist
|
||||
@ -253,7 +253,7 @@ describe Migrator do
|
||||
keg.unlink
|
||||
keg.uninstall
|
||||
old_keg_record.parent.make_relative_symlink(new_keg_record.parent)
|
||||
subject.backup_oldname
|
||||
migrator.backup_oldname
|
||||
expect(old_keg_record.parent).to be_a_directory
|
||||
expect(old_keg_record.parent.subdirs).not_to be_empty
|
||||
expect(HOMEBREW_LINKED_KEGS/"oldname").to exist
|
||||
|
||||
@ -4,136 +4,138 @@
|
||||
require "options"
|
||||
|
||||
describe Option do
|
||||
subject { described_class.new("foo") }
|
||||
subject(:option) { described_class.new("foo") }
|
||||
|
||||
specify "#to_s" do
|
||||
expect(subject.to_s).to eq("--foo")
|
||||
expect(option.to_s).to eq("--foo")
|
||||
end
|
||||
|
||||
specify "equality" do
|
||||
foo = described_class.new("foo")
|
||||
bar = described_class.new("bar")
|
||||
expect(subject).to eq(foo)
|
||||
expect(subject).not_to eq(bar)
|
||||
expect(subject).to eql(foo)
|
||||
expect(subject).not_to eql(bar)
|
||||
expect(option).to eq(foo)
|
||||
expect(option).not_to eq(bar)
|
||||
expect(option).to eql(foo)
|
||||
expect(option).not_to eql(bar)
|
||||
end
|
||||
|
||||
specify "#description" do
|
||||
expect(subject.description).to be_empty
|
||||
expect(option.description).to be_empty
|
||||
expect(described_class.new("foo", "foo").description).to eq("foo")
|
||||
end
|
||||
|
||||
specify "#inspect" do
|
||||
expect(subject.inspect).to eq("#<Option: \"--foo\">")
|
||||
expect(option.inspect).to eq("#<Option: \"--foo\">")
|
||||
end
|
||||
end
|
||||
|
||||
describe DeprecatedOption do
|
||||
subject { described_class.new("foo", "bar") }
|
||||
subject(:option) { described_class.new("foo", "bar") }
|
||||
|
||||
specify "#old" do
|
||||
expect(subject.old).to eq("foo")
|
||||
expect(option.old).to eq("foo")
|
||||
end
|
||||
|
||||
specify "#old_flag" do
|
||||
expect(subject.old_flag).to eq("--foo")
|
||||
expect(option.old_flag).to eq("--foo")
|
||||
end
|
||||
|
||||
specify "#current" do
|
||||
expect(subject.current).to eq("bar")
|
||||
expect(option.current).to eq("bar")
|
||||
end
|
||||
|
||||
specify "#current_flag" do
|
||||
expect(subject.current_flag).to eq("--bar")
|
||||
expect(option.current_flag).to eq("--bar")
|
||||
end
|
||||
|
||||
specify "equality" do
|
||||
foobar = described_class.new("foo", "bar")
|
||||
boofar = described_class.new("boo", "far")
|
||||
expect(foobar).to eq(subject)
|
||||
expect(subject).to eq(foobar)
|
||||
expect(boofar).not_to eq(subject)
|
||||
expect(subject).not_to eq(boofar)
|
||||
expect(foobar).to eq(option)
|
||||
expect(option).to eq(foobar)
|
||||
expect(boofar).not_to eq(option)
|
||||
expect(option).not_to eq(boofar)
|
||||
end
|
||||
end
|
||||
|
||||
describe Options do
|
||||
subject(:options) { described_class.new }
|
||||
|
||||
it "removes duplicate options" do
|
||||
subject << Option.new("foo")
|
||||
subject << Option.new("foo")
|
||||
expect(subject).to include("--foo")
|
||||
expect(subject.count).to eq(1)
|
||||
options << Option.new("foo")
|
||||
options << Option.new("foo")
|
||||
expect(options).to include("--foo")
|
||||
expect(options.count).to eq(1)
|
||||
end
|
||||
|
||||
it "preserves existing member when adding a duplicate" do
|
||||
a = Option.new("foo", "bar")
|
||||
b = Option.new("foo", "qux")
|
||||
subject << a << b
|
||||
expect(subject.count).to eq(1)
|
||||
expect(subject.first).to be(a)
|
||||
expect(subject.first.description).to eq(a.description)
|
||||
options << a << b
|
||||
expect(options.count).to eq(1)
|
||||
expect(options.first).to be(a)
|
||||
expect(options.first.description).to eq(a.description)
|
||||
end
|
||||
|
||||
specify "#include?" do
|
||||
subject << Option.new("foo")
|
||||
expect(subject).to include("--foo")
|
||||
expect(subject).to include("foo")
|
||||
expect(subject).to include(Option.new("foo"))
|
||||
options << Option.new("foo")
|
||||
expect(options).to include("--foo")
|
||||
expect(options).to include("foo")
|
||||
expect(options).to include(Option.new("foo"))
|
||||
end
|
||||
|
||||
describe "#+" do
|
||||
it "returns options" do
|
||||
expect(subject + described_class.new).to be_an_instance_of(described_class)
|
||||
expect(options + described_class.new).to be_an_instance_of(described_class)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#-" do
|
||||
it "returns options" do
|
||||
expect(subject - described_class.new).to be_an_instance_of(described_class)
|
||||
expect(options - described_class.new).to be_an_instance_of(described_class)
|
||||
end
|
||||
end
|
||||
|
||||
specify "#&" do
|
||||
foo, bar, baz = %w[foo bar baz].map { |o| Option.new(o) }
|
||||
options = described_class.new << foo << bar
|
||||
subject << foo << baz
|
||||
expect((subject & options).to_a).to eq([foo])
|
||||
other_options = described_class.new << foo << bar
|
||||
options << foo << baz
|
||||
expect((options & other_options).to_a).to eq([foo])
|
||||
end
|
||||
|
||||
specify "#|" do
|
||||
foo, bar, baz = %w[foo bar baz].map { |o| Option.new(o) }
|
||||
options = described_class.new << foo << bar
|
||||
subject << foo << baz
|
||||
expect((subject | options).sort).to eq([foo, bar, baz].sort)
|
||||
other_options = described_class.new << foo << bar
|
||||
options << foo << baz
|
||||
expect((options | other_options).sort).to eq([foo, bar, baz].sort)
|
||||
end
|
||||
|
||||
specify "#*" do
|
||||
subject << Option.new("aa") << Option.new("bb") << Option.new("cc")
|
||||
expect((subject * "XX").split("XX").sort).to eq(%w[--aa --bb --cc])
|
||||
options << Option.new("aa") << Option.new("bb") << Option.new("cc")
|
||||
expect((options * "XX").split("XX").sort).to eq(%w[--aa --bb --cc])
|
||||
end
|
||||
|
||||
describe "<<" do
|
||||
it "returns itself" do
|
||||
expect(subject << Option.new("foo")).to be subject
|
||||
expect(options << Option.new("foo")).to be options
|
||||
end
|
||||
end
|
||||
|
||||
specify "#as_flags" do
|
||||
subject << Option.new("foo")
|
||||
expect(subject.as_flags).to eq(%w[--foo])
|
||||
options << Option.new("foo")
|
||||
expect(options.as_flags).to eq(%w[--foo])
|
||||
end
|
||||
|
||||
specify "#to_a" do
|
||||
option = Option.new("foo")
|
||||
subject << option
|
||||
expect(subject.to_a).to eq([option])
|
||||
options << option
|
||||
expect(options.to_a).to eq([option])
|
||||
end
|
||||
|
||||
specify "#to_ary" do
|
||||
option = Option.new("foo")
|
||||
subject << option
|
||||
expect(subject.to_ary).to eq([option])
|
||||
options << option
|
||||
expect(options.to_ary).to eq([option])
|
||||
end
|
||||
|
||||
specify "::create_with_array" do
|
||||
@ -144,8 +146,8 @@ describe Options do
|
||||
end
|
||||
|
||||
specify "#inspect" do
|
||||
expect(subject.inspect).to eq("#<Options: []>")
|
||||
subject << Option.new("foo")
|
||||
expect(subject.inspect).to eq("#<Options: [#<Option: \"--foo\">]>")
|
||||
expect(options.inspect).to eq("#<Options: []>")
|
||||
options << Option.new("foo")
|
||||
expect(options.inspect).to eq("#<Options: [#<Option: \"--foo\">]>")
|
||||
end
|
||||
end
|
||||
|
||||
@ -6,6 +6,8 @@ require "dependency_collector"
|
||||
describe DependencyCollector do
|
||||
alias_matcher :be_a_build_requirement, :be_build
|
||||
|
||||
subject(:collector) { described_class.new }
|
||||
|
||||
describe "#add" do
|
||||
resource = Resource.new
|
||||
|
||||
@ -13,19 +15,19 @@ describe DependencyCollector do
|
||||
it "creates a resource dependency from a '.xz' URL" do
|
||||
resource.url("https://brew.sh/foo.xz")
|
||||
allow_any_instance_of(Object).to receive(:which).with("xz")
|
||||
expect(subject.add(resource)).to eq(Dependency.new("xz", [:build, :test]))
|
||||
expect(collector.add(resource)).to eq(Dependency.new("xz", [:build, :test]))
|
||||
end
|
||||
|
||||
it "creates a resource dependency from a '.zip' URL" do
|
||||
resource.url("https://brew.sh/foo.zip")
|
||||
allow_any_instance_of(Object).to receive(:which).with("unzip")
|
||||
expect(subject.add(resource)).to eq(Dependency.new("unzip", [:build, :test]))
|
||||
expect(collector.add(resource)).to eq(Dependency.new("unzip", [:build, :test]))
|
||||
end
|
||||
|
||||
it "creates a resource dependency from a '.bz2' URL" do
|
||||
resource.url("https://brew.sh/foo.tar.bz2")
|
||||
allow_any_instance_of(Object).to receive(:which).with("bzip2")
|
||||
expect(subject.add(resource)).to eq(Dependency.new("bzip2", [:build, :test]))
|
||||
expect(collector.add(resource)).to eq(Dependency.new("bzip2", [:build, :test]))
|
||||
end
|
||||
end
|
||||
|
||||
@ -33,19 +35,19 @@ describe DependencyCollector do
|
||||
it "does not create a resource dependency from a '.xz' URL" do
|
||||
resource.url("https://brew.sh/foo.xz")
|
||||
allow_any_instance_of(Object).to receive(:which).with("xz").and_return(Pathname.new("foo"))
|
||||
expect(subject.add(resource)).to be nil
|
||||
expect(collector.add(resource)).to be nil
|
||||
end
|
||||
|
||||
it "does not create a resource dependency from a '.zip' URL" do
|
||||
resource.url("https://brew.sh/foo.zip")
|
||||
allow_any_instance_of(Object).to receive(:which).with("unzip").and_return(Pathname.new("foo"))
|
||||
expect(subject.add(resource)).to be nil
|
||||
expect(collector.add(resource)).to be nil
|
||||
end
|
||||
|
||||
it "does not create a resource dependency from a '.bz2' URL" do
|
||||
resource.url("https://brew.sh/foo.tar.bz2")
|
||||
allow_any_instance_of(Object).to receive(:which).with("bzip2").and_return(Pathname.new("foo"))
|
||||
expect(subject.add(resource)).to be nil
|
||||
expect(collector.add(resource)).to be nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -4,24 +4,26 @@
|
||||
require "diagnostic"
|
||||
|
||||
describe Homebrew::Diagnostic::Checks do
|
||||
subject(:checks) { described_class.new }
|
||||
|
||||
specify "#check_supported_architecture" do
|
||||
allow(Hardware::CPU).to receive(:type).and_return(:arm64)
|
||||
|
||||
expect(subject.check_supported_architecture)
|
||||
expect(checks.check_supported_architecture)
|
||||
.to match(/Your CPU architecture .+ is not supported/)
|
||||
end
|
||||
|
||||
specify "#check_glibc_minimum_version" do
|
||||
allow(OS::Linux::Glibc).to receive(:below_minimum_version?).and_return(true)
|
||||
|
||||
expect(subject.check_glibc_minimum_version)
|
||||
expect(checks.check_glibc_minimum_version)
|
||||
.to match(/Your system glibc .+ is too old/)
|
||||
end
|
||||
|
||||
specify "#check_kernel_minimum_version" do
|
||||
allow(OS::Linux::Kernel).to receive(:below_minimum_version?).and_return(true)
|
||||
|
||||
expect(subject.check_kernel_minimum_version)
|
||||
expect(checks.check_kernel_minimum_version)
|
||||
.to match(/Your Linux kernel .+ is too old/)
|
||||
end
|
||||
end
|
||||
|
||||
@ -6,37 +6,39 @@ require "dependency_collector"
|
||||
describe DependencyCollector do
|
||||
alias_matcher :need_tar_xz_dependency, :be_tar_needs_xz_dependency
|
||||
|
||||
subject(:collector) { described_class.new }
|
||||
|
||||
specify "Resource dependency from a '.xz' URL" do
|
||||
resource = Resource.new
|
||||
resource.url("https://brew.sh/foo.tar.xz")
|
||||
expect(subject.add(resource)).to be nil
|
||||
expect(collector.add(resource)).to be nil
|
||||
end
|
||||
|
||||
specify "Resource dependency from a '.zip' URL" do
|
||||
resource = Resource.new
|
||||
resource.url("https://brew.sh/foo.zip")
|
||||
expect(subject.add(resource)).to be nil
|
||||
expect(collector.add(resource)).to be nil
|
||||
end
|
||||
|
||||
specify "Resource dependency from a '.bz2' URL" do
|
||||
resource = Resource.new
|
||||
resource.url("https://brew.sh/foo.tar.bz2")
|
||||
expect(subject.add(resource)).to be nil
|
||||
expect(collector.add(resource)).to be nil
|
||||
end
|
||||
|
||||
specify "Resource dependency from a '.git' URL" do
|
||||
resource = Resource.new
|
||||
resource.url("git://brew.sh/foo/bar.git")
|
||||
expect(subject.add(resource)).to be nil
|
||||
expect(collector.add(resource)).to be nil
|
||||
end
|
||||
|
||||
specify "Resource dependency from a Subversion URL" do
|
||||
resource = Resource.new
|
||||
resource.url("svn://brew.sh/foo/bar")
|
||||
if MacOS.version < :catalina
|
||||
expect(subject.add(resource)).to be nil
|
||||
expect(collector.add(resource)).to be nil
|
||||
else
|
||||
expect(subject.add(resource)).not_to be nil
|
||||
expect(collector.add(resource)).not_to be nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -4,6 +4,8 @@
|
||||
require "diagnostic"
|
||||
|
||||
describe Homebrew::Diagnostic::Checks do
|
||||
subject(:checks) { described_class.new }
|
||||
|
||||
specify "#check_for_unsupported_macos" do
|
||||
ENV.delete("HOMEBREW_DEVELOPER")
|
||||
|
||||
@ -12,7 +14,7 @@ describe Homebrew::Diagnostic::Checks do
|
||||
allow(OS::Mac).to receive(:full_version).and_return(macos_version)
|
||||
allow(OS::Mac).to receive(:prerelease?).and_return(true)
|
||||
|
||||
expect(subject.check_for_unsupported_macos)
|
||||
expect(checks.check_for_unsupported_macos)
|
||||
.to match("We do not provide support for this pre-release version.")
|
||||
end
|
||||
|
||||
@ -24,7 +26,7 @@ describe Homebrew::Diagnostic::Checks do
|
||||
allow(OS::Mac::Xcode).to receive(:version).and_return("8.0")
|
||||
allow(OS::Mac::Xcode).to receive(:without_clt?).and_return(true)
|
||||
|
||||
expect(subject.check_if_xcode_needs_clt_installed)
|
||||
expect(checks.check_if_xcode_needs_clt_installed)
|
||||
.to match("Xcode alone is not sufficient on El Capitan")
|
||||
end
|
||||
|
||||
@ -34,7 +36,7 @@ describe Homebrew::Diagnostic::Checks do
|
||||
allow(OS::Mac).to receive(:full_version).and_return(macos_version)
|
||||
stub_const("RUBY_VERSION", "1.8.6")
|
||||
|
||||
expect(subject.check_ruby_version)
|
||||
expect(checks.check_ruby_version)
|
||||
.to match "Ruby version 1.8.6 is unsupported on 10.12"
|
||||
end
|
||||
end
|
||||
|
||||
@ -6,21 +6,21 @@ require "keg"
|
||||
describe Keg do
|
||||
include FileUtils
|
||||
|
||||
subject { described_class.new(keg_path) }
|
||||
subject(:keg) { described_class.new(keg_path) }
|
||||
|
||||
describe "#mach_o_files" do
|
||||
let(:keg_path) { HOMEBREW_CELLAR/"a/1.0" }
|
||||
|
||||
before { (keg_path/"lib").mkpath }
|
||||
|
||||
after { subject.unlink }
|
||||
after { keg.unlink }
|
||||
|
||||
it "skips hardlinks" do
|
||||
cp dylib_path("i386"), keg_path/"lib/i386.dylib"
|
||||
ln keg_path/"lib/i386.dylib", keg_path/"lib/i386_hardlink.dylib"
|
||||
|
||||
subject.link
|
||||
expect(subject.mach_o_files.count).to eq(1)
|
||||
keg.link
|
||||
expect(keg.mach_o_files.count).to eq(1)
|
||||
end
|
||||
|
||||
it "isn't confused by symlinks" do
|
||||
@ -28,8 +28,8 @@ describe Keg do
|
||||
ln keg_path/"lib/i386.dylib", keg_path/"lib/i386_hardlink.dylib"
|
||||
ln_s keg_path/"lib/i386.dylib", keg_path/"lib/i386_symlink.dylib"
|
||||
|
||||
subject.link
|
||||
expect(subject.mach_o_files.count).to eq(1)
|
||||
keg.link
|
||||
expect(keg.mach_o_files.count).to eq(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -7,13 +7,13 @@ require "os/mac"
|
||||
describe OS::Mac do
|
||||
describe "::languages" do
|
||||
it "returns a list of all languages" do
|
||||
expect(subject.languages).not_to be_empty
|
||||
expect(described_class.languages).not_to be_empty
|
||||
end
|
||||
end
|
||||
|
||||
describe "::language" do
|
||||
it "returns the first item from #languages" do
|
||||
expect(subject.language).to eq(subject.languages.first)
|
||||
expect(described_class.language).to eq(described_class.languages.first)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -53,26 +53,26 @@ describe Patch do
|
||||
end
|
||||
|
||||
describe "#patch_files" do
|
||||
subject { described_class.create(:p2, nil) }
|
||||
subject(:patch) { described_class.create(:p2, nil) }
|
||||
|
||||
context "empty patch" do
|
||||
its(:resource) { is_expected.to be_kind_of Resource::PatchResource }
|
||||
its(:patch_files) { is_expected.to eq(subject.resource.patch_files) }
|
||||
its(:patch_files) { is_expected.to eq(patch.resource.patch_files) }
|
||||
its(:patch_files) { is_expected.to eq([]) }
|
||||
end
|
||||
|
||||
it "returns applied patch files" do
|
||||
subject.resource.apply("patch1.diff")
|
||||
expect(subject.patch_files).to eq(["patch1.diff"])
|
||||
patch.resource.apply("patch1.diff")
|
||||
expect(patch.patch_files).to eq(["patch1.diff"])
|
||||
|
||||
subject.resource.apply("patch2.diff", "patch3.diff")
|
||||
expect(subject.patch_files).to eq(["patch1.diff", "patch2.diff", "patch3.diff"])
|
||||
patch.resource.apply("patch2.diff", "patch3.diff")
|
||||
expect(patch.patch_files).to eq(["patch1.diff", "patch2.diff", "patch3.diff"])
|
||||
|
||||
subject.resource.apply(["patch4.diff", "patch5.diff"])
|
||||
expect(subject.patch_files.count).to eq(5)
|
||||
patch.resource.apply(["patch4.diff", "patch5.diff"])
|
||||
expect(patch.patch_files.count).to eq(5)
|
||||
|
||||
subject.resource.apply("patch4.diff", ["patch5.diff", "patch6.diff"], "patch7.diff")
|
||||
expect(subject.patch_files.count).to eq(7)
|
||||
patch.resource.apply("patch4.diff", ["patch5.diff", "patch6.diff"], "patch7.diff")
|
||||
expect(patch.patch_files.count).to eq(7)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -86,7 +86,7 @@ describe EmbeddedPatch do
|
||||
end
|
||||
|
||||
describe ExternalPatch do
|
||||
subject { described_class.new(:p1) { url "file:///my.patch" } }
|
||||
subject(:patch) { described_class.new(:p1) { url "file:///my.patch" } }
|
||||
|
||||
describe "#url" do
|
||||
its(:url) { is_expected.to eq("file:///my.patch") }
|
||||
@ -98,7 +98,7 @@ describe ExternalPatch do
|
||||
|
||||
describe "#cached_download" do
|
||||
before do
|
||||
allow(subject.resource).to receive(:cached_download).and_return("/tmp/foo.tar.gz")
|
||||
allow(patch.resource).to receive(:cached_download).and_return("/tmp/foo.tar.gz")
|
||||
end
|
||||
|
||||
its(:cached_download) { is_expected.to eq("/tmp/foo.tar.gz") }
|
||||
|
||||
@ -7,7 +7,7 @@ require "requirement"
|
||||
describe Requirement do
|
||||
alias_matcher :be_a_build_requirement, :be_a_build
|
||||
|
||||
subject { klass.new }
|
||||
subject(:requirement) { klass.new }
|
||||
|
||||
let(:klass) { Class.new(described_class) }
|
||||
|
||||
@ -111,7 +111,7 @@ describe Requirement do
|
||||
|
||||
it "sets up build environment" do
|
||||
expect(ENV).to receive(:with_build_environment).and_call_original
|
||||
subject.satisfied?
|
||||
requirement.satisfied?
|
||||
end
|
||||
end
|
||||
|
||||
@ -126,7 +126,7 @@ describe Requirement do
|
||||
|
||||
it "skips setting up build environment" do
|
||||
expect(ENV).not_to receive(:with_build_environment)
|
||||
subject.satisfied?
|
||||
requirement.satisfied?
|
||||
end
|
||||
end
|
||||
|
||||
@ -141,8 +141,8 @@ describe Requirement do
|
||||
|
||||
it "infers path from #satisfy result" do
|
||||
expect(ENV).to receive(:prepend_path).with("PATH", Pathname.new("/foo/bar"))
|
||||
subject.satisfied?
|
||||
subject.modify_build_environment
|
||||
requirement.satisfied?
|
||||
requirement.modify_build_environment
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -180,53 +180,53 @@ describe Requirement do
|
||||
let(:klass) { Class.new(described_class) }
|
||||
|
||||
it "returns nil" do
|
||||
expect(subject.modify_build_environment).to be nil
|
||||
expect(requirement.modify_build_environment).to be nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#eql? and #==" do
|
||||
subject { described_class.new }
|
||||
subject(:requirement) { described_class.new }
|
||||
|
||||
it "returns true if the names and tags are equal" do
|
||||
other = described_class.new
|
||||
|
||||
expect(subject).to eql(other)
|
||||
expect(subject).to eq(other)
|
||||
expect(requirement).to eql(other)
|
||||
expect(requirement).to eq(other)
|
||||
end
|
||||
|
||||
it "returns false if names differ" do
|
||||
other = described_class.new
|
||||
allow(other).to receive(:name).and_return("foo")
|
||||
expect(subject).not_to eql(other)
|
||||
expect(subject).not_to eq(other)
|
||||
expect(requirement).not_to eql(other)
|
||||
expect(requirement).not_to eq(other)
|
||||
end
|
||||
|
||||
it "returns false if tags differ" do
|
||||
other = described_class.new([:optional])
|
||||
|
||||
expect(subject).not_to eql(other)
|
||||
expect(subject).not_to eq(other)
|
||||
expect(requirement).not_to eql(other)
|
||||
expect(requirement).not_to eq(other)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#hash" do
|
||||
subject { described_class.new }
|
||||
subject(:requirement) { described_class.new }
|
||||
|
||||
it "is equal if names and tags are equal" do
|
||||
other = described_class.new
|
||||
expect(subject.hash).to eq(other.hash)
|
||||
expect(requirement.hash).to eq(other.hash)
|
||||
end
|
||||
|
||||
it "differs if names differ" do
|
||||
other = described_class.new
|
||||
allow(other).to receive(:name).and_return("foo")
|
||||
expect(subject.hash).not_to eq(other.hash)
|
||||
expect(requirement.hash).not_to eq(other.hash)
|
||||
end
|
||||
|
||||
it "differs if tags differ" do
|
||||
other = described_class.new([:optional])
|
||||
expect(subject.hash).not_to eq(other.hash)
|
||||
expect(requirement.hash).not_to eq(other.hash)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -4,14 +4,16 @@
|
||||
require "requirements"
|
||||
|
||||
describe Requirements do
|
||||
subject(:requirements) { described_class.new }
|
||||
|
||||
describe "#<<" do
|
||||
it "returns itself" do
|
||||
expect(subject << Object.new).to be(subject)
|
||||
expect(requirements << Object.new).to be(requirements)
|
||||
end
|
||||
|
||||
it "merges duplicate requirements" do
|
||||
subject << Requirement.new << Requirement.new
|
||||
expect(subject.count).to eq(1)
|
||||
requirements << Requirement.new << Requirement.new
|
||||
expect(requirements.count).to eq(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -4,111 +4,111 @@
|
||||
require "resource"
|
||||
|
||||
describe Resource do
|
||||
subject { described_class.new("test") }
|
||||
subject(:resource) { described_class.new("test") }
|
||||
|
||||
describe "#url" do
|
||||
it "sets the URL" do
|
||||
subject.url("foo")
|
||||
expect(subject.url).to eq("foo")
|
||||
resource.url("foo")
|
||||
expect(resource.url).to eq("foo")
|
||||
end
|
||||
|
||||
it "can set the URL with specifications" do
|
||||
subject.url("foo", branch: "master")
|
||||
expect(subject.url).to eq("foo")
|
||||
expect(subject.specs).to eq(branch: "master")
|
||||
resource.url("foo", branch: "master")
|
||||
expect(resource.url).to eq("foo")
|
||||
expect(resource.specs).to eq(branch: "master")
|
||||
end
|
||||
|
||||
it "can set the URL with a custom download strategy class" do
|
||||
strategy = Class.new(AbstractDownloadStrategy)
|
||||
subject.url("foo", using: strategy)
|
||||
expect(subject.url).to eq("foo")
|
||||
expect(subject.download_strategy).to eq(strategy)
|
||||
resource.url("foo", using: strategy)
|
||||
expect(resource.url).to eq("foo")
|
||||
expect(resource.download_strategy).to eq(strategy)
|
||||
end
|
||||
|
||||
it "can set the URL with specifications and a custom download strategy class" do
|
||||
strategy = Class.new(AbstractDownloadStrategy)
|
||||
subject.url("foo", using: strategy, branch: "master")
|
||||
expect(subject.url).to eq("foo")
|
||||
expect(subject.specs).to eq(branch: "master")
|
||||
expect(subject.download_strategy).to eq(strategy)
|
||||
resource.url("foo", using: strategy, branch: "master")
|
||||
expect(resource.url).to eq("foo")
|
||||
expect(resource.specs).to eq(branch: "master")
|
||||
expect(resource.download_strategy).to eq(strategy)
|
||||
end
|
||||
|
||||
it "can set the URL with a custom download strategy symbol" do
|
||||
subject.url("foo", using: :git)
|
||||
expect(subject.url).to eq("foo")
|
||||
expect(subject.download_strategy).to eq(GitDownloadStrategy)
|
||||
resource.url("foo", using: :git)
|
||||
expect(resource.url).to eq("foo")
|
||||
expect(resource.download_strategy).to eq(GitDownloadStrategy)
|
||||
end
|
||||
|
||||
it "raises an error if the download strategy class is unknown" do
|
||||
expect { subject.url("foo", using: Class.new) }.to raise_error(TypeError)
|
||||
expect { resource.url("foo", using: Class.new) }.to raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "does not mutate the specifications hash" do
|
||||
specs = { using: :git, branch: "master" }
|
||||
subject.url("foo", specs)
|
||||
expect(subject.specs).to eq(branch: "master")
|
||||
expect(subject.using).to eq(:git)
|
||||
resource.url("foo", specs)
|
||||
expect(resource.specs).to eq(branch: "master")
|
||||
expect(resource.using).to eq(:git)
|
||||
expect(specs).to eq(using: :git, branch: "master")
|
||||
end
|
||||
end
|
||||
|
||||
describe "#version" do
|
||||
it "sets the version" do
|
||||
subject.version("1.0")
|
||||
expect(subject.version).to eq(Version.parse("1.0"))
|
||||
expect(subject.version).not_to be_detected_from_url
|
||||
resource.version("1.0")
|
||||
expect(resource.version).to eq(Version.parse("1.0"))
|
||||
expect(resource.version).not_to be_detected_from_url
|
||||
end
|
||||
|
||||
it "can detect the version from a URL" do
|
||||
subject.url("https://brew.sh/foo-1.0.tar.gz")
|
||||
expect(subject.version).to eq(Version.parse("1.0"))
|
||||
expect(subject.version).to be_detected_from_url
|
||||
resource.url("https://brew.sh/foo-1.0.tar.gz")
|
||||
expect(resource.version).to eq(Version.parse("1.0"))
|
||||
expect(resource.version).to be_detected_from_url
|
||||
end
|
||||
|
||||
it "can set the version with a scheme" do
|
||||
klass = Class.new(Version)
|
||||
subject.version klass.new("1.0")
|
||||
expect(subject.version).to eq(Version.parse("1.0"))
|
||||
expect(subject.version).to be_a(klass)
|
||||
resource.version klass.new("1.0")
|
||||
expect(resource.version).to eq(Version.parse("1.0"))
|
||||
expect(resource.version).to be_a(klass)
|
||||
end
|
||||
|
||||
it "can set the version from a tag" do
|
||||
subject.url("https://brew.sh/foo-1.0.tar.gz", tag: "v1.0.2")
|
||||
expect(subject.version).to eq(Version.parse("1.0.2"))
|
||||
expect(subject.version).to be_detected_from_url
|
||||
resource.url("https://brew.sh/foo-1.0.tar.gz", tag: "v1.0.2")
|
||||
expect(resource.version).to eq(Version.parse("1.0.2"))
|
||||
expect(resource.version).to be_detected_from_url
|
||||
end
|
||||
|
||||
it "rejects non-string versions" do
|
||||
expect { subject.version(1) }.to raise_error(TypeError)
|
||||
expect { subject.version(2.0) }.to raise_error(TypeError)
|
||||
expect { subject.version(Object.new) }.to raise_error(TypeError)
|
||||
expect { resource.version(1) }.to raise_error(TypeError)
|
||||
expect { resource.version(2.0) }.to raise_error(TypeError)
|
||||
expect { resource.version(Object.new) }.to raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "returns nil if unset" do
|
||||
expect(subject.version).to be nil
|
||||
expect(resource.version).to be nil
|
||||
end
|
||||
end
|
||||
|
||||
describe "#mirrors" do
|
||||
it "is empty by defaults" do
|
||||
expect(subject.mirrors).to be_empty
|
||||
expect(resource.mirrors).to be_empty
|
||||
end
|
||||
|
||||
it "returns an array of mirrors added with #mirror" do
|
||||
subject.mirror("foo")
|
||||
subject.mirror("bar")
|
||||
expect(subject.mirrors).to eq(%w[foo bar])
|
||||
resource.mirror("foo")
|
||||
resource.mirror("bar")
|
||||
expect(resource.mirrors).to eq(%w[foo bar])
|
||||
end
|
||||
end
|
||||
|
||||
describe "#checksum" do
|
||||
it "returns nil if unset" do
|
||||
expect(subject.checksum).to be nil
|
||||
expect(resource.checksum).to be nil
|
||||
end
|
||||
|
||||
it "returns the checksum set with #sha256" do
|
||||
subject.sha256(TEST_SHA256)
|
||||
expect(subject.checksum).to eq(Checksum.new(TEST_SHA256))
|
||||
resource.sha256(TEST_SHA256)
|
||||
expect(resource.checksum).to eq(Checksum.new(TEST_SHA256))
|
||||
end
|
||||
end
|
||||
|
||||
@ -117,23 +117,23 @@ describe Resource do
|
||||
strategy = Object.new
|
||||
expect(DownloadStrategyDetector)
|
||||
.to receive(:detect).with("foo", nil).and_return(strategy)
|
||||
subject.url("foo")
|
||||
expect(subject.download_strategy).to eq(strategy)
|
||||
resource.url("foo")
|
||||
expect(resource.download_strategy).to eq(strategy)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#owner" do
|
||||
it "sets the owner" do
|
||||
owner = Object.new
|
||||
subject.owner = owner
|
||||
expect(subject.owner).to eq(owner)
|
||||
resource.owner = owner
|
||||
expect(resource.owner).to eq(owner)
|
||||
end
|
||||
|
||||
it "sets its owner to be the patches' owner" do
|
||||
subject.patch(:p1) { url "file:///my.patch" }
|
||||
resource.patch(:p1) { url "file:///my.patch" }
|
||||
owner = Object.new
|
||||
subject.owner = owner
|
||||
subject.patches.each do |p|
|
||||
resource.owner = owner
|
||||
resource.patches.each do |p|
|
||||
expect(p.resource.owner).to eq(owner)
|
||||
end
|
||||
end
|
||||
@ -141,9 +141,9 @@ describe Resource do
|
||||
|
||||
describe "#patch" do
|
||||
it "adds a patch" do
|
||||
subject.patch(:p1, :DATA)
|
||||
expect(subject.patches.count).to eq(1)
|
||||
expect(subject.patches.first.strip).to eq(:p1)
|
||||
resource.patch(:p1, :DATA)
|
||||
expect(resource.patches.count).to eq(1)
|
||||
expect(resource.patches.first.strip).to eq(:p1)
|
||||
end
|
||||
end
|
||||
|
||||
@ -154,18 +154,18 @@ describe Resource do
|
||||
expect(fn).to receive(:verify_checksum).and_raise(ChecksumMissingError)
|
||||
expect(fn).to receive(:sha256)
|
||||
|
||||
subject.verify_download_integrity(fn)
|
||||
resource.verify_download_integrity(fn)
|
||||
end
|
||||
|
||||
specify "#verify_download_integrity_mismatch" do
|
||||
fn = double(file?: true, basename: "foo")
|
||||
checksum = subject.sha256(TEST_SHA256)
|
||||
checksum = resource.sha256(TEST_SHA256)
|
||||
|
||||
expect(fn).to receive(:verify_checksum).with(checksum)
|
||||
.and_raise(ChecksumMismatchError.new(fn, checksum, Object.new))
|
||||
|
||||
expect {
|
||||
subject.verify_download_integrity(fn)
|
||||
resource.verify_download_integrity(fn)
|
||||
}.to raise_error(ChecksumMismatchError)
|
||||
end
|
||||
end
|
||||
|
||||
@ -6,6 +6,8 @@ require "sandbox"
|
||||
describe Sandbox, :needs_macos do
|
||||
define_negated_matcher :not_matching, :matching
|
||||
|
||||
subject(:sandbox) { described_class.new }
|
||||
|
||||
let(:dir) { mktmpdir }
|
||||
let(:file) { dir/"foo" }
|
||||
|
||||
@ -14,8 +16,8 @@ describe Sandbox, :needs_macos do
|
||||
end
|
||||
|
||||
specify "#allow_write" do
|
||||
subject.allow_write file
|
||||
subject.exec "touch", file
|
||||
sandbox.allow_write file
|
||||
sandbox.exec "touch", file
|
||||
|
||||
expect(file).to exist
|
||||
end
|
||||
@ -23,7 +25,7 @@ describe Sandbox, :needs_macos do
|
||||
describe "#exec" do
|
||||
it "fails when writing to file not specified with ##allow_write" do
|
||||
expect {
|
||||
subject.exec "touch", file
|
||||
sandbox.exec "touch", file
|
||||
}.to raise_error(ErrorDuringExecution)
|
||||
|
||||
expect(file).not_to exist
|
||||
@ -34,7 +36,7 @@ describe Sandbox, :needs_macos do
|
||||
|
||||
expect(Utils).to receive(:popen_read).and_return("foo")
|
||||
|
||||
expect { subject.exec "false" }
|
||||
expect { sandbox.exec "false" }
|
||||
.to raise_error(ErrorDuringExecution)
|
||||
.and output(/foo/).to_stdout
|
||||
end
|
||||
@ -49,7 +51,7 @@ describe Sandbox, :needs_macos do
|
||||
EOS
|
||||
expect(Utils).to receive(:popen_read).and_return(with_bogus_error)
|
||||
|
||||
expect { subject.exec "false" }
|
||||
expect { sandbox.exec "false" }
|
||||
.to raise_error(ErrorDuringExecution)
|
||||
.and output(a_string_matching(/foo/).and(matching(/bar/).and(not_matching(/Python/)))).to_stdout
|
||||
end
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
require "searchable"
|
||||
|
||||
describe Searchable do
|
||||
subject { collection.extend(described_class) }
|
||||
subject(:searchable_collection) { collection.extend(described_class) }
|
||||
|
||||
let(:collection) { ["with-dashes"] }
|
||||
|
||||
@ -13,20 +13,20 @@ describe Searchable do
|
||||
let(:collection) { [["with-dashes", "withdashes"]] }
|
||||
|
||||
it "searches by the selected argument" do
|
||||
expect(subject.search(/withdashes/) { |_, short_name| short_name }).not_to be_empty
|
||||
expect(subject.search(/withdashes/) { |long_name, _| long_name }).to be_empty
|
||||
expect(searchable_collection.search(/withdashes/) { |_, short_name| short_name }).not_to be_empty
|
||||
expect(searchable_collection.search(/withdashes/) { |long_name, _| long_name }).to be_empty
|
||||
end
|
||||
end
|
||||
|
||||
context "when given a regex" do
|
||||
it "does not simplify strings" do
|
||||
expect(subject.search(/with-dashes/)).to eq ["with-dashes"]
|
||||
expect(searchable_collection.search(/with-dashes/)).to eq ["with-dashes"]
|
||||
end
|
||||
end
|
||||
|
||||
context "when given a string" do
|
||||
it "simplifies both the query and searched strings" do
|
||||
expect(subject.search("with dashes")).to eq ["with-dashes"]
|
||||
expect(searchable_collection.search("with dashes")).to eq ["with-dashes"]
|
||||
end
|
||||
end
|
||||
|
||||
@ -34,14 +34,14 @@ describe Searchable do
|
||||
let(:collection) { { "foo" => "bar" } }
|
||||
|
||||
it "returns a Hash" do
|
||||
expect(subject.search("foo")).to eq "foo" => "bar"
|
||||
expect(searchable_collection.search("foo")).to eq "foo" => "bar"
|
||||
end
|
||||
|
||||
context "containing nil" do
|
||||
let(:collection) { { "foo" => nil } }
|
||||
|
||||
it "does not raise an error" do
|
||||
expect(subject.search("foo")).to eq "foo" => nil
|
||||
expect(searchable_collection.search("foo")).to eq "foo" => nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -7,182 +7,188 @@ describe SoftwareSpec do
|
||||
alias_matcher :have_defined_resource, :be_resource_defined
|
||||
alias_matcher :have_defined_option, :be_option_defined
|
||||
|
||||
subject(:spec) { described_class.new }
|
||||
|
||||
let(:owner) { double(name: "some_name", full_name: "some_name", tap: "homebrew/core") }
|
||||
|
||||
describe "#resource" do
|
||||
it "defines a resource" do
|
||||
subject.resource("foo") { url "foo-1.0" }
|
||||
expect(subject).to have_defined_resource("foo")
|
||||
spec.resource("foo") { url "foo-1.0" }
|
||||
expect(spec).to have_defined_resource("foo")
|
||||
end
|
||||
|
||||
it "sets itself to be the resource's owner" do
|
||||
subject.resource("foo") { url "foo-1.0" }
|
||||
subject.owner = owner
|
||||
subject.resources.each_value do |r|
|
||||
expect(r.owner).to eq(subject)
|
||||
spec.resource("foo") { url "foo-1.0" }
|
||||
spec.owner = owner
|
||||
spec.resources.each_value do |r|
|
||||
expect(r.owner).to eq(spec)
|
||||
end
|
||||
end
|
||||
|
||||
it "receives the owner's version if it has no own version" do
|
||||
subject.url("foo-42")
|
||||
subject.resource("bar") { url "bar" }
|
||||
subject.owner = owner
|
||||
spec.url("foo-42")
|
||||
spec.resource("bar") { url "bar" }
|
||||
spec.owner = owner
|
||||
|
||||
expect(subject.resource("bar").version).to eq("42")
|
||||
expect(spec.resource("bar").version).to eq("42")
|
||||
end
|
||||
|
||||
it "raises an error when duplicate resources are defined" do
|
||||
subject.resource("foo") { url "foo-1.0" }
|
||||
spec.resource("foo") { url "foo-1.0" }
|
||||
expect {
|
||||
subject.resource("foo") { url "foo-1.0" }
|
||||
spec.resource("foo") { url "foo-1.0" }
|
||||
}.to raise_error(DuplicateResourceError)
|
||||
end
|
||||
|
||||
it "raises an error when accessing missing resources" do
|
||||
subject.owner = owner
|
||||
spec.owner = owner
|
||||
expect {
|
||||
subject.resource("foo")
|
||||
spec.resource("foo")
|
||||
}.to raise_error(ResourceMissingError)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#owner" do
|
||||
it "sets the owner" do
|
||||
subject.owner = owner
|
||||
expect(subject.owner).to eq(owner)
|
||||
spec.owner = owner
|
||||
expect(spec.owner).to eq(owner)
|
||||
end
|
||||
|
||||
it "sets the name" do
|
||||
subject.owner = owner
|
||||
expect(subject.name).to eq(owner.name)
|
||||
spec.owner = owner
|
||||
expect(spec.name).to eq(owner.name)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#option" do
|
||||
it "defines an option" do
|
||||
subject.option("foo")
|
||||
expect(subject).to have_defined_option("foo")
|
||||
spec.option("foo")
|
||||
expect(spec).to have_defined_option("foo")
|
||||
end
|
||||
|
||||
it "raises an error when it begins with dashes" do
|
||||
expect {
|
||||
subject.option("--foo")
|
||||
spec.option("--foo")
|
||||
}.to raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "raises an error when name is empty" do
|
||||
expect {
|
||||
subject.option("")
|
||||
spec.option("")
|
||||
}.to raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "special cases the cxx11 option" do
|
||||
subject.option(:cxx11)
|
||||
expect(subject).to have_defined_option("c++11")
|
||||
expect(subject).not_to have_defined_option("cxx11")
|
||||
spec.option(:cxx11)
|
||||
expect(spec).to have_defined_option("c++11")
|
||||
expect(spec).not_to have_defined_option("cxx11")
|
||||
end
|
||||
|
||||
it "supports options with descriptions" do
|
||||
subject.option("bar", "description")
|
||||
expect(subject.options.first.description).to eq("description")
|
||||
spec.option("bar", "description")
|
||||
expect(spec.options.first.description).to eq("description")
|
||||
end
|
||||
|
||||
it "defaults to an empty string when no description is given" do
|
||||
subject.option("foo")
|
||||
expect(subject.options.first.description).to eq("")
|
||||
spec.option("foo")
|
||||
expect(spec.options.first.description).to eq("")
|
||||
end
|
||||
end
|
||||
|
||||
describe "#deprecated_option" do
|
||||
it "allows specifying deprecated options" do
|
||||
subject.deprecated_option("foo" => "bar")
|
||||
expect(subject.deprecated_options).not_to be_empty
|
||||
expect(subject.deprecated_options.first.old).to eq("foo")
|
||||
expect(subject.deprecated_options.first.current).to eq("bar")
|
||||
spec.deprecated_option("foo" => "bar")
|
||||
expect(spec.deprecated_options).not_to be_empty
|
||||
expect(spec.deprecated_options.first.old).to eq("foo")
|
||||
expect(spec.deprecated_options.first.current).to eq("bar")
|
||||
end
|
||||
|
||||
it "allows specifying deprecated options as a Hash from an Array/String to an Array/String" do
|
||||
subject.deprecated_option(["foo1", "foo2"] => "bar1", "foo3" => ["bar2", "bar3"])
|
||||
expect(subject.deprecated_options).to include(DeprecatedOption.new("foo1", "bar1"))
|
||||
expect(subject.deprecated_options).to include(DeprecatedOption.new("foo2", "bar1"))
|
||||
expect(subject.deprecated_options).to include(DeprecatedOption.new("foo3", "bar2"))
|
||||
expect(subject.deprecated_options).to include(DeprecatedOption.new("foo3", "bar3"))
|
||||
spec.deprecated_option(["foo1", "foo2"] => "bar1", "foo3" => ["bar2", "bar3"])
|
||||
expect(spec.deprecated_options).to include(DeprecatedOption.new("foo1", "bar1"))
|
||||
expect(spec.deprecated_options).to include(DeprecatedOption.new("foo2", "bar1"))
|
||||
expect(spec.deprecated_options).to include(DeprecatedOption.new("foo3", "bar2"))
|
||||
expect(spec.deprecated_options).to include(DeprecatedOption.new("foo3", "bar3"))
|
||||
end
|
||||
|
||||
it "raises an error when empty" do
|
||||
expect {
|
||||
subject.deprecated_option({})
|
||||
spec.deprecated_option({})
|
||||
}.to raise_error(ArgumentError)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#depends_on" do
|
||||
it "allows specifying dependencies" do
|
||||
subject.depends_on("foo")
|
||||
expect(subject.deps.first.name).to eq("foo")
|
||||
spec.depends_on("foo")
|
||||
expect(spec.deps.first.name).to eq("foo")
|
||||
end
|
||||
|
||||
it "allows specifying optional dependencies" do
|
||||
subject.depends_on "foo" => :optional
|
||||
expect(subject).to have_defined_option("with-foo")
|
||||
spec.depends_on "foo" => :optional
|
||||
expect(spec).to have_defined_option("with-foo")
|
||||
end
|
||||
|
||||
it "allows specifying recommended dependencies" do
|
||||
subject.depends_on "bar" => :recommended
|
||||
expect(subject).to have_defined_option("without-bar")
|
||||
spec.depends_on "bar" => :recommended
|
||||
expect(spec).to have_defined_option("without-bar")
|
||||
end
|
||||
end
|
||||
|
||||
describe "#uses_from_macos" do
|
||||
it "allows specifying dependencies", :needs_linux do
|
||||
subject.uses_from_macos("foo")
|
||||
spec.uses_from_macos("foo")
|
||||
|
||||
expect(subject.deps.first.name).to eq("foo")
|
||||
expect(spec.deps.first.name).to eq("foo")
|
||||
end
|
||||
|
||||
it "works with tags", :needs_linux do
|
||||
subject.uses_from_macos("foo" => :build)
|
||||
spec.uses_from_macos("foo" => :build)
|
||||
|
||||
expect(subject.deps.first.name).to eq("foo")
|
||||
expect(subject.deps.first.tags).to include(:build)
|
||||
expect(spec.deps.first.name).to eq("foo")
|
||||
expect(spec.deps.first.tags).to include(:build)
|
||||
end
|
||||
|
||||
it "ignores OS version specifications", :needs_linux do
|
||||
subject.uses_from_macos("foo", since: :mojave)
|
||||
subject.uses_from_macos("bar" => :build, :since => :mojave)
|
||||
spec.uses_from_macos("foo", since: :mojave)
|
||||
spec.uses_from_macos("bar" => :build, :since => :mojave)
|
||||
|
||||
expect(subject.deps.first.name).to eq("foo")
|
||||
expect(subject.deps.last.name).to eq("bar")
|
||||
expect(subject.deps.last.tags).to include(:build)
|
||||
expect(spec.deps.first.name).to eq("foo")
|
||||
expect(spec.deps.last.name).to eq("bar")
|
||||
expect(spec.deps.last.tags).to include(:build)
|
||||
end
|
||||
end
|
||||
|
||||
specify "explicit options override defaupt depends_on option description" do
|
||||
subject.option("with-foo", "blah")
|
||||
subject.depends_on("foo" => :optional)
|
||||
expect(subject.options.first.description).to eq("blah")
|
||||
spec.option("with-foo", "blah")
|
||||
spec.depends_on("foo" => :optional)
|
||||
expect(spec.options.first.description).to eq("blah")
|
||||
end
|
||||
|
||||
describe "#patch" do
|
||||
it "adds a patch" do
|
||||
subject.patch(:p1, :DATA)
|
||||
expect(subject.patches.count).to eq(1)
|
||||
expect(subject.patches.first.strip).to eq(:p1)
|
||||
spec.patch(:p1, :DATA)
|
||||
expect(spec.patches.count).to eq(1)
|
||||
expect(spec.patches.first.strip).to eq(:p1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe HeadSoftwareSpec do
|
||||
subject(:head_spec) { described_class.new }
|
||||
|
||||
specify "#version" do
|
||||
expect(subject.version).to eq(Version.create("HEAD"))
|
||||
expect(head_spec.version).to eq(Version.create("HEAD"))
|
||||
end
|
||||
|
||||
specify "#verify_download_integrity" do
|
||||
expect(subject.verify_download_integrity(Object.new)).to be nil
|
||||
expect(head_spec.verify_download_integrity(Object.new)).to be nil
|
||||
end
|
||||
end
|
||||
|
||||
describe BottleSpecification do
|
||||
subject(:bottle_spec) { described_class.new }
|
||||
|
||||
describe "#sha256" do
|
||||
it "works without cellar" do
|
||||
checksums = {
|
||||
@ -193,8 +199,8 @@ describe BottleSpecification do
|
||||
}
|
||||
|
||||
checksums.each_pair do |cat, digest|
|
||||
subject.sha256(digest => cat)
|
||||
checksum, = subject.checksum_for(cat)
|
||||
bottle_spec.sha256(digest => cat)
|
||||
checksum, = bottle_spec.checksum_for(cat)
|
||||
expect(Checksum.new(digest)).to eq(checksum)
|
||||
end
|
||||
end
|
||||
@ -208,8 +214,8 @@ describe BottleSpecification do
|
||||
]
|
||||
|
||||
checksums.each do |checksum|
|
||||
subject.sha256(checksum[:tag] => checksum[:digest], cellar: checksum[:cellar])
|
||||
digest, tag, cellar = subject.checksum_for(checksum[:tag])
|
||||
bottle_spec.sha256(checksum[:tag] => checksum[:digest], cellar: checksum[:cellar])
|
||||
digest, tag, cellar = bottle_spec.checksum_for(checksum[:tag])
|
||||
expect(Checksum.new(checksum[:digest])).to eq(digest)
|
||||
expect(checksum[:tag]).to eq(tag)
|
||||
checksum[:cellar] ||= Homebrew::DEFAULT_CELLAR
|
||||
@ -221,8 +227,8 @@ describe BottleSpecification do
|
||||
%w[root_url prefix cellar rebuild].each do |method|
|
||||
specify "##{method}" do
|
||||
object = Object.new
|
||||
subject.public_send(method, object)
|
||||
expect(subject.public_send(method)).to eq(object)
|
||||
bottle_spec.public_send(method, object)
|
||||
expect(bottle_spec.public_send(method)).to eq(object)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -45,7 +45,7 @@ describe SystemCommand::Result do
|
||||
end
|
||||
|
||||
describe "#plist" do
|
||||
subject { result.plist }
|
||||
subject(:result_plist) { result.plist }
|
||||
|
||||
let(:output_array) { [[:stdout, stdout]] }
|
||||
let(:garbage) {
|
||||
@ -116,7 +116,7 @@ describe SystemCommand::Result do
|
||||
}
|
||||
|
||||
it "ignores garbage" do
|
||||
expect(subject["system-entities"].length).to eq(3)
|
||||
expect(result_plist["system-entities"].length).to eq(3)
|
||||
end
|
||||
|
||||
context "when verbose" do
|
||||
@ -125,7 +125,7 @@ describe SystemCommand::Result do
|
||||
end
|
||||
|
||||
it "warns about garbage" do
|
||||
expect { subject }
|
||||
expect { result_plist }
|
||||
.to output(a_string_containing(garbage)).to_stderr
|
||||
end
|
||||
end
|
||||
@ -140,7 +140,7 @@ describe SystemCommand::Result do
|
||||
}
|
||||
|
||||
it "ignores garbage" do
|
||||
expect(subject["system-entities"].length).to eq(3)
|
||||
expect(result_plist["system-entities"].length).to eq(3)
|
||||
end
|
||||
|
||||
context "when verbose" do
|
||||
@ -149,7 +149,7 @@ describe SystemCommand::Result do
|
||||
end
|
||||
|
||||
it "warns about garbage" do
|
||||
expect { subject }
|
||||
expect { result_plist }
|
||||
.to output(a_string_containing(garbage)).to_stderr
|
||||
end
|
||||
end
|
||||
@ -159,9 +159,9 @@ describe SystemCommand::Result do
|
||||
let(:stdout) { plist }
|
||||
|
||||
it "successfully parses it" do
|
||||
expect(subject.keys).to eq(["system-entities"])
|
||||
expect(subject["system-entities"].length).to eq(3)
|
||||
expect(subject["system-entities"].map { |e| e["dev-entry"] })
|
||||
expect(result_plist.keys).to eq(["system-entities"])
|
||||
expect(result_plist["system-entities"].length).to eq(3)
|
||||
expect(result_plist["system-entities"].map { |e| e["dev-entry"] })
|
||||
.to eq(["/dev/disk3s1", "/dev/disk3", "/dev/disk3s2"])
|
||||
end
|
||||
end
|
||||
@ -170,7 +170,7 @@ describe SystemCommand::Result do
|
||||
let(:stdout) { "" }
|
||||
|
||||
it "returns nil" do
|
||||
expect(subject).to be nil
|
||||
expect(result_plist).to be nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -19,7 +19,7 @@ describe Tab do
|
||||
end
|
||||
end
|
||||
|
||||
subject {
|
||||
subject(:tab) {
|
||||
described_class.new(
|
||||
"homebrew_version" => HOMEBREW_VERSION,
|
||||
"used_options" => used_options.as_flags,
|
||||
@ -79,15 +79,15 @@ describe Tab do
|
||||
end
|
||||
|
||||
specify "#include?" do
|
||||
expect(subject).to include("with-foo")
|
||||
expect(subject).to include("without-bar")
|
||||
expect(tab).to include("with-foo")
|
||||
expect(tab).to include("without-bar")
|
||||
end
|
||||
|
||||
specify "#with?" do
|
||||
expect(subject).to be_built_with("foo")
|
||||
expect(subject).to be_built_with("qux")
|
||||
expect(subject).not_to be_built_with("bar")
|
||||
expect(subject).not_to be_built_with("baz")
|
||||
expect(tab).to be_built_with("foo")
|
||||
expect(tab).to be_built_with("qux")
|
||||
expect(tab).not_to be_built_with("bar")
|
||||
expect(tab).not_to be_built_with("baz")
|
||||
end
|
||||
|
||||
specify "#parsed_homebrew_version" do
|
||||
@ -146,16 +146,16 @@ describe Tab do
|
||||
end
|
||||
|
||||
specify "#cxxstdlib" do
|
||||
expect(subject.cxxstdlib.compiler).to eq(:clang)
|
||||
expect(subject.cxxstdlib.type).to eq(:libcxx)
|
||||
expect(tab.cxxstdlib.compiler).to eq(:clang)
|
||||
expect(tab.cxxstdlib.type).to eq(:libcxx)
|
||||
end
|
||||
|
||||
specify "other attributes" do
|
||||
expect(subject.HEAD).to eq(TEST_SHA1)
|
||||
expect(subject.tap.name).to eq("homebrew/core")
|
||||
expect(subject.time).to eq(time)
|
||||
expect(subject).not_to be_built_as_bottle
|
||||
expect(subject).to be_poured_from_bottle
|
||||
expect(tab.HEAD).to eq(TEST_SHA1)
|
||||
expect(tab.tap.name).to eq("homebrew/core")
|
||||
expect(tab.time).to eq(time)
|
||||
expect(tab).not_to be_built_as_bottle
|
||||
expect(tab).to be_poured_from_bottle
|
||||
end
|
||||
|
||||
describe "::from_file" do
|
||||
@ -286,19 +286,19 @@ describe Tab do
|
||||
end
|
||||
|
||||
describe "::for_keg" do
|
||||
subject { described_class.for_keg(f.prefix) }
|
||||
subject(:tab_for_keg) { described_class.for_keg(f.prefix) }
|
||||
|
||||
it "creates a Tab for a given Keg" do
|
||||
f.prefix.mkpath
|
||||
f_tab_path.write f_tab_content
|
||||
|
||||
expect(subject.tabfile).to eq(f_tab_path)
|
||||
expect(tab_for_keg.tabfile).to eq(f_tab_path)
|
||||
end
|
||||
|
||||
it "can create a Tab for a non-existent Keg" do
|
||||
f.prefix.mkpath
|
||||
|
||||
expect(subject.tabfile).to eq(f_tab_path)
|
||||
expect(tab_for_keg.tabfile).to eq(f_tab_path)
|
||||
end
|
||||
end
|
||||
|
||||
@ -359,27 +359,27 @@ describe Tab do
|
||||
end
|
||||
|
||||
specify "#to_json" do
|
||||
tab = described_class.new(JSON.parse(subject.to_json))
|
||||
expect(tab.used_options.sort).to eq(subject.used_options.sort)
|
||||
expect(tab.unused_options.sort).to eq(subject.unused_options.sort)
|
||||
expect(tab.built_as_bottle).to eq(subject.built_as_bottle)
|
||||
expect(tab.poured_from_bottle).to eq(subject.poured_from_bottle)
|
||||
expect(tab.changed_files).to eq(subject.changed_files)
|
||||
expect(tab.tap).to eq(subject.tap)
|
||||
expect(tab.spec).to eq(subject.spec)
|
||||
expect(tab.time).to eq(subject.time)
|
||||
expect(tab.HEAD).to eq(subject.HEAD)
|
||||
expect(tab.compiler).to eq(subject.compiler)
|
||||
expect(tab.stdlib).to eq(subject.stdlib)
|
||||
expect(tab.runtime_dependencies).to eq(subject.runtime_dependencies)
|
||||
expect(tab.stable_version).to eq(subject.stable_version)
|
||||
expect(tab.head_version).to eq(subject.head_version)
|
||||
expect(tab.source["path"]).to eq(subject.source["path"])
|
||||
json_tab = described_class.new(JSON.parse(tab.to_json))
|
||||
expect(json_tab.used_options.sort).to eq(tab.used_options.sort)
|
||||
expect(json_tab.unused_options.sort).to eq(tab.unused_options.sort)
|
||||
expect(json_tab.built_as_bottle).to eq(tab.built_as_bottle)
|
||||
expect(json_tab.poured_from_bottle).to eq(tab.poured_from_bottle)
|
||||
expect(json_tab.changed_files).to eq(tab.changed_files)
|
||||
expect(json_tab.tap).to eq(tab.tap)
|
||||
expect(json_tab.spec).to eq(tab.spec)
|
||||
expect(json_tab.time).to eq(tab.time)
|
||||
expect(json_tab.HEAD).to eq(tab.HEAD)
|
||||
expect(json_tab.compiler).to eq(tab.compiler)
|
||||
expect(json_tab.stdlib).to eq(tab.stdlib)
|
||||
expect(json_tab.runtime_dependencies).to eq(tab.runtime_dependencies)
|
||||
expect(json_tab.stable_version).to eq(tab.stable_version)
|
||||
expect(json_tab.head_version).to eq(tab.head_version)
|
||||
expect(json_tab.source["path"]).to eq(tab.source["path"])
|
||||
end
|
||||
|
||||
specify "::remap_deprecated_options" do
|
||||
deprecated_options = [DeprecatedOption.new("with-foo", "with-foo-new")]
|
||||
remapped_options = described_class.remap_deprecated_options(deprecated_options, subject.used_options)
|
||||
remapped_options = described_class.remap_deprecated_options(deprecated_options, tab.used_options)
|
||||
expect(remapped_options).to include(Option.new("without-bar"))
|
||||
expect(remapped_options).to include(Option.new("with-foo-new"))
|
||||
end
|
||||
|
||||
@ -5,7 +5,7 @@ describe Tap do
|
||||
alias_matcher :have_formula_file, :be_formula_file
|
||||
alias_matcher :have_custom_remote, :be_custom_remote
|
||||
|
||||
subject { described_class.new("Homebrew", "foo") }
|
||||
subject(:homebrew_foo_tap) { described_class.new("Homebrew", "foo") }
|
||||
|
||||
let(:path) { Tap::TAP_DIRECTORY/"homebrew/homebrew-foo" }
|
||||
let(:formula_file) { path/"Formula/foo.rb" }
|
||||
@ -131,13 +131,13 @@ describe Tap do
|
||||
end
|
||||
|
||||
specify "attributes" do
|
||||
expect(subject.user).to eq("Homebrew")
|
||||
expect(subject.repo).to eq("foo")
|
||||
expect(subject.name).to eq("homebrew/foo")
|
||||
expect(subject.path).to eq(path)
|
||||
expect(subject).to be_installed
|
||||
expect(subject).to be_official
|
||||
expect(subject).not_to be_a_core_tap
|
||||
expect(homebrew_foo_tap.user).to eq("Homebrew")
|
||||
expect(homebrew_foo_tap.repo).to eq("foo")
|
||||
expect(homebrew_foo_tap.name).to eq("homebrew/foo")
|
||||
expect(homebrew_foo_tap.path).to eq(path)
|
||||
expect(homebrew_foo_tap).to be_installed
|
||||
expect(homebrew_foo_tap).to be_official
|
||||
expect(homebrew_foo_tap).not_to be_a_core_tap
|
||||
end
|
||||
|
||||
specify "#issues_url" do
|
||||
@ -150,7 +150,7 @@ describe Tap do
|
||||
"https://github.com/someone/homebrew-foo"
|
||||
end
|
||||
expect(t.issues_url).to eq("https://github.com/someone/homebrew-foo/issues")
|
||||
expect(subject.issues_url).to eq("https://github.com/Homebrew/homebrew-foo/issues")
|
||||
expect(homebrew_foo_tap.issues_url).to eq("https://github.com/Homebrew/homebrew-foo/issues")
|
||||
|
||||
(Tap::TAP_DIRECTORY/"someone/homebrew-no-git").mkpath
|
||||
expect(described_class.new("someone", "no-git").issues_url).to be nil
|
||||
@ -161,29 +161,29 @@ describe Tap do
|
||||
specify "files" do
|
||||
setup_tap_files
|
||||
|
||||
expect(subject.formula_files).to eq([formula_file])
|
||||
expect(subject.formula_names).to eq(["homebrew/foo/foo"])
|
||||
expect(subject.alias_files).to eq([alias_file])
|
||||
expect(subject.aliases).to eq(["homebrew/foo/bar"])
|
||||
expect(subject.alias_table).to eq("homebrew/foo/bar" => "homebrew/foo/foo")
|
||||
expect(subject.alias_reverse_table).to eq("homebrew/foo/foo" => ["homebrew/foo/bar"])
|
||||
expect(subject.formula_renames).to eq("oldname" => "foo")
|
||||
expect(subject.tap_migrations).to eq("removed-formula" => "homebrew/foo")
|
||||
expect(subject.command_files).to eq([cmd_file])
|
||||
expect(subject.to_hash).to be_kind_of(Hash)
|
||||
expect(subject).to have_formula_file(formula_file)
|
||||
expect(subject).to have_formula_file("Formula/foo.rb")
|
||||
expect(subject).not_to have_formula_file("bar.rb")
|
||||
expect(subject).not_to have_formula_file("Formula/baz.sh")
|
||||
expect(homebrew_foo_tap.formula_files).to eq([formula_file])
|
||||
expect(homebrew_foo_tap.formula_names).to eq(["homebrew/foo/foo"])
|
||||
expect(homebrew_foo_tap.alias_files).to eq([alias_file])
|
||||
expect(homebrew_foo_tap.aliases).to eq(["homebrew/foo/bar"])
|
||||
expect(homebrew_foo_tap.alias_table).to eq("homebrew/foo/bar" => "homebrew/foo/foo")
|
||||
expect(homebrew_foo_tap.alias_reverse_table).to eq("homebrew/foo/foo" => ["homebrew/foo/bar"])
|
||||
expect(homebrew_foo_tap.formula_renames).to eq("oldname" => "foo")
|
||||
expect(homebrew_foo_tap.tap_migrations).to eq("removed-formula" => "homebrew/foo")
|
||||
expect(homebrew_foo_tap.command_files).to eq([cmd_file])
|
||||
expect(homebrew_foo_tap.to_hash).to be_kind_of(Hash)
|
||||
expect(homebrew_foo_tap).to have_formula_file(formula_file)
|
||||
expect(homebrew_foo_tap).to have_formula_file("Formula/foo.rb")
|
||||
expect(homebrew_foo_tap).not_to have_formula_file("bar.rb")
|
||||
expect(homebrew_foo_tap).not_to have_formula_file("Formula/baz.sh")
|
||||
end
|
||||
|
||||
describe "#remote" do
|
||||
it "returns the remote URL" do
|
||||
setup_git_repo
|
||||
|
||||
expect(subject.remote).to eq("https://github.com/Homebrew/homebrew-foo")
|
||||
expect(homebrew_foo_tap.remote).to eq("https://github.com/Homebrew/homebrew-foo")
|
||||
expect { described_class.new("Homebrew", "bar").remote }.to raise_error(TapUnavailableError)
|
||||
expect(subject).not_to have_custom_remote
|
||||
expect(homebrew_foo_tap).not_to have_custom_remote
|
||||
|
||||
services_tap = described_class.new("Homebrew", "services")
|
||||
services_tap.path.mkpath
|
||||
@ -195,13 +195,13 @@ describe Tap do
|
||||
end
|
||||
|
||||
it "returns nil if the Tap is not a Git repository" do
|
||||
expect(subject.remote).to be nil
|
||||
expect(homebrew_foo_tap.remote).to be nil
|
||||
end
|
||||
|
||||
it "returns nil if Git is not available" do
|
||||
setup_git_repo
|
||||
allow(Utils::Git).to receive(:available?).and_return(false)
|
||||
expect(subject.remote).to be nil
|
||||
expect(homebrew_foo_tap.remote).to be nil
|
||||
end
|
||||
end
|
||||
|
||||
@ -209,15 +209,15 @@ describe Tap do
|
||||
touch path/"README"
|
||||
setup_git_repo
|
||||
|
||||
expect(subject.git_head).to eq("0453e16c8e3fac73104da50927a86221ca0740c2")
|
||||
expect(subject.git_short_head).to eq("0453")
|
||||
expect(subject.git_last_commit).to match(/\A\d+ .+ ago\Z/)
|
||||
expect(subject.git_last_commit_date).to eq("2017-01-22")
|
||||
expect(homebrew_foo_tap.git_head).to eq("0453e16c8e3fac73104da50927a86221ca0740c2")
|
||||
expect(homebrew_foo_tap.git_short_head).to eq("0453")
|
||||
expect(homebrew_foo_tap.git_last_commit).to match(/\A\d+ .+ ago\Z/)
|
||||
expect(homebrew_foo_tap.git_last_commit_date).to eq("2017-01-22")
|
||||
end
|
||||
|
||||
specify "#private?" do
|
||||
skip "HOMEBREW_GITHUB_API_TOKEN is required" unless GitHub.api_credentials
|
||||
expect(subject).to be_private
|
||||
expect(homebrew_foo_tap).to be_private
|
||||
end
|
||||
|
||||
describe "#install" do
|
||||
@ -232,7 +232,7 @@ describe Tap do
|
||||
setup_git_repo
|
||||
already_tapped_tap = described_class.new("Homebrew", "foo")
|
||||
expect(already_tapped_tap).to be_installed
|
||||
right_remote = subject.remote
|
||||
right_remote = homebrew_foo_tap.remote
|
||||
expect { already_tapped_tap.install clone_target: right_remote }.to raise_error(TapAlreadyTappedError)
|
||||
end
|
||||
|
||||
@ -240,7 +240,7 @@ describe Tap do
|
||||
setup_git_repo
|
||||
already_tapped_tap = described_class.new("Homebrew", "foo")
|
||||
expect(already_tapped_tap).to be_installed
|
||||
wrong_remote = "#{subject.remote}-oops"
|
||||
wrong_remote = "#{homebrew_foo_tap.remote}-oops"
|
||||
expect {
|
||||
already_tapped_tap.install clone_target: wrong_remote
|
||||
}.to raise_error(TapRemoteMismatchError)
|
||||
@ -297,7 +297,7 @@ describe Tap do
|
||||
|
||||
tap = described_class.new("Homebrew", "bar")
|
||||
|
||||
tap.install clone_target: subject.path/".git"
|
||||
tap.install clone_target: homebrew_foo_tap.path/".git"
|
||||
|
||||
expect(tap).to be_installed
|
||||
expect(HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1").to be_a_file
|
||||
@ -322,7 +322,7 @@ describe Tap do
|
||||
setup_git_repo
|
||||
setup_completion link: true
|
||||
tap = described_class.new("NotHomebrew", "baz")
|
||||
tap.install clone_target: subject.path/".git"
|
||||
tap.install clone_target: homebrew_foo_tap.path/".git"
|
||||
(HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1").delete
|
||||
(HOMEBREW_PREFIX/"etc/bash_completion.d/brew-tap-cmd").delete
|
||||
(HOMEBREW_PREFIX/"share/zsh/site-functions/_brew-tap-cmd").delete
|
||||
@ -343,7 +343,7 @@ describe Tap do
|
||||
setup_git_repo
|
||||
setup_completion link: false
|
||||
tap = described_class.new("NotHomebrew", "baz")
|
||||
tap.install clone_target: subject.path/".git"
|
||||
tap.install clone_target: homebrew_foo_tap.path/".git"
|
||||
(HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1").delete
|
||||
tap.link_completions_and_manpages
|
||||
expect(HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1").to be_a_file
|
||||
@ -361,7 +361,7 @@ describe Tap do
|
||||
setup_git_repo
|
||||
setup_completion link: false
|
||||
tap = described_class.new("Homebrew", "baz")
|
||||
tap.install clone_target: subject.path/".git"
|
||||
tap.install clone_target: homebrew_foo_tap.path/".git"
|
||||
(HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1").delete
|
||||
(HOMEBREW_PREFIX/"etc/bash_completion.d/brew-tap-cmd").delete
|
||||
(HOMEBREW_PREFIX/"share/zsh/site-functions/_brew-tap-cmd").delete
|
||||
@ -380,11 +380,11 @@ describe Tap do
|
||||
specify "#config" do
|
||||
setup_git_repo
|
||||
|
||||
expect(subject.config["foo"]).to be nil
|
||||
subject.config["foo"] = "bar"
|
||||
expect(subject.config["foo"]).to eq("bar")
|
||||
subject.config["foo"] = nil
|
||||
expect(subject.config["foo"]).to be nil
|
||||
expect(homebrew_foo_tap.config["foo"]).to be nil
|
||||
homebrew_foo_tap.config["foo"] = "bar"
|
||||
expect(homebrew_foo_tap.config["foo"]).to eq("bar")
|
||||
homebrew_foo_tap.config["foo"] = nil
|
||||
expect(homebrew_foo_tap.config["foo"]).to be nil
|
||||
end
|
||||
|
||||
describe "#each" do
|
||||
@ -399,7 +399,7 @@ describe Tap do
|
||||
setup_tap_files
|
||||
|
||||
expected_result = { "oldname" => "foo" }
|
||||
expect(subject.formula_renames).to eq expected_result
|
||||
expect(homebrew_foo_tap.formula_renames).to eq expected_result
|
||||
end
|
||||
end
|
||||
|
||||
@ -408,7 +408,7 @@ describe Tap do
|
||||
setup_tap_files
|
||||
|
||||
expected_result = { "removed-formula" => "homebrew/foo" }
|
||||
expect(subject.tap_migrations).to eq expected_result
|
||||
expect(homebrew_foo_tap.tap_migrations).to eq expected_result
|
||||
end
|
||||
end
|
||||
|
||||
@ -420,7 +420,7 @@ describe Tap do
|
||||
formula_list: ["foo", "bar"],
|
||||
formula_hash: { "foo" => "foo1", "bar" => "bar1" },
|
||||
}
|
||||
expect(subject.audit_exceptions).to eq expected_result
|
||||
expect(homebrew_foo_tap.audit_exceptions).to eq expected_result
|
||||
end
|
||||
end
|
||||
|
||||
@ -432,7 +432,7 @@ describe Tap do
|
||||
formula_list: ["foo", "bar"],
|
||||
formula_hash: { "foo" => "foo1", "bar" => "bar1" },
|
||||
}
|
||||
expect(subject.style_exceptions).to eq expected_result
|
||||
expect(homebrew_foo_tap.style_exceptions).to eq expected_result
|
||||
end
|
||||
end
|
||||
|
||||
@ -448,33 +448,35 @@ describe Tap do
|
||||
"exclude_packages" => ["baz"],
|
||||
},
|
||||
}
|
||||
expect(subject.pypi_formula_mappings).to eq expected_result
|
||||
expect(homebrew_foo_tap.pypi_formula_mappings).to eq expected_result
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe CoreTap do
|
||||
subject(:core_tap) { described_class.new }
|
||||
|
||||
specify "attributes" do
|
||||
expect(subject.user).to eq("Homebrew")
|
||||
expect(subject.repo).to eq("core")
|
||||
expect(subject.name).to eq("homebrew/core")
|
||||
expect(subject.command_files).to eq([])
|
||||
expect(subject).to be_installed
|
||||
expect(subject).not_to be_pinned
|
||||
expect(subject).to be_official
|
||||
expect(subject).to be_a_core_tap
|
||||
expect(core_tap.user).to eq("Homebrew")
|
||||
expect(core_tap.repo).to eq("core")
|
||||
expect(core_tap.name).to eq("homebrew/core")
|
||||
expect(core_tap.command_files).to eq([])
|
||||
expect(core_tap).to be_installed
|
||||
expect(core_tap).not_to be_pinned
|
||||
expect(core_tap).to be_official
|
||||
expect(core_tap).to be_a_core_tap
|
||||
end
|
||||
|
||||
specify "forbidden operations" do
|
||||
expect { subject.uninstall }.to raise_error(RuntimeError)
|
||||
expect { subject.pin }.to raise_error(RuntimeError)
|
||||
expect { subject.unpin }.to raise_error(RuntimeError)
|
||||
expect { core_tap.uninstall }.to raise_error(RuntimeError)
|
||||
expect { core_tap.pin }.to raise_error(RuntimeError)
|
||||
expect { core_tap.unpin }.to raise_error(RuntimeError)
|
||||
end
|
||||
|
||||
specify "files" do
|
||||
path = Tap::TAP_DIRECTORY/"homebrew/homebrew-core"
|
||||
formula_file = subject.formula_dir/"foo.rb"
|
||||
formula_file = core_tap.formula_dir/"foo.rb"
|
||||
formula_file.write <<~RUBY
|
||||
class Foo < Formula
|
||||
url "https://brew.sh/foo-1.0.tar.gz"
|
||||
@ -493,21 +495,21 @@ describe CoreTap do
|
||||
(path/file).write formula_list_file_json
|
||||
end
|
||||
|
||||
alias_file = subject.alias_dir/"bar"
|
||||
alias_file = core_tap.alias_dir/"bar"
|
||||
alias_file.parent.mkpath
|
||||
ln_s formula_file, alias_file
|
||||
|
||||
expect(subject.formula_files).to eq([formula_file])
|
||||
expect(subject.formula_names).to eq(["foo"])
|
||||
expect(subject.alias_files).to eq([alias_file])
|
||||
expect(subject.aliases).to eq(["bar"])
|
||||
expect(subject.alias_table).to eq("bar" => "foo")
|
||||
expect(subject.alias_reverse_table).to eq("foo" => ["bar"])
|
||||
expect(core_tap.formula_files).to eq([formula_file])
|
||||
expect(core_tap.formula_names).to eq(["foo"])
|
||||
expect(core_tap.alias_files).to eq([alias_file])
|
||||
expect(core_tap.aliases).to eq(["bar"])
|
||||
expect(core_tap.alias_table).to eq("bar" => "foo")
|
||||
expect(core_tap.alias_reverse_table).to eq("foo" => ["bar"])
|
||||
|
||||
expect(subject.formula_renames).to eq formula_list_file_contents
|
||||
expect(subject.tap_migrations).to eq formula_list_file_contents
|
||||
expect(subject.audit_exceptions).to eq({ formula_list: formula_list_file_contents })
|
||||
expect(subject.style_exceptions).to eq({ formula_hash: formula_list_file_contents })
|
||||
expect(subject.pypi_formula_mappings).to eq formula_list_file_contents
|
||||
expect(core_tap.formula_renames).to eq formula_list_file_contents
|
||||
expect(core_tap.tap_migrations).to eq formula_list_file_contents
|
||||
expect(core_tap.audit_exceptions).to eq({ formula_list: formula_list_file_contents })
|
||||
expect(core_tap.style_exceptions).to eq({ formula_hash: formula_list_file_contents })
|
||||
expect(core_tap.pypi_formula_mappings).to eq formula_list_file_contents
|
||||
end
|
||||
end
|
||||
|
||||
@ -28,14 +28,14 @@ describe "globally-scoped helper methods" do
|
||||
end
|
||||
|
||||
describe "#pretty_installed" do
|
||||
subject { pretty_installed("foo") }
|
||||
subject(:pretty_installed_output) { pretty_installed("foo") }
|
||||
|
||||
context "when $stdout is a TTY" do
|
||||
before { allow($stdout).to receive(:tty?).and_return(true) }
|
||||
|
||||
context "with HOMEBREW_NO_EMOJI unset" do
|
||||
it "returns a string with a colored checkmark" do
|
||||
expect(subject)
|
||||
expect(pretty_installed_output)
|
||||
.to match(/#{esc 1}foo #{esc 32}✔#{esc 0}/)
|
||||
end
|
||||
end
|
||||
@ -44,7 +44,7 @@ describe "globally-scoped helper methods" do
|
||||
before { ENV["HOMEBREW_NO_EMOJI"] = "1" }
|
||||
|
||||
it "returns a string with colored info" do
|
||||
expect(subject)
|
||||
expect(pretty_installed_output)
|
||||
.to match(/#{esc 1}foo \(installed\)#{esc 0}/)
|
||||
end
|
||||
end
|
||||
@ -54,20 +54,20 @@ describe "globally-scoped helper methods" do
|
||||
before { allow($stdout).to receive(:tty?).and_return(false) }
|
||||
|
||||
it "returns plain text" do
|
||||
expect(subject).to eq("foo")
|
||||
expect(pretty_installed_output).to eq("foo")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#pretty_uninstalled" do
|
||||
subject { pretty_uninstalled("foo") }
|
||||
subject(:pretty_uninstalled_output) { pretty_uninstalled("foo") }
|
||||
|
||||
context "when $stdout is a TTY" do
|
||||
before { allow($stdout).to receive(:tty?).and_return(true) }
|
||||
|
||||
context "with HOMEBREW_NO_EMOJI unset" do
|
||||
it "returns a string with a colored checkmark" do
|
||||
expect(subject)
|
||||
expect(pretty_uninstalled_output)
|
||||
.to match(/#{esc 1}foo #{esc 31}✘#{esc 0}/)
|
||||
end
|
||||
end
|
||||
@ -76,7 +76,7 @@ describe "globally-scoped helper methods" do
|
||||
before { ENV["HOMEBREW_NO_EMOJI"] = "1" }
|
||||
|
||||
it "returns a string with colored info" do
|
||||
expect(subject)
|
||||
expect(pretty_uninstalled_output)
|
||||
.to match(/#{esc 1}foo \(uninstalled\)#{esc 0}/)
|
||||
end
|
||||
end
|
||||
@ -86,7 +86,7 @@ describe "globally-scoped helper methods" do
|
||||
before { allow($stdout).to receive(:tty?).and_return(false) }
|
||||
|
||||
it "returns plain text" do
|
||||
expect(subject).to eq("foo")
|
||||
expect(pretty_uninstalled_output).to eq("foo")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -72,14 +72,14 @@ end
|
||||
|
||||
describe Version do
|
||||
describe "::NULL_TOKEN" do
|
||||
subject { described_class::NULL_TOKEN }
|
||||
subject(:null_version) { described_class::NULL_TOKEN }
|
||||
|
||||
specify "#inspect" do
|
||||
expect(subject.inspect).to eq("#<Version::NullToken>")
|
||||
expect(null_version.inspect).to eq("#<Version::NullToken>")
|
||||
end
|
||||
|
||||
it "is equal to itself" do
|
||||
expect(subject).to be == described_class::NULL_TOKEN
|
||||
expect(null_version).to be == described_class::NULL_TOKEN
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user