aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMarkus Reiter2017-02-09 04:37:24 +0100
committerMarkus Reiter2017-02-10 17:19:19 +0100
commitb9de5c04908bbbe2e2c30fff57b1301e17082202 (patch)
treee03e7ee706007f4a1ac265b14af99f1920c02851 /Library
parenta9e538efbdb0532e9236400434c9970e0cdfd8fc (diff)
downloadbrew-b9de5c04908bbbe2e2c30fff57b1301e17082202.tar.bz2
Simplify spec helper.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cask/spec/spec_helper.rb31
1 files changed, 16 insertions, 15 deletions
diff --git a/Library/Homebrew/cask/spec/spec_helper.rb b/Library/Homebrew/cask/spec/spec_helper.rb
index 8b0720e86..ea6a87f41 100644
--- a/Library/Homebrew/cask/spec/spec_helper.rb
+++ b/Library/Homebrew/cask/spec/spec_helper.rb
@@ -34,16 +34,26 @@ 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,
+ :prefpanedir,
+ :qlplugindir,
+ :servicedir,
+ :binarydir,
+].freeze
+
RSpec.configure do |config|
config.order = :random
config.include(Test::Helper::Shutup)
config.around(:each) do |example|
begin
- @__appdir = Hbc.appdir
- @__caskroom = Hbc.caskroom
- @__prefpanedir = Hbc.prefpanedir
- @__qlplugindir = Hbc.qlplugindir
- @__servicedir = Hbc.servicedir
+ @__dirs = HOMEBREW_CASK_DIRS.map { |dir|
+ Pathname.new(TEST_TMPDIR).join(dir.to_s).tap { |path|
+ path.mkpath
+ Hbc.public_send("#{dir}=", path)
+ }
+ }
@__argv = ARGV.dup
@__env = ENV.to_hash # dup doesn't work on ENV
@@ -53,16 +63,7 @@ RSpec.configure do |config|
ARGV.replace(@__argv)
ENV.replace(@__env)
- Hbc.appdir = @__appdir
- Hbc.caskroom = @__caskroom
- Hbc.prefpanedir = @__prefpanedir
- Hbc.qlplugindir = @__qlplugindir
- Hbc.servicedir = @__servicedir
-
- FileUtils.rm_rf [
- Hbc.appdir.children,
- Hbc.caskroom.children,
- ]
+ FileUtils.rm_rf @__dirs.map(&:children)
end
end
end