diff options
| author | Markus Reiter | 2017-12-03 09:06:23 +0100 |
|---|---|---|
| committer | Markus Reiter | 2018-01-27 21:47:18 +0100 |
| commit | 6760d26319c6fcbf8ba74bd737530adc7831da22 (patch) | |
| tree | ac7fefe897fa1bc4eb50f74959fb215f292bd441 /Library/Homebrew/test/support | |
| parent | d558ec09332c74927dfb9182b19e11c5a73d8b52 (diff) | |
| download | brew-6760d26319c6fcbf8ba74bd737530adc7831da22.tar.bz2 | |
Create `Hbc::Config` class.
Diffstat (limited to 'Library/Homebrew/test/support')
4 files changed, 19 insertions, 18 deletions
diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/generic-artifact-absolute-target.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/generic-artifact-absolute-target.rb index a1844a9c9..dc73ab773 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/generic-artifact-absolute-target.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/generic-artifact-absolute-target.rb @@ -1,3 +1,3 @@ cask 'generic-artifact-absolute-target' do - artifact 'Caffeine.app', target: "#{Hbc.appdir}/Caffeine.app" + artifact 'Caffeine.app', target: "#{Hbc::Config.global.appdir}/Caffeine.app" end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-generic-artifact.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-generic-artifact.rb index d6ce0ce8d..40c0da95a 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-generic-artifact.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-generic-artifact.rb @@ -5,5 +5,5 @@ cask 'with-generic-artifact' do url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" homepage 'http://example.com/with-generic-artifact' - artifact 'Caffeine.app', target: "#{Hbc.appdir}/Caffeine.app" + artifact 'Caffeine.app', target: "#{Hbc::Config.global.appdir}/Caffeine.app" end diff --git a/Library/Homebrew/test/support/helper/spec/shared_context/homebrew_cask.rb b/Library/Homebrew/test/support/helper/spec/shared_context/homebrew_cask.rb index e1afc44bf..46303a46e 100644 --- a/Library/Homebrew/test/support/helper/spec/shared_context/homebrew_cask.rb +++ b/Library/Homebrew/test/support/helper/spec/shared_context/homebrew_cask.rb @@ -6,25 +6,26 @@ require "test/support/helper/cask/fake_system_command" require "test/support/helper/cask/install_helper" require "test/support/helper/cask/never_sudo_system_command" -HOMEBREW_CASK_DIRS = [ - :appdir, - :prefpanedir, - :qlplugindir, - :servicedir, -].freeze +HOMEBREW_CASK_DIRS = { + :appdir => Pathname.new(TEST_TMPDIR).join("cask-appdir"), + :prefpanedir => Pathname.new(TEST_TMPDIR).join("cask-prefpanedir"), + :qlplugindir => Pathname.new(TEST_TMPDIR).join("cask-qlplugindir"), + :servicedir => Pathname.new(TEST_TMPDIR).join("cask-servicedir"), +}.freeze RSpec.shared_context "Homebrew-Cask" do + before(:each) do + HOMEBREW_CASK_DIRS.each do |method, path| + allow(Hbc::Config.global).to receive(method).and_return(path) + end + end + around(:each) do |example| third_party_tap = Tap.fetch("third-party", "tap") begin - [Hbc.binarydir, Hbc.caskroom, Hbc.cache].each(&:mkpath) + HOMEBREW_CASK_DIRS.values.each(&:mkpath) - dirs = HOMEBREW_CASK_DIRS.map do |dir| - Pathname.new(TEST_TMPDIR).join("cask-#{dir}").tap do |path| - path.mkpath - Hbc.public_send("#{dir}=", path) - end - end + [Hbc::Config.global.binarydir, Hbc.caskroom, Hbc.cache].each(&:mkpath) Hbc.default_tap = Tap.fetch("caskroom", "spec").tap do |tap| FileUtils.mkdir_p tap.path.dirname @@ -38,8 +39,8 @@ RSpec.shared_context "Homebrew-Cask" do example.run ensure - FileUtils.rm_rf dirs - FileUtils.rm_rf [Hbc.binarydir, Hbc.caskroom, Hbc.cache] + FileUtils.rm_rf HOMEBREW_CASK_DIRS.values + FileUtils.rm_rf [Hbc::Config.global.binarydir, Hbc.caskroom, Hbc.cache] Hbc.default_tap.path.unlink FileUtils.rm_rf Hbc.default_tap.path.parent third_party_tap.path.unlink diff --git a/Library/Homebrew/test/support/helper/spec/shared_examples/hbc_staged.rb b/Library/Homebrew/test/support/helper/spec/shared_examples/hbc_staged.rb index 361179b9e..e7fa172c4 100644 --- a/Library/Homebrew/test/support/helper/spec/shared_examples/hbc_staged.rb +++ b/Library/Homebrew/test/support/helper/spec/shared_examples/hbc_staged.rb @@ -22,7 +22,7 @@ shared_examples Hbc::Staged do end it "can get the Info.plist file for the primary app" do - expect(staged.info_plist_file).to eq Hbc.appdir.join("TestCask.app/Contents/Info.plist") + expect(staged.info_plist_file).to eq Hbc::Config.global.appdir.join("TestCask.app/Contents/Info.plist") end it "can execute commands on the Info.plist file" do |
