From a5549023804a8cef50f71dc2d7a723be8e83f3d1 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Tue, 28 Feb 2017 14:50:46 +0100 Subject: Add `mktmpdir` helper method. --- Library/Homebrew/test/cmd/bundle_spec.rb | 4 ++-- Library/Homebrew/test/cmd/commands_spec.rb | 2 +- Library/Homebrew/test/cmd/custom-external-command_spec.rb | 4 +--- Library/Homebrew/test/cmd/linkapps_spec.rb | 6 +----- Library/Homebrew/test/cmd/unlinkapps_spec.rb | 6 +----- Library/Homebrew/test/cmd/unpack_spec.rb | 4 +--- 6 files changed, 7 insertions(+), 19 deletions(-) (limited to 'Library/Homebrew/test/cmd') diff --git a/Library/Homebrew/test/cmd/bundle_spec.rb b/Library/Homebrew/test/cmd/bundle_spec.rb index 755f9ab3d..13f13485c 100644 --- a/Library/Homebrew/test/cmd/bundle_spec.rb +++ b/Library/Homebrew/test/cmd/bundle_spec.rb @@ -10,9 +10,9 @@ describe "brew bundle", :integration_test, :needs_test_cmd_taps do end end - Dir.mktmpdir do |path| + mktmpdir do |path| FileUtils.touch "#{path}/Brewfile" - Dir.chdir path do + path.cd do expect { brew "bundle", "check" } .to output("The Brewfile's dependencies are satisfied.\n").to_stdout .and not_to_output.to_stderr diff --git a/Library/Homebrew/test/cmd/commands_spec.rb b/Library/Homebrew/test/cmd/commands_spec.rb index 32d07a0bc..cf6f56740 100644 --- a/Library/Homebrew/test/cmd/commands_spec.rb +++ b/Library/Homebrew/test/cmd/commands_spec.rb @@ -54,7 +54,7 @@ describe Homebrew do end specify "::external_commands" do - Dir.mktmpdir do |dir| + mktmpdir do |dir| %w[brew-t1 brew-t2.rb brew-t3.py].each do |file| path = "#{dir}/#{file}" FileUtils.touch path diff --git a/Library/Homebrew/test/cmd/custom-external-command_spec.rb b/Library/Homebrew/test/cmd/custom-external-command_spec.rb index 8ccc21fa7..d649786ec 100644 --- a/Library/Homebrew/test/cmd/custom-external-command_spec.rb +++ b/Library/Homebrew/test/cmd/custom-external-command_spec.rb @@ -1,8 +1,6 @@ describe "brew custom-external-command", :integration_test do it "is supported" do - Dir.mktmpdir do |path| - path = Pathname.new(path) - + mktmpdir do |path| cmd = "custom-external-command-#{rand}" file = path/"brew-#{cmd}" diff --git a/Library/Homebrew/test/cmd/linkapps_spec.rb b/Library/Homebrew/test/cmd/linkapps_spec.rb index 42118a215..2bca97822 100644 --- a/Library/Homebrew/test/cmd/linkapps_spec.rb +++ b/Library/Homebrew/test/cmd/linkapps_spec.rb @@ -1,11 +1,7 @@ describe "brew linkapps", :integration_test do - let(:home_dir) { @home_dir = Pathname.new(Dir.mktmpdir) } + let(:home_dir) { mktmpdir } let(:apps_dir) { home_dir/"Applications" } - after(:each) do - home_dir.rmtree unless @home_dir.nil? - end - it "symlinks applications" do apps_dir.mkpath diff --git a/Library/Homebrew/test/cmd/unlinkapps_spec.rb b/Library/Homebrew/test/cmd/unlinkapps_spec.rb index 1e21bd851..e1170f435 100644 --- a/Library/Homebrew/test/cmd/unlinkapps_spec.rb +++ b/Library/Homebrew/test/cmd/unlinkapps_spec.rb @@ -1,11 +1,7 @@ describe "brew unlinkapps", :integration_test do - let(:home_dir) { @home_dir = Pathname.new(Dir.mktmpdir) } + let(:home_dir) { mktmpdir } let(:apps_dir) { home_dir/"Applications" } - after(:each) do - home_dir.rmtree unless @home_dir.nil? - end - it "unlinks symlinked applications" do apps_dir.mkpath diff --git a/Library/Homebrew/test/cmd/unpack_spec.rb b/Library/Homebrew/test/cmd/unpack_spec.rb index 244fc0852..9b2b801bc 100644 --- a/Library/Homebrew/test/cmd/unpack_spec.rb +++ b/Library/Homebrew/test/cmd/unpack_spec.rb @@ -2,9 +2,7 @@ describe "brew unpack", :integration_test do it "unpacks a given Formula's archive" do setup_test_formula "testball" - Dir.mktmpdir do |path| - path = Pathname.new(path) - + mktmpdir do |path| shutup do expect { brew "unpack", "testball", "--destdir=#{path}" } .to be_a_success -- cgit v1.2.3