Autofix RuboCop RSpec failures
This commit is contained in:
parent
da404fcb4e
commit
78eba5b815
@ -18,6 +18,7 @@ describe Bottle::Filename do
|
||||
|
||||
context "when rebuild is 1" do
|
||||
let(:rebuild) { 1 }
|
||||
|
||||
its(:extname) { is_expected.to eq ".tag.bottle.1.tar.gz" }
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,23 +1,23 @@
|
||||
require "cache_store"
|
||||
|
||||
describe CacheStoreDatabase do
|
||||
subject { CacheStoreDatabase.new(:sample) }
|
||||
subject { described_class.new(:sample) }
|
||||
|
||||
describe "self.use" do
|
||||
let(:type) { :test }
|
||||
|
||||
it "creates a new `DatabaseCache` instance" do
|
||||
cache_store = double("cache_store", close_if_open!: nil)
|
||||
expect(CacheStoreDatabase).to receive(:new).with(type).and_return(cache_store)
|
||||
expect(described_class).to receive(:new).with(type).and_return(cache_store)
|
||||
expect(cache_store).to receive(:close_if_open!)
|
||||
CacheStoreDatabase.use(type) { |_db| }
|
||||
described_class.use(type) { |_db| }
|
||||
end
|
||||
end
|
||||
|
||||
describe "#set" do
|
||||
let(:db) { double("db", :[]= => nil) }
|
||||
|
||||
before(:each) do
|
||||
before do
|
||||
allow(File).to receive(:write)
|
||||
allow(subject).to receive(:created?).and_return(true)
|
||||
expect(db).to receive(:has_key?).with(:foo).and_return(false)
|
||||
@ -25,7 +25,7 @@ describe CacheStoreDatabase do
|
||||
end
|
||||
|
||||
it "sets the value in the `CacheStoreDatabase`" do
|
||||
expect(db).to_not have_key(:foo)
|
||||
expect(db).not_to have_key(:foo)
|
||||
subject.set(:foo, "bar")
|
||||
end
|
||||
end
|
||||
@ -34,7 +34,7 @@ describe CacheStoreDatabase do
|
||||
context "database created" do
|
||||
let(:db) { double("db", :[] => "bar") }
|
||||
|
||||
before(:each) do
|
||||
before do
|
||||
allow(subject).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)
|
||||
@ -49,13 +49,13 @@ describe CacheStoreDatabase do
|
||||
context "database not created" do
|
||||
let(:db) { double("db", :[] => nil) }
|
||||
|
||||
before(:each) do
|
||||
before do
|
||||
allow(subject).to receive(:created?).and_return(false)
|
||||
allow(subject).to receive(:db).and_return(db)
|
||||
end
|
||||
|
||||
it "does not get value in the `CacheStoreDatabase` corresponding to key" do
|
||||
expect(subject.get(:foo)).to_not be("bar")
|
||||
expect(subject.get(:foo)).not_to be("bar")
|
||||
end
|
||||
|
||||
it "does not call `db[]` if `CacheStoreDatabase.created?` is `false`" do
|
||||
@ -69,7 +69,7 @@ describe CacheStoreDatabase do
|
||||
context "database created" do
|
||||
let(:db) { double("db", :[] => { foo: "bar" }) }
|
||||
|
||||
before(:each) do
|
||||
before do
|
||||
allow(subject).to receive(:created?).and_return(true)
|
||||
allow(subject).to receive(:db).and_return(db)
|
||||
end
|
||||
@ -83,7 +83,7 @@ describe CacheStoreDatabase do
|
||||
context "database not created" do
|
||||
let(:db) { double("db", delete: nil) }
|
||||
|
||||
before(:each) do
|
||||
before do
|
||||
allow(subject).to receive(:created?).and_return(false)
|
||||
allow(subject).to receive(:db).and_return(db)
|
||||
end
|
||||
@ -97,22 +97,22 @@ describe CacheStoreDatabase do
|
||||
|
||||
describe "#close_if_open!" do
|
||||
context "database open" do
|
||||
before(:each) do
|
||||
before do
|
||||
subject.instance_variable_set(:@db, instance_double(DBM, close: nil))
|
||||
end
|
||||
|
||||
it "does not raise an error when `close` is called on the database" do
|
||||
expect { subject.close_if_open! }.to_not raise_error(NoMethodError)
|
||||
expect { subject.close_if_open! }.not_to raise_error(NoMethodError)
|
||||
end
|
||||
end
|
||||
|
||||
context "database not open" do
|
||||
before(:each) do
|
||||
before do
|
||||
subject.instance_variable_set(:@db, nil)
|
||||
end
|
||||
|
||||
it "does not raise an error when `close` is called on the database" do
|
||||
expect { subject.close_if_open! }.to_not raise_error(NoMethodError)
|
||||
expect { subject.close_if_open! }.not_to raise_error(NoMethodError)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -120,13 +120,13 @@ describe CacheStoreDatabase do
|
||||
describe "#created?" do
|
||||
let(:cache_path) { Pathname("path/to/homebrew/cache/sample.db") }
|
||||
|
||||
before(:each) do
|
||||
before do
|
||||
allow(subject).to receive(:cache_path).and_return(cache_path)
|
||||
end
|
||||
|
||||
context "`cache_path.exist?` returns `true`" do
|
||||
before(:each) do
|
||||
allow(cache_path).to receive(:exist?).and_return(true)
|
||||
context "`File.exist?(cache_path)` returns `true`" do
|
||||
before do
|
||||
allow(File).to receive(:exist?).with(cache_path).and_return(true)
|
||||
end
|
||||
|
||||
it "returns `true`" do
|
||||
@ -134,9 +134,9 @@ describe CacheStoreDatabase do
|
||||
end
|
||||
end
|
||||
|
||||
context "`cache_path.exist?` returns `false`" do
|
||||
before(:each) do
|
||||
allow(cache_path).to receive(:exist?).and_return(false)
|
||||
context "`File.exist?(cache_path)` returns `false`" do
|
||||
before do
|
||||
allow(File).to receive(:exist?).with(cache_path).and_return(false)
|
||||
end
|
||||
|
||||
it "returns `false`" do
|
||||
|
||||
@ -112,6 +112,10 @@ describe Cask::Artifact::App, :cask do
|
||||
FileUtils.chmod 0555, target_path
|
||||
end
|
||||
|
||||
after do
|
||||
FileUtils.chmod 0755, target_path
|
||||
end
|
||||
|
||||
it "overwrites the existing app" do
|
||||
expect(command).to receive(:run).with(
|
||||
"/bin/chmod", args: [
|
||||
@ -148,10 +152,6 @@ describe Cask::Artifact::App, :cask do
|
||||
contents_path = target_path.join("Contents/Info.plist")
|
||||
expect(contents_path).to exist
|
||||
end
|
||||
|
||||
after do
|
||||
FileUtils.chmod 0755, target_path
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
describe Cask::Artifact::Installer, :cask do
|
||||
subject(:installer) { described_class.new(cask, **args) }
|
||||
|
||||
let(:staged_path) { mktmpdir }
|
||||
let(:cask) { instance_double(Cask::Cask, staged_path: staged_path, config: nil) }
|
||||
subject(:installer) { described_class.new(cask, **args) }
|
||||
|
||||
let(:command) { SystemCommand }
|
||||
|
||||
let(:args) { {} }
|
||||
@ -21,7 +23,7 @@ describe Cask::Artifact::Installer, :cask do
|
||||
let(:executable) { staged_path/"executable" }
|
||||
let(:args) { { script: { executable: "executable" } } }
|
||||
|
||||
before(:each) do
|
||||
before do
|
||||
FileUtils.touch executable
|
||||
end
|
||||
|
||||
|
||||
@ -104,7 +104,7 @@ describe Cask::Cask, :cask do
|
||||
allow(cask).to receive(:versions).and_return(installed_versions)
|
||||
allow(cask).to receive(:version).and_return(Cask::DSL::Version.new(tap_version))
|
||||
expect(cask).to receive(:outdated_versions).and_call_original
|
||||
is_expected.to eq expected_output
|
||||
expect(subject).to eq expected_output
|
||||
}
|
||||
end
|
||||
end
|
||||
@ -138,7 +138,7 @@ describe Cask::Cask, :cask do
|
||||
allow(cask).to receive(:versions).and_return(installed_version)
|
||||
allow(cask).to receive(:version).and_return(Cask::DSL::Version.new(tap_version))
|
||||
expect(cask).to receive(:outdated_versions).and_call_original
|
||||
is_expected.to eq expected_output
|
||||
expect(subject).to eq expected_output
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
@ -20,7 +20,7 @@ describe Cask::Cmd::Info, :cask do
|
||||
EOS
|
||||
end
|
||||
|
||||
it "it prints auto_updates if the Cask has `auto_updates true`" do
|
||||
it "prints auto_updates if the Cask has `auto_updates true`" do
|
||||
expect {
|
||||
described_class.run("with-auto-updates")
|
||||
}.to output(<<~EOS).to_stdout
|
||||
|
||||
@ -93,7 +93,7 @@ describe Cask::Cmd::Style, :cask do
|
||||
end
|
||||
|
||||
it {
|
||||
is_expected.to contain_exactly(a_path_ending_with("/homebrew/homebrew-cask/Casks"),
|
||||
expect(subject).to contain_exactly(a_path_ending_with("/homebrew/homebrew-cask/Casks"),
|
||||
a_path_ending_with("/third-party/homebrew-tap/Casks"))
|
||||
}
|
||||
end
|
||||
|
||||
@ -12,7 +12,7 @@ describe "Satisfy Dependencies and Requirements", :cask do
|
||||
let(:cask) { Cask::CaskLoader.load(cask_path("with-depends-on-cask-cyclic")) }
|
||||
|
||||
it {
|
||||
is_expected.to raise_error(
|
||||
expect(subject).to raise_error(
|
||||
Cask::CaskCyclicDependencyError,
|
||||
"Cask 'with-depends-on-cask-cyclic' includes cyclic dependencies "\
|
||||
"on other Casks: with-depends-on-cask-cyclic-helper",
|
||||
|
||||
@ -130,7 +130,7 @@ describe Cask::Quarantine, :cask do
|
||||
Cask::CaskLoader.load(cask_path("local-transmission")),
|
||||
).to be_installed
|
||||
|
||||
expect(Cask::Config.global.appdir.join("Transmission.app")).to_not be_quarantined
|
||||
expect(Cask::Config.global.appdir.join("Transmission.app")).not_to be_quarantined
|
||||
end
|
||||
|
||||
it "does not quarantine Cask fetches" do
|
||||
@ -138,7 +138,7 @@ describe Cask::Quarantine, :cask do
|
||||
local_transmission = Cask::CaskLoader.load(cask_path("local-transmission"))
|
||||
cached_location = Cask::Download.new(local_transmission).perform
|
||||
|
||||
expect(cached_location).to_not be_quarantined
|
||||
expect(cached_location).not_to be_quarantined
|
||||
end
|
||||
|
||||
it "does not quarantine Cask audits" do
|
||||
@ -147,7 +147,7 @@ describe Cask::Quarantine, :cask do
|
||||
local_transmission = Cask::CaskLoader.load(cask_path("local-transmission"))
|
||||
cached_location = Cask::Download.new(local_transmission).perform
|
||||
|
||||
expect(cached_location).to_not be_quarantined
|
||||
expect(cached_location).not_to be_quarantined
|
||||
end
|
||||
|
||||
it "does not quarantine Cask installs even if the fetch was" do
|
||||
@ -159,7 +159,7 @@ describe Cask::Quarantine, :cask do
|
||||
Cask::CaskLoader.load(cask_path("local-transmission")),
|
||||
).to be_installed
|
||||
|
||||
expect(Cask::Config.global.appdir.join("Transmission.app")).to_not be_quarantined
|
||||
expect(Cask::Config.global.appdir.join("Transmission.app")).not_to be_quarantined
|
||||
end
|
||||
|
||||
it "does not quarantine dmg-based Casks" do
|
||||
@ -169,7 +169,7 @@ describe Cask::Quarantine, :cask do
|
||||
Cask::CaskLoader.load(cask_path("container-dmg")),
|
||||
).to be_installed
|
||||
|
||||
expect(Cask::Config.global.appdir.join("container")).to_not be_quarantined
|
||||
expect(Cask::Config.global.appdir.join("container")).not_to be_quarantined
|
||||
end
|
||||
|
||||
it "does not quarantine tar-gz-based Casks" do
|
||||
@ -179,7 +179,7 @@ describe Cask::Quarantine, :cask do
|
||||
Cask::CaskLoader.load(cask_path("container-tar-gz")),
|
||||
).to be_installed
|
||||
|
||||
expect(Cask::Config.global.appdir.join("container")).to_not be_quarantined
|
||||
expect(Cask::Config.global.appdir.join("container")).not_to be_quarantined
|
||||
end
|
||||
|
||||
it "does not quarantine xar-based Casks" do
|
||||
@ -189,7 +189,7 @@ describe Cask::Quarantine, :cask do
|
||||
Cask::CaskLoader.load(cask_path("container-xar")),
|
||||
).to be_installed
|
||||
|
||||
expect(Cask::Config.global.appdir.join("container")).to_not be_quarantined
|
||||
expect(Cask::Config.global.appdir.join("container")).not_to be_quarantined
|
||||
end
|
||||
|
||||
it "does not quarantine pure bzip2-based Casks" do
|
||||
@ -199,7 +199,7 @@ describe Cask::Quarantine, :cask do
|
||||
Cask::CaskLoader.load(cask_path("container-bzip2")),
|
||||
).to be_installed
|
||||
|
||||
expect(Cask::Config.global.appdir.join("container")).to_not be_quarantined
|
||||
expect(Cask::Config.global.appdir.join("container")).not_to be_quarantined
|
||||
end
|
||||
|
||||
it "does not quarantine pure gzip-based Casks" do
|
||||
@ -209,7 +209,7 @@ describe Cask::Quarantine, :cask do
|
||||
Cask::CaskLoader.load(cask_path("container-gzip")),
|
||||
).to be_installed
|
||||
|
||||
expect(Cask::Config.global.appdir.join("container")).to_not be_quarantined
|
||||
expect(Cask::Config.global.appdir.join("container")).not_to be_quarantined
|
||||
end
|
||||
|
||||
it "does not quarantine the pkg in naked-pkg-based Casks" do
|
||||
@ -221,7 +221,7 @@ describe Cask::Quarantine, :cask do
|
||||
|
||||
expect(
|
||||
Cask::Caskroom.path.join("container-pkg", naked_pkg.version, "container.pkg"),
|
||||
).to_not be_quarantined
|
||||
).not_to be_quarantined
|
||||
end
|
||||
|
||||
it "does not quarantine a nested container" do
|
||||
@ -231,7 +231,7 @@ describe Cask::Quarantine, :cask do
|
||||
Cask::CaskLoader.load(cask_path("nested-app")),
|
||||
).to be_installed
|
||||
|
||||
expect(Cask::Config.global.appdir.join("MyNestedApp.app")).to_not be_quarantined
|
||||
expect(Cask::Config.global.appdir.join("MyNestedApp.app")).not_to be_quarantined
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -2,6 +2,7 @@ module Cask
|
||||
describe Verify, :cask do
|
||||
describe "::all" do
|
||||
subject(:verification) { described_class.all(cask, downloaded_path) }
|
||||
|
||||
let(:cask) { instance_double(Cask, token: "cask", sha256: expected_sha256) }
|
||||
let(:cafebabe) { "cafebabecafebabecafebabecafebabecafebabecafebabecafebabecafebabe" }
|
||||
let(:deadbeef) { "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef" }
|
||||
|
||||
@ -137,7 +137,7 @@ describe Homebrew::Cleanup do
|
||||
end
|
||||
|
||||
describe "#cleanup_cask", :cask do
|
||||
before(:each) do
|
||||
before do
|
||||
Cask::Cache.path.mkpath
|
||||
end
|
||||
|
||||
|
||||
@ -2,11 +2,6 @@ require_relative "../cli_parser"
|
||||
|
||||
describe Homebrew::CLI::Parser do
|
||||
describe "test switch options" do
|
||||
before do
|
||||
allow(ENV).to receive(:[]).with("HOMEBREW_PRY").and_return("1")
|
||||
allow(ENV).to receive(:[]).with("HOMEBREW_VERBOSE")
|
||||
end
|
||||
|
||||
subject(:parser) {
|
||||
described_class.new do
|
||||
switch :verbose, description: "Flag for verbosity"
|
||||
@ -15,6 +10,11 @@ describe Homebrew::CLI::Parser do
|
||||
end
|
||||
}
|
||||
|
||||
before do
|
||||
allow(ENV).to receive(:[]).with("HOMEBREW_PRY").and_return("1")
|
||||
allow(ENV).to receive(:[]).with("HOMEBREW_VERBOSE")
|
||||
end
|
||||
|
||||
it "parses short option" do
|
||||
parser.parse(["-v"])
|
||||
expect(Homebrew.args).to be_verbose
|
||||
|
||||
@ -235,7 +235,7 @@ describe CurlDownloadStrategy do
|
||||
|
||||
context "when URL ends with file" do
|
||||
it {
|
||||
is_expected.to eq(
|
||||
expect(subject).to eq(
|
||||
HOMEBREW_CACHE/"downloads/3d1c0ae7da22be9d83fb1eb774df96b7c4da71d3cf07e1cb28555cf9a5e5af70--foo.tar.gz",
|
||||
)
|
||||
}
|
||||
@ -245,7 +245,7 @@ describe CurlDownloadStrategy do
|
||||
let(:url) { "https://example.com/foo.tar.gz/from/this/mirror" }
|
||||
|
||||
it {
|
||||
is_expected.to eq(
|
||||
expect(subject).to eq(
|
||||
HOMEBREW_CACHE/"downloads/1ab61269ba52c83994510b1e28dd04167a2f2e8393a35a9c50c1f7d33fd8f619--foo.tar.gz",
|
||||
)
|
||||
}
|
||||
@ -253,7 +253,7 @@ describe CurlDownloadStrategy do
|
||||
end
|
||||
|
||||
describe "#fetch" do
|
||||
before(:each) do
|
||||
before do
|
||||
subject.temporary_path.dirname.mkpath
|
||||
FileUtils.touch subject.temporary_path
|
||||
end
|
||||
@ -337,16 +337,19 @@ describe CurlDownloadStrategy do
|
||||
describe "#cached_location" do
|
||||
context "with a file name trailing the URL path" do
|
||||
let(:url) { "https://example.com/cask.dmg" }
|
||||
|
||||
its("cached_location.extname") { is_expected.to eq(".dmg") }
|
||||
end
|
||||
|
||||
context "with a file name trailing the first query parameter" do
|
||||
let(:url) { "https://example.com/download?file=cask.zip&a=1" }
|
||||
|
||||
its("cached_location.extname") { is_expected.to eq(".zip") }
|
||||
end
|
||||
|
||||
context "with a file name trailing the second query parameter" do
|
||||
let(:url) { "https://example.com/dl?a=1&file=cask.zip&b=2" }
|
||||
|
||||
its("cached_location.extname") { is_expected.to eq(".zip") }
|
||||
end
|
||||
|
||||
@ -384,7 +387,7 @@ describe CurlPostDownloadStrategy do
|
||||
let(:specs) { {} }
|
||||
|
||||
describe "#fetch" do
|
||||
before(:each) do
|
||||
before do
|
||||
subject.temporary_path.dirname.mkpath
|
||||
FileUtils.touch subject.temporary_path
|
||||
end
|
||||
@ -426,6 +429,7 @@ end
|
||||
|
||||
describe ScpDownloadStrategy do
|
||||
subject { described_class.new(url, name, version) }
|
||||
|
||||
let(:name) { "foo" }
|
||||
let(:url) { "scp://example.com/foo.tar.gz" }
|
||||
let(:version) { nil }
|
||||
@ -456,6 +460,7 @@ describe ScpDownloadStrategy do
|
||||
|
||||
context "when given a valid URL" do
|
||||
let(:url) { "scp://example.com/foo.tar.gz" }
|
||||
|
||||
it "copies the file via scp" do
|
||||
expect(subject)
|
||||
.to receive(:system_command!)
|
||||
@ -468,6 +473,7 @@ describe ScpDownloadStrategy do
|
||||
|
||||
context "when given a URL with a username" do
|
||||
let(:url) { "scp://user@example.com/foo.tar.gz" }
|
||||
|
||||
it "copies the file via scp" do
|
||||
expect(subject)
|
||||
.to receive(:system_command!)
|
||||
@ -480,6 +486,7 @@ describe ScpDownloadStrategy do
|
||||
|
||||
context "when given a URL with a port" do
|
||||
let(:url) { "scp://example.com:1234/foo.tar.gz" }
|
||||
|
||||
it "copies the file via scp" do
|
||||
expect(subject)
|
||||
.to receive(:system_command!)
|
||||
@ -492,6 +499,7 @@ describe ScpDownloadStrategy do
|
||||
|
||||
context "when given a URL with /~/" do
|
||||
let(:url) { "scp://example.com/~/foo.tar.gz" }
|
||||
|
||||
it "treats the path as relative to the home directory" do
|
||||
expect(subject)
|
||||
.to receive(:system_command!)
|
||||
@ -562,7 +570,7 @@ describe DownloadStrategyDetector do
|
||||
|
||||
it "returns S3DownloadStrategy" do
|
||||
allow(described_class).to receive(:require_aws_sdk).and_return(true)
|
||||
is_expected.to eq(S3DownloadStrategy)
|
||||
expect(subject).to eq(S3DownloadStrategy)
|
||||
end
|
||||
end
|
||||
|
||||
@ -572,12 +580,13 @@ describe DownloadStrategyDetector do
|
||||
|
||||
it "requires aws-sdk-s3" do
|
||||
allow(described_class).to receive(:require_aws_sdk).and_return(true)
|
||||
is_expected.to eq(S3DownloadStrategy)
|
||||
expect(subject).to eq(S3DownloadStrategy)
|
||||
end
|
||||
end
|
||||
|
||||
context "when given an scp URL" do
|
||||
let(:url) { "scp://example.com/brew.tar.gz" }
|
||||
|
||||
it { is_expected.to eq(ScpDownloadStrategy) }
|
||||
end
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
describe ErrorDuringExecution do
|
||||
subject(:error) { described_class.new(command, status: status, output: output) }
|
||||
|
||||
let(:command) { ["false"] }
|
||||
let(:status) { instance_double(Process::Status, exitstatus: exitstatus) }
|
||||
let(:exitstatus) { 1 }
|
||||
@ -43,7 +44,7 @@ describe ErrorDuringExecution do
|
||||
end
|
||||
|
||||
its(:to_s) {
|
||||
is_expected.to eq <<~EOS
|
||||
expect(subject).to eq <<~EOS
|
||||
Failure while executing; `false` exited with 1. Here's the output:
|
||||
This still worked.
|
||||
#{Formatter.error("Here something went wrong.\n")}
|
||||
@ -55,7 +56,7 @@ describe ErrorDuringExecution do
|
||||
let(:command) { ["env", "PATH=/bin", "cat", "with spaces"] }
|
||||
|
||||
its(:to_s) {
|
||||
is_expected
|
||||
expect(subject)
|
||||
.to eq 'Failure while executing; `env PATH=/bin cat with\ spaces` exited with 1.'
|
||||
}
|
||||
end
|
||||
|
||||
@ -16,7 +16,7 @@ describe FormulaValidationError do
|
||||
subject { described_class.new("foo", "sha257", "magic") }
|
||||
|
||||
its(:to_s) {
|
||||
is_expected.to eq(%q(invalid attribute for formula 'foo': sha257 ("magic")))
|
||||
expect(subject).to eq(%q(invalid attribute for formula 'foo': sha257 ("magic")))
|
||||
}
|
||||
end
|
||||
|
||||
@ -49,7 +49,7 @@ describe FormulaUnavailableError do
|
||||
end
|
||||
|
||||
its(:to_s) {
|
||||
is_expected.to eq('No available formula with the name "foo" (dependency of foobar)')
|
||||
expect(subject).to eq('No available formula with the name "foo" (dependency of foobar)')
|
||||
}
|
||||
end
|
||||
end
|
||||
@ -76,7 +76,7 @@ describe FormulaClassUnavailableError do
|
||||
let(:list) { [] }
|
||||
|
||||
its(:to_s) {
|
||||
is_expected.to match(/Expected to find class Foo, but found no classes\./)
|
||||
expect(subject).to match(/Expected to find class Foo, but found no classes\./)
|
||||
}
|
||||
end
|
||||
|
||||
@ -84,7 +84,7 @@ describe FormulaClassUnavailableError do
|
||||
let(:list) { [mod.const_get(:Bar)] }
|
||||
|
||||
its(:to_s) {
|
||||
is_expected.to match(/Expected to find class Foo, but only found: Bar \(not derived from Formula!\)\./)
|
||||
expect(subject).to match(/Expected to find class Foo, but only found: Bar \(not derived from Formula!\)\./)
|
||||
}
|
||||
end
|
||||
|
||||
@ -184,6 +184,7 @@ end
|
||||
|
||||
describe ErrorDuringExecution do
|
||||
subject { described_class.new(["badprg", "arg1", "arg2"], status: status) }
|
||||
|
||||
let(:status) { instance_double(Process::Status, exitstatus: 17) }
|
||||
|
||||
its(:to_s) { is_expected.to eq("Failure while executing; `badprg arg1 arg2` exited with 17.") }
|
||||
|
||||
@ -137,7 +137,7 @@ describe Formulary do
|
||||
|
||||
context "with installed Formula" do
|
||||
before do
|
||||
allow(Formulary).to receive(:loader_for).and_call_original
|
||||
allow(described_class).to receive(:loader_for).and_call_original
|
||||
stub_formula_loader formula("patchelf") { url "patchelf-1.0" }
|
||||
allow(Formula["patchelf"]).to receive(:installed?).and_return(true)
|
||||
end
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
require "linkage_cache_store"
|
||||
|
||||
describe LinkageCacheStore do
|
||||
subject { described_class.new(keg_name, database) }
|
||||
|
||||
let(:keg_name) { "keg_name" }
|
||||
let(:database) { double("database") }
|
||||
|
||||
subject { LinkageCacheStore.new(keg_name, database) }
|
||||
|
||||
describe "#keg_exists?" do
|
||||
context "`keg_name` exists in cache" do
|
||||
before(:each) do
|
||||
before do
|
||||
expect(database).to receive(:get).with(keg_name).and_return("")
|
||||
end
|
||||
|
||||
@ -18,7 +18,7 @@ describe LinkageCacheStore do
|
||||
end
|
||||
|
||||
context "`keg_name` does not exist in cache" do
|
||||
before(:each) do
|
||||
before do
|
||||
expect(database).to receive(:get).with(keg_name).and_return(nil)
|
||||
end
|
||||
|
||||
@ -52,7 +52,7 @@ describe LinkageCacheStore do
|
||||
|
||||
describe "#fetch_type" do
|
||||
context "`HASH_LINKAGE_TYPES.include?(type)`" do
|
||||
before(:each) do
|
||||
before do
|
||||
expect(database).to receive(:get).with(keg_name).and_return(nil)
|
||||
end
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@ require "messages"
|
||||
require "spec_helper"
|
||||
|
||||
describe Messages do
|
||||
let(:messages) { Messages.new }
|
||||
let(:messages) { described_class.new }
|
||||
let(:test_formula) { formula("foo") { url("https://example.com/foo-0.1.tgz") } }
|
||||
let(:elapsed_time) { 1.1 }
|
||||
|
||||
@ -18,7 +18,7 @@ describe Messages do
|
||||
it "increases the formula count" do
|
||||
expect {
|
||||
messages.formula_installed(test_formula, elapsed_time)
|
||||
}.to change { messages.formula_count }.by(1)
|
||||
}.to change(messages, :formula_count).by(1)
|
||||
end
|
||||
|
||||
it "adds to install_times" do
|
||||
|
||||
@ -24,24 +24,24 @@ describe OS::Mac do
|
||||
it "calls sdk_path on Xcode-only systems" do
|
||||
allow(OS::Mac::Xcode).to receive(:installed?).and_return(true)
|
||||
allow(OS::Mac::CLT).to receive(:installed?).and_return(false)
|
||||
expect(OS::Mac).to receive(:sdk_path)
|
||||
OS::Mac.sdk_path_if_needed
|
||||
expect(described_class).to receive(:sdk_path)
|
||||
described_class.sdk_path_if_needed
|
||||
end
|
||||
|
||||
it "does not call sdk_path on Xcode-and-CLT systems with system headers" do
|
||||
allow(OS::Mac::Xcode).to receive(:installed?).and_return(true)
|
||||
allow(OS::Mac::CLT).to receive(:installed?).and_return(true)
|
||||
allow(OS::Mac::CLT).to receive(:separate_header_package?).and_return(false)
|
||||
expect(OS::Mac).not_to receive(:sdk_path)
|
||||
OS::Mac.sdk_path_if_needed
|
||||
expect(described_class).not_to receive(:sdk_path)
|
||||
described_class.sdk_path_if_needed
|
||||
end
|
||||
|
||||
it "does not call sdk_path on CLT-only systems with no CLT SDK" do
|
||||
allow(OS::Mac::Xcode).to receive(:installed?).and_return(false)
|
||||
allow(OS::Mac::CLT).to receive(:installed?).and_return(true)
|
||||
allow(OS::Mac::CLT).to receive(:provides_sdk?).and_return(false)
|
||||
expect(OS::Mac).not_to receive(:sdk_path)
|
||||
OS::Mac.sdk_path_if_needed
|
||||
expect(described_class).not_to receive(:sdk_path)
|
||||
described_class.sdk_path_if_needed
|
||||
end
|
||||
|
||||
it "does not call sdk_path on CLT-only systems with a CLT SDK if the system provides headers" do
|
||||
@ -49,8 +49,8 @@ describe OS::Mac do
|
||||
allow(OS::Mac::CLT).to receive(:installed?).and_return(true)
|
||||
allow(OS::Mac::CLT).to receive(:provides_sdk?).and_return(true)
|
||||
allow(OS::Mac::CLT).to receive(:separate_header_package?).and_return(false)
|
||||
expect(OS::Mac).not_to receive(:sdk_path)
|
||||
OS::Mac.sdk_path_if_needed
|
||||
expect(described_class).not_to receive(:sdk_path)
|
||||
described_class.sdk_path_if_needed
|
||||
end
|
||||
|
||||
it "calls sdk_path on CLT-only systems with a CLT SDK if the system does not provide headers" do
|
||||
@ -58,8 +58,8 @@ describe OS::Mac do
|
||||
allow(OS::Mac::CLT).to receive(:installed?).and_return(true)
|
||||
allow(OS::Mac::CLT).to receive(:provides_sdk?).and_return(true)
|
||||
allow(OS::Mac::CLT).to receive(:separate_header_package?).and_return(true)
|
||||
expect(OS::Mac).to receive(:sdk_path)
|
||||
OS::Mac.sdk_path_if_needed
|
||||
expect(described_class).to receive(:sdk_path)
|
||||
described_class.sdk_path_if_needed
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,15 +1,16 @@
|
||||
require "system_command"
|
||||
|
||||
describe SystemCommand::Result do
|
||||
subject(:result) {
|
||||
described_class.new([], output_array, instance_double(Process::Status, exitstatus: 0, success?: true))
|
||||
}
|
||||
|
||||
let(:output_array) {
|
||||
[
|
||||
[:stdout, "output\n"],
|
||||
[:stderr, "error\n"],
|
||||
]
|
||||
}
|
||||
subject(:result) {
|
||||
described_class.new([], output_array, instance_double(Process::Status, exitstatus: 0, success?: true))
|
||||
}
|
||||
|
||||
describe "#to_ary" do
|
||||
it "can be destructed like `Open3.capture3`" do
|
||||
@ -41,6 +42,7 @@ describe SystemCommand::Result do
|
||||
|
||||
describe "#plist" do
|
||||
subject { result.plist }
|
||||
|
||||
let(:output_array) { [[:stdout, stdout]] }
|
||||
let(:garbage) {
|
||||
<<~EOS
|
||||
@ -114,7 +116,7 @@ describe SystemCommand::Result do
|
||||
end
|
||||
|
||||
context "when verbose" do
|
||||
before(:each) do
|
||||
before do
|
||||
allow(ARGV).to receive(:verbose?).and_return(true)
|
||||
end
|
||||
|
||||
@ -138,7 +140,7 @@ describe SystemCommand::Result do
|
||||
end
|
||||
|
||||
context "when verbose" do
|
||||
before(:each) do
|
||||
before do
|
||||
allow(ARGV).to receive(:verbose?).and_return(true)
|
||||
end
|
||||
|
||||
|
||||
@ -1,9 +1,5 @@
|
||||
describe SystemCommand do
|
||||
describe "#initialize" do
|
||||
let(:env_args) { ["bash", "-c", 'printf "%s" "${A?}" "${B?}" "${C?}"'] }
|
||||
let(:env) { { "A" => "1", "B" => "2", "C" => "3" } }
|
||||
let(:sudo) { false }
|
||||
|
||||
subject(:command) {
|
||||
described_class.new(
|
||||
"env",
|
||||
@ -14,6 +10,10 @@ describe SystemCommand do
|
||||
)
|
||||
}
|
||||
|
||||
let(:env_args) { ["bash", "-c", 'printf "%s" "${A?}" "${B?}" "${C?}"'] }
|
||||
let(:env) { { "A" => "1", "B" => "2", "C" => "3" } }
|
||||
let(:sudo) { false }
|
||||
|
||||
context "when given some environment variables" do
|
||||
its("run!.stdout") { is_expected.to eq("123") }
|
||||
|
||||
@ -237,7 +237,7 @@ describe SystemCommand do
|
||||
context "when given an executable with spaces and no arguments" do
|
||||
let(:executable) { mktmpdir/"App Uninstaller" }
|
||||
|
||||
before(:each) do
|
||||
before do
|
||||
executable.write <<~SH
|
||||
#!/usr/bin/env bash
|
||||
true
|
||||
|
||||
@ -1,13 +1,15 @@
|
||||
require_relative "shared_examples"
|
||||
|
||||
describe UnpackStrategy::Directory do
|
||||
subject(:strategy) { described_class.new(path) }
|
||||
|
||||
let(:path) {
|
||||
mktmpdir.tap do |path|
|
||||
FileUtils.touch path/"file"
|
||||
FileUtils.ln_s "file", path/"symlink"
|
||||
end
|
||||
}
|
||||
subject(:strategy) { described_class.new(path) }
|
||||
|
||||
let(:unpack_dir) { mktmpdir }
|
||||
|
||||
it "does not follow symlinks" do
|
||||
|
||||
@ -5,7 +5,7 @@ describe UnpackStrategy::Subversion, :needs_svn do
|
||||
let(:working_copy) { mktmpdir }
|
||||
let(:path) { working_copy }
|
||||
|
||||
before(:each) do
|
||||
before do
|
||||
system "svnadmin", "create", repo
|
||||
|
||||
system "svn", "checkout", "file://#{repo}", working_copy
|
||||
|
||||
@ -12,7 +12,7 @@ describe UpdateMigrator do
|
||||
let(:old_cache_file) { HOMEBREW_CACHE/"#{formula_name}-1.2.3.tar.gz" }
|
||||
let(:new_cache_file) { HOMEBREW_CACHE/"#{formula_name}--1.2.3.tar.gz" }
|
||||
|
||||
before(:each) do
|
||||
before do
|
||||
FileUtils.touch old_cache_file
|
||||
allow(Formula).to receive(:each).and_yield(f)
|
||||
end
|
||||
@ -58,7 +58,7 @@ describe UpdateMigrator do
|
||||
HOMEBREW_CACHE/"downloads/5994e3a27baa3f448a001fb071ab1f0bf25c87aebcb254d91a6d0b02f46eef86--foo-1.2.3.tar.gz"
|
||||
}
|
||||
|
||||
before(:each) do
|
||||
before do
|
||||
old_cache_file.dirname.mkpath
|
||||
FileUtils.touch old_cache_file
|
||||
allow(Formula).to receive(:[]).and_return(f)
|
||||
|
||||
@ -10,7 +10,7 @@ describe Utils::Analytics do
|
||||
|
||||
it "returns OS_VERSION and prefix when HOMEBREW_PREFIX is a custom prefix" do
|
||||
stub_const("HOMEBREW_PREFIX", "blah")
|
||||
expect(described_class.os_prefix_ci).to include("#{OS_VERSION}, #{Utils::Analytics.custom_prefix_label}")
|
||||
expect(described_class.os_prefix_ci).to include("#{OS_VERSION}, #{described_class.custom_prefix_label}")
|
||||
end
|
||||
|
||||
it "includes CI when ENV['CI'] is set" do
|
||||
@ -20,7 +20,7 @@ describe Utils::Analytics do
|
||||
|
||||
it "does not include prefix when HOMEBREW_PREFIX is the default prefix" do
|
||||
stub_const("HOMEBREW_PREFIX", Homebrew::DEFAULT_PREFIX)
|
||||
expect(described_class.os_prefix_ci).not_to include(Utils::Analytics.custom_prefix_label)
|
||||
expect(described_class.os_prefix_ci).not_to include(described_class.custom_prefix_label)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -9,7 +9,7 @@ describe "curl" do
|
||||
|
||||
it "doesn't return -q as the first argument when HOMEBREW_CURLRC is set" do
|
||||
ENV["HOMEBREW_CURLRC"] = "1"
|
||||
expect(curl_args("foo").first).to_not eq("-q")
|
||||
expect(curl_args("foo").first).not_to eq("-q")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user