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

Make Cask tests work without tapping `caskroom/cask`.

parent a1fbb102
No related branches found
No related tags found
No related merge requests found
......@@ -22,33 +22,33 @@ describe Hbc::Cask do
end
describe "load" do
let(:hbc_relative_tap_path) { "../../Taps/caskroom/homebrew-cask" }
let(:tap_path) { Hbc.default_tap.path }
let(:file_dirname) { Pathname.new(__FILE__).dirname }
let(:relative_tap_path) { tap_path.relative_path_from(file_dirname) }
it "returns an instance of the Cask for the given token" do
c = Hbc.load("adium")
c = Hbc.load("local-caffeine")
expect(c).to be_kind_of(Hbc::Cask)
expect(c.token).to eq("adium")
expect(c.token).to eq("local-caffeine")
end
it "returns an instance of the Cask from a specific file location" do
location = File.expand_path(hbc_relative_tap_path + "/Casks/dia.rb")
c = Hbc.load(location)
c = Hbc.load("#{tap_path}/Casks/local-caffeine.rb")
expect(c).to be_kind_of(Hbc::Cask)
expect(c.token).to eq("dia")
expect(c.token).to eq("local-caffeine")
end
it "returns an instance of the Cask from a url" do
url = "file://" + File.expand_path(hbc_relative_tap_path + "/Casks/dia.rb")
c = shutup do
Hbc.load(url)
Hbc.load("file://#{tap_path}/Casks/local-caffeine.rb")
end
expect(c).to be_kind_of(Hbc::Cask)
expect(c.token).to eq("dia")
expect(c.token).to eq("local-caffeine")
end
it "raises an error when failing to download a Cask from a url" do
expect {
url = "file://" + File.expand_path(hbc_relative_tap_path + "/Casks/notacask.rb")
url = "file://#{tap_path}/Casks/notacask.rb"
shutup do
Hbc.load(url)
end
......@@ -56,9 +56,9 @@ describe Hbc::Cask do
end
it "returns an instance of the Cask from a relative file location" do
c = Hbc.load(hbc_relative_tap_path + "/Casks/bbedit.rb")
c = Hbc.load(relative_tap_path/"Casks/local-caffeine.rb")
expect(c).to be_kind_of(Hbc::Cask)
expect(c.token).to eq("bbedit")
expect(c.token).to eq("local-caffeine")
end
it "uses exact match when loading by token" do
......@@ -83,7 +83,7 @@ describe Hbc::Cask do
describe "metadata" do
it "proposes a versioned metadata directory name for each instance" do
cask_token = "adium"
cask_token = "local-caffeine"
c = Hbc.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)
......
......@@ -64,21 +64,21 @@ describe Hbc::CLI::Install do
it "returns a suggestion for a misspelled Cask" do
expect {
begin
Hbc::CLI::Install.run("googlechrome")
Hbc::CLI::Install.run("localcaffeine")
rescue Hbc::CaskError
nil
end
}.to output(/No available Cask for googlechrome\. Did you mean:\ngoogle-chrome/).to_stderr
}.to output(/No available Cask for localcaffeine\. Did you mean:\nlocal-caffeine/).to_stderr
end
it "returns multiple suggestions for a Cask fragment" do
expect {
begin
Hbc::CLI::Install.run("google")
Hbc::CLI::Install.run("local-caf")
rescue Hbc::CaskError
nil
end
}.to output(/No available Cask for google\. Did you mean one of:\ngoogle/).to_stderr
}.to output(/No available Cask for local-caf\. Did you mean one of:\nlocal-caffeine/).to_stderr
end
describe "when no Cask is specified" do
......
......@@ -3,11 +3,11 @@ require "spec_helper"
describe Hbc::CLI::Search do
it "lists the available Casks that match the search term" do
expect {
Hbc::CLI::Search.run("photoshop")
Hbc::CLI::Search.run("local")
}.to output(<<-EOS.undent).to_stdout
==> Partial matches
adobe-photoshop-cc
adobe-photoshop-lightroom
local-caffeine
local-transmission
EOS
end
......@@ -20,37 +20,37 @@ describe Hbc::CLI::Search do
it "lists all available Casks with no search term" do
expect {
Hbc::CLI::Search.run
}.to output(/google-chrome/).to_stdout
}.to output(/local-caffeine/).to_stdout
end
it "ignores hyphens in search terms" do
expect {
Hbc::CLI::Search.run("goo-gle-chrome")
}.to output(/google-chrome/).to_stdout
Hbc::CLI::Search.run("lo-cal-caffeine")
}.to output(/local-caffeine/).to_stdout
end
it "ignores hyphens in Cask tokens" do
expect {
Hbc::CLI::Search.run("googlechrome")
}.to output(/google-chrome/).to_stdout
Hbc::CLI::Search.run("localcaffeine")
}.to output(/local-caffeine/).to_stdout
end
it "accepts multiple arguments" do
expect {
Hbc::CLI::Search.run("google chrome")
}.to output(/google-chrome/).to_stdout
Hbc::CLI::Search.run("local caffeine")
}.to output(/local-caffeine/).to_stdout
end
it "accepts a regexp argument" do
expect {
Hbc::CLI::Search.run("/^google-c[a-z]rome$/")
}.to output("==> Regexp matches\ngoogle-chrome\n").to_stdout
Hbc::CLI::Search.run("/^local-c[a-z]ffeine$/")
}.to output("==> Regexp matches\nlocal-caffeine\n").to_stdout
end
it "Returns both exact and partial matches" do
expect {
Hbc::CLI::Search.run("mnemosyne")
}.to output(/^==> Exact match\nmnemosyne\n==> Partial matches\nsubclassed-mnemosyne/).to_stdout
Hbc::CLI::Search.run("test-opera")
}.to output(/^==> Exact match\ntest-opera\n==> Partial matches\ntest-opera-mail/).to_stdout
end
it "does not search the Tap name" do
......
......@@ -9,13 +9,13 @@ describe Hbc::CLI::Uninstall do
it "shows an error when a Cask is provided that's not installed" do
expect {
Hbc::CLI::Uninstall.run("anvil")
Hbc::CLI::Uninstall.run("local-caffeine")
}.to raise_error(Hbc::CaskNotInstalledError)
end
it "tries anyway on a non-present Cask when --force is given" do
expect {
Hbc::CLI::Uninstall.run("anvil", "--force")
Hbc::CLI::Uninstall.run("local-caffeine", "--force")
}.not_to raise_error
end
......
......@@ -27,9 +27,6 @@ Hbc.default_tap = Tap.fetch("caskroom", "spec").tap do |tap|
FileUtils.ln_s TEST_FIXTURE_DIR.join("cask"), tap.path
end
# pretend that the caskroom/cask Tap is installed
FileUtils.ln_s Pathname.new(ENV["HOMEBREW_LIBRARY"]).join("Taps", "caskroom", "homebrew-cask"), Tap.fetch("caskroom", "cask").path
HOMEBREW_CASK_DIRS = [
:appdir,
:caskroom,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment