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

Simplify spec helper.

parent a9e538ef
No related branches found
No related tags found
No related merge requests found
...@@ -34,16 +34,26 @@ end ...@@ -34,16 +34,26 @@ end
# pretend that the caskroom/cask Tap is installed # 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 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| RSpec.configure do |config|
config.order = :random config.order = :random
config.include(Test::Helper::Shutup) config.include(Test::Helper::Shutup)
config.around(:each) do |example| config.around(:each) do |example|
begin begin
@__appdir = Hbc.appdir @__dirs = HOMEBREW_CASK_DIRS.map { |dir|
@__caskroom = Hbc.caskroom Pathname.new(TEST_TMPDIR).join(dir.to_s).tap { |path|
@__prefpanedir = Hbc.prefpanedir path.mkpath
@__qlplugindir = Hbc.qlplugindir Hbc.public_send("#{dir}=", path)
@__servicedir = Hbc.servicedir }
}
@__argv = ARGV.dup @__argv = ARGV.dup
@__env = ENV.to_hash # dup doesn't work on ENV @__env = ENV.to_hash # dup doesn't work on ENV
...@@ -53,16 +63,7 @@ RSpec.configure do |config| ...@@ -53,16 +63,7 @@ RSpec.configure do |config|
ARGV.replace(@__argv) ARGV.replace(@__argv)
ENV.replace(@__env) ENV.replace(@__env)
Hbc.appdir = @__appdir FileUtils.rm_rf @__dirs.map(&:children)
Hbc.caskroom = @__caskroom
Hbc.prefpanedir = @__prefpanedir
Hbc.qlplugindir = @__qlplugindir
Hbc.servicedir = @__servicedir
FileUtils.rm_rf [
Hbc.appdir.children,
Hbc.caskroom.children,
]
end end
end end
end end
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