aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test
diff options
context:
space:
mode:
Diffstat (limited to 'Library/Homebrew/test')
-rw-r--r--Library/Homebrew/test/.bundle/config1
-rw-r--r--Library/Homebrew/test/cask/cask_spec.rb4
-rw-r--r--Library/Homebrew/test/cask/cli/install_spec.rb14
-rw-r--r--Library/Homebrew/test/cask/cli/reinstall_spec.rb23
-rw-r--r--Library/Homebrew/test/cask/cli/uninstall_spec.rb17
-rw-r--r--Library/Homebrew/test/cask/installer_spec.rb10
-rw-r--r--Library/Homebrew/test/cmd/install_spec.rb10
-rw-r--r--Library/Homebrew/test/compiler_selector_spec.rb12
-rw-r--r--Library/Homebrew/test/dev-cmd/audit_spec.rb190
-rw-r--r--Library/Homebrew/test/diagnostic_spec.rb9
-rw-r--r--Library/Homebrew/test/requirement_spec.rb10
-rw-r--r--Library/Homebrew/test/spec_helper.rb1
-rw-r--r--Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb1
-rw-r--r--Library/Homebrew/test/utils/shell_spec.rb56
-rw-r--r--Library/Homebrew/test/utils_spec.rb10
-rw-r--r--Library/Homebrew/test/version_spec.rb5
16 files changed, 309 insertions, 64 deletions
diff --git a/Library/Homebrew/test/.bundle/config b/Library/Homebrew/test/.bundle/config
index e451829e9..20549341c 100644
--- a/Library/Homebrew/test/.bundle/config
+++ b/Library/Homebrew/test/.bundle/config
@@ -1,3 +1,4 @@
---
BUNDLE_PATH: "../vendor/bundle"
BUNDLE_DISABLE_SHARED_GEMS: "true"
+BUNDLE_BIN: "../bin"
diff --git a/Library/Homebrew/test/cask/cask_spec.rb b/Library/Homebrew/test/cask/cask_spec.rb
index 2ab966f82..3736f3c01 100644
--- a/Library/Homebrew/test/cask/cask_spec.rb
+++ b/Library/Homebrew/test/cask/cask_spec.rb
@@ -85,8 +85,8 @@ describe Hbc::Cask, :cask do
it "proposes a versioned metadata directory name for each instance" do
cask_token = "local-caffeine"
c = Hbc::CaskLoader.load(cask_token)
- metadata_path = Hbc.caskroom.join(cask_token, ".metadata", c.version)
- expect(c.metadata_versioned_container_path.to_s).to eq(metadata_path.to_s)
+ metadata_timestamped_path = Hbc.caskroom.join(cask_token, ".metadata", c.version)
+ expect(c.metadata_versioned_path.to_s).to eq(metadata_timestamped_path.to_s)
end
end
diff --git a/Library/Homebrew/test/cask/cli/install_spec.rb b/Library/Homebrew/test/cask/cli/install_spec.rb
index 5a40017e8..219b9522e 100644
--- a/Library/Homebrew/test/cask/cli/install_spec.rb
+++ b/Library/Homebrew/test/cask/cli/install_spec.rb
@@ -1,4 +1,18 @@
describe Hbc::CLI::Install, :cask do
+ it "displays the installation progress" do
+ output = Regexp.new <<-EOS.undent
+ ==> Downloading file:.*caffeine.zip
+ ==> Verifying checksum for Cask local-caffeine
+ ==> Installing Cask local-caffeine
+ ==> Moving App 'Caffeine.app' to '.*Caffeine.app'.
+ .*local-caffeine was successfully installed!
+ EOS
+
+ expect {
+ Hbc::CLI::Install.run("local-caffeine")
+ }.to output(output).to_stdout
+ end
+
it "allows staging and activation of multiple Casks at once" do
shutup do
Hbc::CLI::Install.run("local-transmission", "local-caffeine")
diff --git a/Library/Homebrew/test/cask/cli/reinstall_spec.rb b/Library/Homebrew/test/cask/cli/reinstall_spec.rb
index e573a3470..8885fa199 100644
--- a/Library/Homebrew/test/cask/cli/reinstall_spec.rb
+++ b/Library/Homebrew/test/cask/cli/reinstall_spec.rb
@@ -1,4 +1,27 @@
describe Hbc::CLI::Reinstall, :cask do
+ it "displays the reinstallation progress" do
+ caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb")
+
+ shutup do
+ Hbc::Installer.new(caffeine).install
+ end
+
+ output = Regexp.new <<-EOS.undent
+ ==> Downloading file:.*caffeine.zip
+ Already downloaded: .*local-caffeine--1.2.3.zip
+ ==> Verifying checksum for Cask local-caffeine
+ ==> Uninstalling Cask local-caffeine
+ ==> Removing App '.*Caffeine.app'.
+ ==> Installing Cask local-caffeine
+ ==> Moving App 'Caffeine.app' to '.*Caffeine.app'.
+ .*local-caffeine was successfully installed!
+ EOS
+
+ expect {
+ Hbc::CLI::Reinstall.run("local-caffeine")
+ }.to output(output).to_stdout
+ end
+
it "allows reinstalling a Cask" do
shutup do
Hbc::CLI::Install.run("local-transmission")
diff --git a/Library/Homebrew/test/cask/cli/uninstall_spec.rb b/Library/Homebrew/test/cask/cli/uninstall_spec.rb
index c03f64c8f..4089c47b4 100644
--- a/Library/Homebrew/test/cask/cli/uninstall_spec.rb
+++ b/Library/Homebrew/test/cask/cli/uninstall_spec.rb
@@ -1,4 +1,21 @@
describe Hbc::CLI::Uninstall, :cask do
+ it "displays the uninstallation progress" do
+ caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb")
+
+ shutup do
+ Hbc::Installer.new(caffeine).install
+ end
+
+ output = Regexp.new <<-EOS.undent
+ ==> Uninstalling Cask local-caffeine
+ ==> Removing App '.*Caffeine.app'.
+ EOS
+
+ expect {
+ Hbc::CLI::Uninstall.run("local-caffeine")
+ }.to output(output).to_stdout
+ end
+
it "shows an error when a bad Cask is provided" do
expect {
Hbc::CLI::Uninstall.run("notacask")
diff --git a/Library/Homebrew/test/cask/installer_spec.rb b/Library/Homebrew/test/cask/installer_spec.rb
index 7dd5b2bda..59d61bbdd 100644
--- a/Library/Homebrew/test/cask/installer_spec.rb
+++ b/Library/Homebrew/test/cask/installer_spec.rb
@@ -336,9 +336,8 @@ describe Hbc::Installer, :cask do
Hbc::Installer.new(caffeine).install
end
- m_path = caffeine.metadata_path(:now, true)
- expect(caffeine.metadata_path(:now, false)).to eq(m_path)
- expect(caffeine.metadata_path(:latest)).to eq(m_path)
+ m_path = caffeine.metadata_timestamped_path(timestamp: :now, create: true)
+ expect(caffeine.metadata_timestamped_path(timestamp: :latest)).to eq(m_path)
end
it "generates and finds a metadata subdirectory for an installed Cask" do
@@ -349,9 +348,8 @@ describe Hbc::Installer, :cask do
end
subdir_name = "Casks"
- m_subdir = caffeine.metadata_subdir(subdir_name, :now, true)
- expect(caffeine.metadata_subdir(subdir_name, :now, false)).to eq(m_subdir)
- expect(caffeine.metadata_subdir(subdir_name, :latest)).to eq(m_subdir)
+ m_subdir = caffeine.metadata_subdir(subdir_name, timestamp: :now, create: true)
+ expect(caffeine.metadata_subdir(subdir_name, timestamp: :latest)).to eq(m_subdir)
end
end
diff --git a/Library/Homebrew/test/cmd/install_spec.rb b/Library/Homebrew/test/cmd/install_spec.rb
index c1240a30e..034bdd53f 100644
--- a/Library/Homebrew/test/cmd/install_spec.rb
+++ b/Library/Homebrew/test/cmd/install_spec.rb
@@ -217,10 +217,9 @@ describe "brew install", :integration_test do
depends_on NonFatalRequirement
EOS
- # FIXME: This should output to STDERR.
expect { brew "install", "testball1" }
- .to output(/NonFatalRequirement unsatisfied!/).to_stdout
- .and not_to_output.to_stderr
+ .to output(/NonFatalRequirement unsatisfied!/).to_stderr
+ .and output(/built in/).to_stdout
.and be_a_success
end
@@ -234,10 +233,9 @@ describe "brew install", :integration_test do
depends_on FatalRequirement
EOS
- # FIXME: This should output to STDERR.
expect { brew "install", "testball1" }
- .to output(/FatalRequirement unsatisfied!/).to_stdout
- .and output(/An unsatisfied requirement failed this build./).to_stderr
+ .to output(/FatalRequirement unsatisfied!/).to_stderr
+ .and not_to_output.to_stdout
.and be_a_failure
end
end
diff --git a/Library/Homebrew/test/compiler_selector_spec.rb b/Library/Homebrew/test/compiler_selector_spec.rb
index 0f6f6b5f2..18efbfd42 100644
--- a/Library/Homebrew/test/compiler_selector_spec.rb
+++ b/Library/Homebrew/test/compiler_selector_spec.rb
@@ -3,7 +3,7 @@ require "software_spec"
describe CompilerSelector do
subject { described_class.new(software_spec, versions, compilers) }
- let(:compilers) { [:clang, :gcc, :llvm, :gnu] }
+ let(:compilers) { [:clang, :gcc, :gnu] }
let(:software_spec) { SoftwareSpec.new }
let(:cc) { :clang }
let(:versions) do
@@ -28,7 +28,6 @@ describe CompilerSelector do
describe "#compiler" do
it "raises an error if no matching compiler can be found" do
software_spec.fails_with(:clang)
- software_spec.fails_with(:llvm)
software_spec.fails_with(:gcc)
software_spec.fails_with(gcc: "4.8")
software_spec.fails_with(gcc: "4.7")
@@ -45,11 +44,6 @@ describe CompilerSelector do
expect(subject.compiler).to eq(:gcc)
end
- it "returns clang if it fails with llvm" do
- software_spec.fails_with(:llvm)
- expect(subject.compiler).to eq(:clang)
- end
-
it "returns clang if it fails with gcc" do
software_spec.fails_with(:gcc)
expect(subject.compiler).to eq(:clang)
@@ -68,13 +62,11 @@ describe CompilerSelector do
it "returns gcc if it fails with clang and llvm" do
software_spec.fails_with(:clang)
- software_spec.fails_with(:llvm)
expect(subject.compiler).to eq(:gcc)
end
it "returns clang if it fails with gcc and llvm" do
software_spec.fails_with(:gcc)
- software_spec.fails_with(:llvm)
expect(subject.compiler).to eq(:clang)
end
@@ -87,7 +79,6 @@ describe CompilerSelector do
example "returns a lower version of gcc if it fails with the highest version" do
software_spec.fails_with(:clang)
software_spec.fails_with(:gcc)
- software_spec.fails_with(:llvm)
software_spec.fails_with(gcc: "4.8")
expect(subject.compiler).to eq("gcc-4.7")
end
@@ -102,7 +93,6 @@ describe CompilerSelector do
allow(versions).to receive(:gcc_build_version).and_return(Version::NULL)
software_spec.fails_with(:clang)
- software_spec.fails_with(:llvm)
software_spec.fails_with(gcc: "4.8")
software_spec.fails_with(gcc: "4.7")
diff --git a/Library/Homebrew/test/dev-cmd/audit_spec.rb b/Library/Homebrew/test/dev-cmd/audit_spec.rb
index c0a090b29..9afb7954a 100644
--- a/Library/Homebrew/test/dev-cmd/audit_spec.rb
+++ b/Library/Homebrew/test/dev-cmd/audit_spec.rb
@@ -5,6 +5,13 @@ RSpec::Matchers.alias_matcher :have_data, :be_data
RSpec::Matchers.alias_matcher :have_end, :be_end
RSpec::Matchers.alias_matcher :have_trailing_newline, :be_trailing_newline
+module Count
+ def self.increment
+ @count ||= 0
+ @count += 1
+ end
+end
+
describe FormulaText do
let(:dir) { mktmpdir }
@@ -424,4 +431,187 @@ describe FormulaAuditor do
.to match('xcodebuild should be passed an explicit "SYMROOT"')
end
end
+
+ describe "#audit_revision_and_version_scheme" do
+ let(:origin_tap_path) { Tap::TAP_DIRECTORY/"homebrew/homebrew-foo" }
+ let(:formula_subpath) { "Formula/foo#{@foo_version}.rb" }
+ let(:origin_formula_path) { origin_tap_path/formula_subpath }
+ let(:tap_path) { Tap::TAP_DIRECTORY/"homebrew/homebrew-bar" }
+ let(:formula_path) { tap_path/formula_subpath }
+
+ before(:each) do
+ @foo_version = Count.increment
+
+ origin_formula_path.write <<-EOS.undent
+ class Foo#{@foo_version} < Formula
+ url "https://example.com/foo-1.0.tar.gz"
+ revision 2
+ version_scheme 1
+ end
+ EOS
+
+ origin_tap_path.mkpath
+ origin_tap_path.cd do
+ shutup do
+ system "git", "init"
+ system "git", "add", "--all"
+ system "git", "commit", "-m", "init"
+ end
+ end
+
+ tap_path.mkpath
+ tap_path.cd do
+ shutup do
+ system "git", "clone", origin_tap_path, "."
+ end
+ end
+ end
+
+ subject do
+ fa = described_class.new(Formulary.factory(formula_path))
+ fa.audit_revision_and_version_scheme
+ fa.problems.first
+ end
+
+ def formula_gsub(before, after = "")
+ text = formula_path.read
+ text.gsub! before, after
+ formula_path.unlink
+ formula_path.write text
+ end
+
+ def formula_gsub_commit(before, after = "")
+ text = origin_formula_path.read
+ text.gsub!(before, after)
+ origin_formula_path.unlink
+ origin_formula_path.write text
+
+ origin_tap_path.cd do
+ shutup do
+ system "git", "commit", "-am", "commit"
+ end
+ end
+
+ tap_path.cd do
+ shutup do
+ system "git", "fetch"
+ system "git", "reset", "--hard", "origin/master"
+ end
+ end
+ end
+
+ context "revisions" do
+ context "should not be removed when first committed above 0" do
+ it { is_expected.to be_nil }
+ end
+
+ context "should not decrease with the same version" do
+ before { formula_gsub_commit "revision 2", "revision 1" }
+
+ it { is_expected.to match("revision should not decrease (from 2 to 1)") }
+ end
+
+ context "should not be removed with the same version" do
+ before { formula_gsub_commit "revision 2" }
+
+ it { is_expected.to match("revision should not decrease (from 2 to 0)") }
+ end
+
+ context "should not decrease with the same, uncommitted version" do
+ before { formula_gsub "revision 2", "revision 1" }
+
+ it { is_expected.to match("revision should not decrease (from 2 to 1)") }
+ end
+
+ context "should be removed with a newer version" do
+ before { formula_gsub_commit "foo-1.0.tar.gz", "foo-1.1.tar.gz" }
+
+ it { is_expected.to match("'revision 2' should be removed") }
+ end
+
+ context "should not warn on an newer version revision removal" do
+ before do
+ formula_gsub_commit "revision 2", ""
+ formula_gsub_commit "foo-1.0.tar.gz", "foo-1.1.tar.gz"
+ end
+
+ it { is_expected.to be_nil }
+ end
+
+ context "should only increment by 1 with an uncommitted version" do
+ before do
+ formula_gsub "foo-1.0.tar.gz", "foo-1.1.tar.gz"
+ formula_gsub "revision 2", "revision 4"
+ end
+
+ it { is_expected.to match("revisions should only increment by 1") }
+ end
+
+ context "should not warn on past increment by more than 1" do
+ before do
+ formula_gsub_commit "revision 2", "# no revision"
+ formula_gsub_commit "foo-1.0.tar.gz", "foo-1.1.tar.gz"
+ formula_gsub_commit "# no revision", "revision 3"
+ end
+
+ it { is_expected.to be_nil }
+ end
+ end
+
+ context "version_schemes" do
+ context "should not decrease with the same version" do
+ before { formula_gsub_commit "version_scheme 1" }
+
+ it { is_expected.to match("version_scheme should not decrease (from 1 to 0)") }
+ end
+
+ context "should not decrease with a new version" do
+ before do
+ formula_gsub_commit "foo-1.0.tar.gz", "foo-1.1.tar.gz"
+ formula_gsub_commit "version_scheme 1", ""
+ formula_gsub_commit "revision 2", ""
+ end
+
+ it { is_expected.to match("version_scheme should not decrease (from 1 to 0)") }
+ end
+
+ context "should only increment by 1" do
+ before do
+ formula_gsub_commit "version_scheme 1", "# no version_scheme"
+ formula_gsub_commit "foo-1.0.tar.gz", "foo-1.1.tar.gz"
+ formula_gsub_commit "revision 2", ""
+ formula_gsub_commit "# no version_scheme", "version_scheme 3"
+ end
+
+ it { is_expected.to match("version_schemes should only increment by 1") }
+ end
+ end
+
+ context "versions" do
+ context "uncommitted should not decrease" do
+ before { formula_gsub "foo-1.0.tar.gz", "foo-0.9.tar.gz" }
+
+ it { is_expected.to match("stable version should not decrease (from 1.0 to 0.9)") }
+ end
+
+ context "committed can decrease" do
+ before do
+ formula_gsub_commit "revision 2"
+ formula_gsub_commit "foo-1.0.tar.gz", "foo-0.9.tar.gz"
+ end
+
+ it { is_expected.to be_nil }
+ end
+
+ context "can decrease with version_scheme increased" do
+ before do
+ formula_gsub "revision 2"
+ formula_gsub "foo-1.0.tar.gz", "foo-0.9.tar.gz"
+ formula_gsub "version_scheme 1", "version_scheme 2"
+ end
+
+ it { is_expected.to be_nil }
+ end
+ end
+ end
end
diff --git a/Library/Homebrew/test/diagnostic_spec.rb b/Library/Homebrew/test/diagnostic_spec.rb
index c2bcdb9c0..6e2c09268 100644
--- a/Library/Homebrew/test/diagnostic_spec.rb
+++ b/Library/Homebrew/test/diagnostic_spec.rb
@@ -122,8 +122,9 @@ describe Homebrew::Diagnostic::Checks do
specify "#check_user_path_3" do
begin
sbin = HOMEBREW_PREFIX/"sbin"
- ENV["PATH"] = "#{HOMEBREW_PREFIX}/bin#{File::PATH_SEPARATOR}" +
- ENV["PATH"].gsub(/(?:^|#{Regexp.escape(File::PATH_SEPARATOR)})#{Regexp.escape(sbin)}/, "")
+ ENV["HOMEBREW_PATH"] =
+ "#{HOMEBREW_PREFIX}/bin#{File::PATH_SEPARATOR}" +
+ ENV["HOMEBREW_PATH"].gsub(/(?:^|#{Regexp.escape(File::PATH_SEPARATOR)})#{Regexp.escape(sbin)}/, "")
(sbin/"something").mkpath
expect(subject.check_user_path_1).to be nil
@@ -149,7 +150,9 @@ describe Homebrew::Diagnostic::Checks do
file = "#{path}/foo-config"
FileUtils.touch file
FileUtils.chmod 0755, file
- ENV["PATH"] = "#{path}#{File::PATH_SEPARATOR}#{ENV["PATH"]}"
+ ENV["HOMEBREW_PATH"] =
+ ENV["PATH"] =
+ "#{path}#{File::PATH_SEPARATOR}#{ENV["PATH"]}"
expect(subject.check_for_config_scripts)
.to match('"config" scripts exist')
diff --git a/Library/Homebrew/test/requirement_spec.rb b/Library/Homebrew/test/requirement_spec.rb
index 110a7ac4f..959041cf4 100644
--- a/Library/Homebrew/test/requirement_spec.rb
+++ b/Library/Homebrew/test/requirement_spec.rb
@@ -146,17 +146,13 @@ describe Requirement do
end
describe "#build?" do
- context "#build true is specified" do
- let(:klass) do
- Class.new(described_class) do
- build true
- end
- end
+ context ":build tag is specified" do
+ subject { described_class.new([:build]) }
it { is_expected.to be_a_build_requirement }
end
- context "#build ommitted" do
+ context "#build omitted" do
it { is_expected.not_to be_a_build_requirement }
end
end
diff --git a/Library/Homebrew/test/spec_helper.rb b/Library/Homebrew/test/spec_helper.rb
index 005c6d2fb..e193b91a0 100644
--- a/Library/Homebrew/test/spec_helper.rb
+++ b/Library/Homebrew/test/spec_helper.rb
@@ -93,6 +93,7 @@ RSpec.configure do |config|
HOMEBREW_PREFIX/"opt",
HOMEBREW_PREFIX/"Caskroom",
HOMEBREW_LIBRARY/"Taps/caskroom",
+ HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-bar",
HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-bundle",
HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-foo",
HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-services",
diff --git a/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb b/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb
index b037068d2..ae1854f58 100644
--- a/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb
+++ b/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb
@@ -72,6 +72,7 @@ RSpec.shared_context "integration test" do
env.merge!(
"PATH" => path,
+ "HOMEBREW_PATH" => path,
"HOMEBREW_BREW_FILE" => HOMEBREW_PREFIX/"bin/brew",
"HOMEBREW_INTEGRATION_TEST" => command_id_from_args(args),
"HOMEBREW_TEST_TMPDIR" => TEST_TMPDIR,
diff --git a/Library/Homebrew/test/utils/shell_spec.rb b/Library/Homebrew/test/utils/shell_spec.rb
index c44bd8253..d32f9928f 100644
--- a/Library/Homebrew/test/utils/shell_spec.rb
+++ b/Library/Homebrew/test/utils/shell_spec.rb
@@ -1,92 +1,92 @@
require "utils/shell"
describe Utils::Shell do
- describe "::shell_profile" do
+ describe "::profile" do
it "returns ~/.bash_profile by default" do
ENV["SHELL"] = "/bin/another_shell"
- expect(subject.shell_profile).to eq("~/.bash_profile")
+ expect(subject.profile).to eq("~/.bash_profile")
end
it "returns ~/.bash_profile for Sh" do
ENV["SHELL"] = "/bin/another_shell"
- expect(subject.shell_profile).to eq("~/.bash_profile")
+ expect(subject.profile).to eq("~/.bash_profile")
end
it "returns ~/.bash_profile for Bash" do
ENV["SHELL"] = "/bin/bash"
- expect(subject.shell_profile).to eq("~/.bash_profile")
+ expect(subject.profile).to eq("~/.bash_profile")
end
it "returns ~/.zshrc for Zsh" do
ENV["SHELL"] = "/bin/zsh"
- expect(subject.shell_profile).to eq("~/.zshrc")
+ expect(subject.profile).to eq("~/.zshrc")
end
it "returns ~/.kshrc for Ksh" do
ENV["SHELL"] = "/bin/ksh"
- expect(subject.shell_profile).to eq("~/.kshrc")
+ expect(subject.profile).to eq("~/.kshrc")
end
end
- describe "::path_to_shell" do
+ describe "::from_path" do
it "supports a raw command name" do
- expect(subject.path_to_shell("bash")).to eq(:bash)
+ expect(subject.from_path("bash")).to eq(:bash)
end
it "supports full paths" do
- expect(subject.path_to_shell("/bin/bash")).to eq(:bash)
+ expect(subject.from_path("/bin/bash")).to eq(:bash)
end
it "supports versions" do
- expect(subject.path_to_shell("zsh-5.2")).to eq(:zsh)
+ expect(subject.from_path("zsh-5.2")).to eq(:zsh)
end
it "strips newlines" do
- expect(subject.path_to_shell("zsh-5.2\n")).to eq(:zsh)
+ expect(subject.from_path("zsh-5.2\n")).to eq(:zsh)
end
it "returns nil when input is invalid" do
- expect(subject.path_to_shell("")).to be nil
- expect(subject.path_to_shell("@@@@@@")).to be nil
- expect(subject.path_to_shell("invalid_shell-4.2")).to be nil
+ expect(subject.from_path("")).to be nil
+ expect(subject.from_path("@@@@@@")).to be nil
+ expect(subject.from_path("invalid_shell-4.2")).to be nil
end
end
specify "::sh_quote" do
- expect(subject.sh_quote("")).to eq("''")
- expect(subject.sh_quote("\\")).to eq("\\\\")
- expect(subject.sh_quote("\n")).to eq("'\n'")
- expect(subject.sh_quote("$")).to eq("\\$")
- expect(subject.sh_quote("word")).to eq("word")
+ expect(subject.send(:sh_quote, "")).to eq("''")
+ expect(subject.send(:sh_quote, "\\")).to eq("\\\\")
+ expect(subject.send(:sh_quote, "\n")).to eq("'\n'")
+ expect(subject.send(:sh_quote, "$")).to eq("\\$")
+ expect(subject.send(:sh_quote, "word")).to eq("word")
end
specify "::csh_quote" do
- expect(subject.csh_quote("")).to eq("''")
- expect(subject.csh_quote("\\")).to eq("\\\\")
+ expect(subject.send(:csh_quote, "")).to eq("''")
+ expect(subject.send(:csh_quote, "\\")).to eq("\\\\")
# note this test is different than for sh
- expect(subject.csh_quote("\n")).to eq("'\\\n'")
- expect(subject.csh_quote("$")).to eq("\\$")
- expect(subject.csh_quote("word")).to eq("word")
+ expect(subject.send(:csh_quote, "\n")).to eq("'\\\n'")
+ expect(subject.send(:csh_quote, "$")).to eq("\\$")
+ expect(subject.send(:csh_quote, "word")).to eq("word")
end
- describe "::prepend_path_in_shell_profile" do
+ describe "::prepend_path_in_profile" do
let(:path) { "/my/path" }
it "supports Tcsh" do
ENV["SHELL"] = "/bin/tcsh"
- expect(subject.prepend_path_in_shell_profile(path))
+ expect(subject.prepend_path_in_profile(path))
.to start_with("echo 'setenv PATH #{path}:$")
end
it "supports Bash" do
ENV["SHELL"] = "/bin/bash"
- expect(subject.prepend_path_in_shell_profile(path))
+ expect(subject.prepend_path_in_profile(path))
.to start_with("echo 'export PATH=\"#{path}:$")
end
it "supports Fish" do
ENV["SHELL"] = "/usr/local/bin/fish"
- expect(subject.prepend_path_in_shell_profile(path))
+ expect(subject.prepend_path_in_profile(path))
.to start_with("echo 'set -g fish_user_paths \"#{path}\" $fish_user_paths' >>")
end
end
diff --git a/Library/Homebrew/test/utils_spec.rb b/Library/Homebrew/test/utils_spec.rb
index dd7ea20de..ffaa1f493 100644
--- a/Library/Homebrew/test/utils_spec.rb
+++ b/Library/Homebrew/test/utils_spec.rb
@@ -191,7 +191,7 @@ describe "globally-scoped helper methods" do
ENV["HOMEBREW_EDITOR"] = "vemate"
ENV["HOMEBREW_PATH"] = dir
- editor = dir/"vemate"
+ editor = "#{dir}/vemate"
FileUtils.touch editor
FileUtils.chmod 0755, editor
@@ -270,4 +270,12 @@ describe "globally-scoped helper methods" do
}.to raise_error(MethodDeprecatedError, %r{method.*replacement.*homebrew/homebrew-core.*homebrew/core}m)
end
end
+
+ describe "#puts_hash" do
+ it "outputs a hash" do
+ expect {
+ puts_hash(a: 1, b: 2, c: [3, { "d"=>4 }])
+ }.to output("a: 1\nb: 2\nc: [3, {\"d\"=>4}]\n").to_stdout
+ end
+ end
end
diff --git a/Library/Homebrew/test/version_spec.rb b/Library/Homebrew/test/version_spec.rb
index d3d63a25c..41e05019c 100644
--- a/Library/Homebrew/test/version_spec.rb
+++ b/Library/Homebrew/test/version_spec.rb
@@ -433,6 +433,11 @@ describe Version do
.to be_detected_from("https://homebrew.bintray.com/bottles/imagemagick-6.7.5-7.lion.bottle.1.tar.gz")
end
+ specify "date-based version style" do
+ expect(Version.create("2017-04-17"))
+ .to be_detected_from("https://example.com/dada-v2017-04-17.tar.gz")
+ end
+
specify "dash version style" do
expect(Version.create("3.4"))
.to be_detected_from("http://www.antlr.org/download/antlr-3.4-complete.jar")