aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test
diff options
context:
space:
mode:
authorJack Nagel2015-03-25 21:11:51 -0400
committerJack Nagel2015-03-25 21:11:51 -0400
commit53b7d45de8f38d1998e5c23a77064ae3df4be522 (patch)
treef7fa617f8fe057fe8e0784c680482d782dc50c26 /Library/Homebrew/test
parent617544694c5ee03a2b79708c80ab862e42144e8b (diff)
downloadbrew-53b7d45de8f38d1998e5c23a77064ae3df4be522.tar.bz2
Do less work inside chdir blocks
Diffstat (limited to 'Library/Homebrew/test')
-rw-r--r--Library/Homebrew/test/test_pathname.rb75
1 files changed, 35 insertions, 40 deletions
diff --git a/Library/Homebrew/test/test_pathname.rb b/Library/Homebrew/test/test_pathname.rb
index 06e676d76..c59571305 100644
--- a/Library/Homebrew/test/test_pathname.rb
+++ b/Library/Homebrew/test/test_pathname.rb
@@ -96,100 +96,95 @@ class PathnameExtensionTests < Homebrew::TestCase
end
def setup_install_test
- cd @src do
- (@src+'a.txt').write 'This is sample file a.'
- (@src+'b.txt').write 'This is sample file b.'
- yield
- end
+ (@src+'a.txt').write 'This is sample file a.'
+ (@src+'b.txt').write 'This is sample file b.'
+ cd(@src) { yield }
end
def test_install
setup_install_test do
@dst.install 'a.txt'
-
- assert_predicate @dst+"a.txt", :exist?, "a.txt was not installed"
- refute_predicate @dst+"b.txt", :exist?, "b.txt was installed."
end
+
+ assert_predicate @dst+"a.txt", :exist?, "a.txt was not installed"
+ refute_predicate @dst+"b.txt", :exist?, "b.txt was installed."
end
def test_install_list
setup_install_test do
@dst.install %w[a.txt b.txt]
-
- assert_predicate @dst+"a.txt", :exist?, "a.txt was not installed"
- assert_predicate @dst+"b.txt", :exist?, "b.txt was not installed"
end
+
+ assert_predicate @dst+"a.txt", :exist?, "a.txt was not installed"
+ assert_predicate @dst+"b.txt", :exist?, "b.txt was not installed"
end
def test_install_glob
setup_install_test do
@dst.install Dir['*.txt']
-
- assert_predicate @dst+"a.txt", :exist?, "a.txt was not installed"
- assert_predicate @dst+"b.txt", :exist?, "b.txt was not installed"
end
+
+ assert_predicate @dst+"a.txt", :exist?, "a.txt was not installed"
+ assert_predicate @dst+"b.txt", :exist?, "b.txt was not installed"
end
def test_install_directory
setup_install_test do
mkdir_p 'bin'
mv Dir['*.txt'], 'bin'
-
@dst.install 'bin'
-
- assert_predicate @dst+"bin/a.txt", :exist?, "a.txt was not installed"
- assert_predicate @dst+"bin/b.txt", :exist?, "b.txt was not installed"
end
+
+ assert_predicate @dst+"bin/a.txt", :exist?, "a.txt was not installed"
+ assert_predicate @dst+"bin/b.txt", :exist?, "b.txt was not installed"
end
def test_install_rename
setup_install_test do
@dst.install 'a.txt' => 'c.txt'
-
- assert_predicate @dst+"c.txt", :exist?, "c.txt was not installed"
- refute_predicate @dst+"a.txt", :exist?, "a.txt was installed but not renamed"
- refute_predicate @dst+"b.txt", :exist?, "b.txt was installed"
end
+
+ assert_predicate @dst+"c.txt", :exist?, "c.txt was not installed"
+ refute_predicate @dst+"a.txt", :exist?, "a.txt was installed but not renamed"
+ refute_predicate @dst+"b.txt", :exist?, "b.txt was installed"
end
def test_install_rename_more
setup_install_test do
@dst.install({'a.txt' => 'c.txt', 'b.txt' => 'd.txt'})
-
- assert_predicate @dst+"c.txt", :exist?, "c.txt was not installed"
- assert_predicate @dst+"d.txt", :exist?, "d.txt was not installed"
- refute_predicate @dst+"a.txt", :exist?, "a.txt was installed but not renamed"
- refute_predicate @dst+"b.txt", :exist?, "b.txt was installed but not renamed"
end
+
+ assert_predicate @dst+"c.txt", :exist?, "c.txt was not installed"
+ assert_predicate @dst+"d.txt", :exist?, "d.txt was not installed"
+ refute_predicate @dst+"a.txt", :exist?, "a.txt was installed but not renamed"
+ refute_predicate @dst+"b.txt", :exist?, "b.txt was installed but not renamed"
end
def test_install_rename_directory
setup_install_test do
mkdir_p 'bin'
mv Dir['*.txt'], 'bin'
-
@dst.install 'bin' => 'libexec'
-
- refute_predicate @dst+"bin", :exist?, "bin was installed but not renamed"
- assert_predicate @dst+"libexec/a.txt", :exist?, "a.txt was not installed"
- assert_predicate @dst+"libexec/b.txt", :exist?, "b.txt was not installed"
end
+
+ refute_predicate @dst+"bin", :exist?, "bin was installed but not renamed"
+ assert_predicate @dst+"libexec/a.txt", :exist?, "a.txt was not installed"
+ assert_predicate @dst+"libexec/b.txt", :exist?, "b.txt was not installed"
end
def test_install_symlink
setup_install_test do
mkdir_p 'bin'
mv Dir['*.txt'], 'bin'
+ end
- @dst.install_symlink @src+'bin'
-
- assert_predicate @dst+"bin", :symlink?
- assert_predicate @dst+"bin", :directory?
- assert_predicate @dst+"bin/a.txt", :exist?
- assert_predicate @dst+"bin/b.txt", :exist?
+ @dst.install_symlink @src+'bin'
- assert_predicate (@dst+"bin").readlink, :relative?
- end
+ assert_predicate @dst+"bin", :symlink?
+ assert_predicate @dst+"bin", :directory?
+ assert_predicate @dst+"bin/a.txt", :exist?
+ assert_predicate @dst+"bin/b.txt", :exist?
+ assert_predicate (@dst+"bin").readlink, :relative?
end
def test_install_creates_intermediate_directories