diff options
| author | Markus Reiter | 2017-03-05 00:31:26 +0100 |
|---|---|---|
| committer | GitHub | 2017-03-05 00:31:26 +0100 |
| commit | f84ad9ca2ea0e86a2ba43c8b4b9cdffd0a707f5a (patch) | |
| tree | 598f02608e173028d4f2f6b2c6e2950a343b6361 /Library | |
| parent | 370c711da23fa0f7c7944f7d15928e44a67656a9 (diff) | |
| parent | 80be26fd8b1c572d80d2c323eec9ce640726a8b0 (diff) | |
| download | brew-f84ad9ca2ea0e86a2ba43c8b4b9cdffd0a707f5a.tar.bz2 | |
Merge pull request #2256 from reitermarkus/spec-cask
Make Cask tests work without tapping `caskroom/cask`.
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/locations.rb | 8 | ||||
| -rw-r--r-- | Library/Homebrew/cask/spec/cask/cask_spec.rb | 26 | ||||
| -rw-r--r-- | Library/Homebrew/cask/spec/cask/cli/install_spec.rb | 8 | ||||
| -rw-r--r-- | Library/Homebrew/cask/spec/cask/cli/search_spec.rb | 28 | ||||
| -rw-r--r-- | Library/Homebrew/cask/spec/cask/cli/uninstall_spec.rb | 4 | ||||
| -rw-r--r-- | Library/Homebrew/cask/spec/spec_helper.rb | 8 |
6 files changed, 38 insertions, 44 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/locations.rb b/Library/Homebrew/cask/lib/hbc/locations.rb index 292b45d0c..4fb4a2191 100644 --- a/Library/Homebrew/cask/lib/hbc/locations.rb +++ b/Library/Homebrew/cask/lib/hbc/locations.rb @@ -15,6 +15,8 @@ module Hbc @default_caskroom ||= HOMEBREW_PREFIX.join("Caskroom") end + attr_writer :caskroom + def caskroom @caskroom ||= begin if Utils.path_occupied?(legacy_caskroom) @@ -36,14 +38,12 @@ module Hbc end end - def caskroom=(caskroom) - @caskroom = caskroom - end - def legacy_cache @legacy_cache ||= HOMEBREW_CACHE.join("Casks") end + attr_writer :cache + def cache @cache ||= HOMEBREW_CACHE.join("Cask") end diff --git a/Library/Homebrew/cask/spec/cask/cask_spec.rb b/Library/Homebrew/cask/spec/cask/cask_spec.rb index 32f3d8258..b926be627 100644 --- a/Library/Homebrew/cask/spec/cask/cask_spec.rb +++ b/Library/Homebrew/cask/spec/cask/cask_spec.rb @@ -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) diff --git a/Library/Homebrew/cask/spec/cask/cli/install_spec.rb b/Library/Homebrew/cask/spec/cask/cli/install_spec.rb index 07aa78aa3..2544eacc8 100644 --- a/Library/Homebrew/cask/spec/cask/cli/install_spec.rb +++ b/Library/Homebrew/cask/spec/cask/cli/install_spec.rb @@ -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 diff --git a/Library/Homebrew/cask/spec/cask/cli/search_spec.rb b/Library/Homebrew/cask/spec/cask/cli/search_spec.rb index fe669dd3e..b05d3fbde 100644 --- a/Library/Homebrew/cask/spec/cask/cli/search_spec.rb +++ b/Library/Homebrew/cask/spec/cask/cli/search_spec.rb @@ -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 diff --git a/Library/Homebrew/cask/spec/cask/cli/uninstall_spec.rb b/Library/Homebrew/cask/spec/cask/cli/uninstall_spec.rb index a1b47e823..f451af277 100644 --- a/Library/Homebrew/cask/spec/cask/cli/uninstall_spec.rb +++ b/Library/Homebrew/cask/spec/cask/cli/uninstall_spec.rb @@ -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 diff --git a/Library/Homebrew/cask/spec/spec_helper.rb b/Library/Homebrew/cask/spec/spec_helper.rb index ea6a87f41..985a5335f 100644 --- a/Library/Homebrew/cask/spec/spec_helper.rb +++ b/Library/Homebrew/cask/spec/spec_helper.rb @@ -1,4 +1,3 @@ -require "pathname" require "rspec/its" require "rspec/wait" @@ -22,21 +21,16 @@ Pathname.glob(HOMEBREW_LIBRARY_PATH.join("cask", "spec", "support", "**", "*.rb" require "hbc" # create and override default directories -Hbc.appdir = Pathname.new(TEST_TMPDIR).join("Applications").tap(&:mkpath) -Hbc.cache.mkpath -Hbc.caskroom = Hbc.default_caskroom.tap(&:mkpath) Hbc.default_tap = Tap.fetch("caskroom", "spec").tap do |tap| # link test casks FileUtils.mkdir_p tap.path.dirname 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, + :cache, :prefpanedir, :qlplugindir, :servicedir, |
