Use assert_predicate

This commit is contained in:
Jack Nagel 2014-06-11 12:21:03 -05:00
parent 06305e6211
commit 58a75b0f71
18 changed files with 242 additions and 243 deletions

View File

@ -17,14 +17,14 @@ class BottleHookTests < Homebrew::TestCase
Homebrew::Hooks::Bottles.setup_formula_has_bottle do |f| Homebrew::Hooks::Bottles.setup_formula_has_bottle do |f|
f.some_random_method f.some_random_method
end end
assert @fi.pour_bottle? assert_predicate @fi, :pour_bottle?
end end
def test_has_no_bottle def test_has_no_bottle
Homebrew::Hooks::Bottles.setup_formula_has_bottle do |f| Homebrew::Hooks::Bottles.setup_formula_has_bottle do |f|
!f.some_random_method !f.some_random_method
end end
assert !@fi.pour_bottle? refute_predicate @fi, :pour_bottle?
end end
def test_pour_formula_bottle def test_pour_formula_bottle

View File

@ -12,12 +12,12 @@ class BuildEnvironmentTests < Homebrew::TestCase
def test_std? def test_std?
@env << :std @env << :std
assert @env.std? assert_predicate @env, :std?
end end
def test_userpaths? def test_userpaths?
@env << :userpaths @env << :userpaths
assert @env.userpaths? assert_predicate @env, :userpaths?
end end
def test_modify_build_environment def test_modify_build_environment
@ -31,7 +31,7 @@ class BuildEnvironmentTests < Homebrew::TestCase
@env << :userpaths @env << :userpaths
@env << Proc.new { 1 } @env << Proc.new { 1 }
dump = Marshal.dump(@env) dump = Marshal.dump(@env)
assert Marshal.load(dump).userpaths? assert_predicate Marshal.load(dump), :userpaths?
end end
def test_env_block def test_env_block
@ -60,12 +60,12 @@ class BuildEnvironmentDSLTests < Homebrew::TestCase
def test_env_single_argument def test_env_single_argument
obj = make_instance { env :userpaths } obj = make_instance { env :userpaths }
assert obj.env.userpaths? assert_predicate obj.env, :userpaths?
end end
def test_env_multiple_arguments def test_env_multiple_arguments
obj = make_instance { env :userpaths, :std } obj = make_instance { env :userpaths, :std }
assert obj.env.userpaths? assert_predicate obj.env, :userpaths?
assert obj.env.std? assert_predicate obj.env, :std?
end end
end end

View File

@ -30,7 +30,7 @@ class CleanerTests < Homebrew::TestCase
def test_prunes_prefix_if_empty def test_prunes_prefix_if_empty
Cleaner.new(@f).clean Cleaner.new(@f).clean
assert !@f.prefix.directory? refute_predicate @f.prefix, :directory?
end end
def test_prunes_empty_directories def test_prunes_empty_directories
@ -39,8 +39,8 @@ class CleanerTests < Homebrew::TestCase
Cleaner.new(@f).clean Cleaner.new(@f).clean
assert !@f.bin.directory? refute_predicate @f.bin, :directory?
assert !subdir.directory? refute_predicate subdir, :directory?
end end
def test_skip_clean_empty_directory def test_skip_clean_empty_directory
@ -49,7 +49,7 @@ class CleanerTests < Homebrew::TestCase
Cleaner.new(@f).clean Cleaner.new(@f).clean
assert @f.bin.directory? assert_predicate @f.bin, :directory?
end end
def test_skip_clean_directory_with_empty_subdir def test_skip_clean_directory_with_empty_subdir
@ -59,8 +59,8 @@ class CleanerTests < Homebrew::TestCase
Cleaner.new(@f).clean Cleaner.new(@f).clean
assert @f.bin.directory? assert_predicate @f.bin, :directory?
assert subdir.directory? assert_predicate subdir, :directory?
end end
def test_removes_symlink_when_target_was_pruned_first def test_removes_symlink_when_target_was_pruned_first
@ -72,9 +72,9 @@ class CleanerTests < Homebrew::TestCase
Cleaner.new(@f).clean Cleaner.new(@f).clean
assert !dir.exist? refute_predicate dir, :exist?
assert !symlink.symlink? refute_predicate symlink, :symlink?
assert !symlink.exist? refute_predicate symlink, :exist?
end end
def test_removes_symlink_pointing_to_empty_directory def test_removes_symlink_pointing_to_empty_directory
@ -86,9 +86,9 @@ class CleanerTests < Homebrew::TestCase
Cleaner.new(@f).clean Cleaner.new(@f).clean
assert !dir.exist? refute_predicate dir, :exist?
assert !symlink.symlink? refute_predicate symlink, :symlink?
assert !symlink.exist? refute_predicate symlink, :exist?
end end
def test_removes_broken_symlinks def test_removes_broken_symlinks
@ -97,7 +97,7 @@ class CleanerTests < Homebrew::TestCase
Cleaner.new(@f).clean Cleaner.new(@f).clean
assert !symlink.symlink? refute_predicate symlink, :symlink?
end end
def test_skip_clean_broken_symlink def test_skip_clean_broken_symlink
@ -107,7 +107,7 @@ class CleanerTests < Homebrew::TestCase
Cleaner.new(@f).clean Cleaner.new(@f).clean
assert symlink.symlink? assert_predicate symlink, :symlink?
end end
def test_skip_clean_symlink_pointing_to_empty_directory def test_skip_clean_symlink_pointing_to_empty_directory
@ -120,9 +120,9 @@ class CleanerTests < Homebrew::TestCase
Cleaner.new(@f).clean Cleaner.new(@f).clean
assert !dir.exist? refute_predicate dir, :exist?
assert symlink.symlink? assert_predicate symlink, :symlink?
assert !symlink.exist? refute_predicate symlink, :exist?
end end
def test_skip_clean_symlink_when_target_pruned def test_skip_clean_symlink_when_target_pruned
@ -135,9 +135,9 @@ class CleanerTests < Homebrew::TestCase
Cleaner.new(@f).clean Cleaner.new(@f).clean
assert !dir.exist? refute_predicate dir, :exist?
assert symlink.symlink? assert_predicate symlink, :symlink?
assert !symlink.exist? refute_predicate symlink, :exist?
end end
def test_removes_la_files def test_removes_la_files
@ -148,7 +148,7 @@ class CleanerTests < Homebrew::TestCase
Cleaner.new(@f).clean Cleaner.new(@f).clean
assert !file.exist? refute_predicate file, :exist?
end end
def test_skip_clean_la def test_skip_clean_la
@ -160,7 +160,7 @@ class CleanerTests < Homebrew::TestCase
Cleaner.new(@f).clean Cleaner.new(@f).clean
assert file.exist? assert_predicate file, :exist?
end end
def test_remove_charset_alias def test_remove_charset_alias
@ -171,7 +171,7 @@ class CleanerTests < Homebrew::TestCase
Cleaner.new(@f).clean Cleaner.new(@f).clean
assert !file.exist? refute_predicate file, :exist?
end end
def test_skip_clean_subdir def test_skip_clean_subdir
@ -182,7 +182,7 @@ class CleanerTests < Homebrew::TestCase
Cleaner.new(@f).clean Cleaner.new(@f).clean
assert dir.directory? assert_predicate dir, :directory?
end end
def test_skip_clean_paths_are_anchored_to_prefix def test_skip_clean_paths_are_anchored_to_prefix
@ -195,7 +195,7 @@ class CleanerTests < Homebrew::TestCase
Cleaner.new(@f).clean Cleaner.new(@f).clean
assert dir1.exist? assert_predicate dir1, :exist?
assert !dir2.exist? refute_predicate dir2, :exist?
end end
end end

View File

@ -14,14 +14,14 @@ class CleanupTests < Homebrew::TestCase
f3.brew { f3.install } f3.brew { f3.install }
end end
assert f1.installed? assert_predicate f1, :installed?
assert f2.installed? assert_predicate f2, :installed?
assert f3.installed? assert_predicate f3, :installed?
shutup { Homebrew.cleanup_formula(f3) } shutup { Homebrew.cleanup_formula(f3) }
assert !f1.installed? refute_predicate f1, :installed?
assert !f2.installed? refute_predicate f2, :installed?
assert f3.installed? assert_predicate f3, :installed?
end end
end end

View File

@ -12,9 +12,9 @@ class DependableTests < Homebrew::TestCase
end end
def test_interrogation def test_interrogation
assert @dep.build? assert_predicate @dep, :build?
assert !@dep.optional? refute_predicate @dep, :optional?
assert !@dep.recommended? refute_predicate @dep, :recommended?
end end
end end

View File

@ -32,8 +32,8 @@ class DependencyCollectorTests < Homebrew::TestCase
end end
def test_dependency_tags def test_dependency_tags
assert Dependency.new('foo', [:build]).build? assert_predicate Dependency.new('foo', [:build]), :build?
assert Dependency.new('foo', [:build, :optional]).optional? assert_predicate Dependency.new('foo', [:build, :optional]), :optional?
assert Dependency.new('foo', [:universal]).options.include? '--universal' assert Dependency.new('foo', [:universal]).options.include? '--universal'
assert_empty Dependency.new('foo').tags assert_empty Dependency.new('foo').tags
end end
@ -59,7 +59,7 @@ class DependencyCollectorTests < Homebrew::TestCase
@d.add :x11 => '2.5.1' @d.add :x11 => '2.5.1'
@d.add :xcode => :build @d.add :xcode => :build
assert_empty find_requirement(X11Dependency).tags assert_empty find_requirement(X11Dependency).tags
assert find_requirement(XcodeDependency).build? assert_predicate find_requirement(XcodeDependency), :build?
end end
def test_x11_no_tag def test_x11_no_tag
@ -74,14 +74,14 @@ class DependencyCollectorTests < Homebrew::TestCase
def test_x11_tag def test_x11_tag
@d.add :x11 => :optional @d.add :x11 => :optional
assert find_requirement(X11Dependency).optional? assert_predicate find_requirement(X11Dependency), :optional?
end end
def test_x11_min_version_and_tag def test_x11_min_version_and_tag
@d.add :x11 => ['2.5.1', :optional] @d.add :x11 => ['2.5.1', :optional]
dep = find_requirement(X11Dependency) dep = find_requirement(X11Dependency)
assert_equal '2.5.1', dep.min_version assert_equal '2.5.1', dep.min_version
assert dep.optional? assert_predicate dep, :optional?
end end
def test_ld64_dep_pre_leopard def test_ld64_dep_pre_leopard

View File

@ -27,17 +27,17 @@ class FormulaTests < Homebrew::TestCase
def test_installed? def test_installed?
f = TestBall.new f = TestBall.new
f.stubs(:installed_prefix).returns(stub(:directory? => false)) f.stubs(:installed_prefix).returns(stub(:directory? => false))
assert !f.installed? refute_predicate f, :installed?
f.stubs(:installed_prefix).returns( f.stubs(:installed_prefix).returns(
stub(:directory? => true, :children => []) stub(:directory? => true, :children => [])
) )
assert !f.installed? refute_predicate f, :installed?
f.stubs(:installed_prefix).returns( f.stubs(:installed_prefix).returns(
stub(:directory? => true, :children => [stub]) stub(:directory? => true, :children => [stub])
) )
assert f.installed? assert_predicate f, :installed?
end end
def test_installed_prefix def test_installed_prefix

View File

@ -24,31 +24,32 @@ class InstallTests < Homebrew::TestCase
keg.uninstall keg.uninstall
end end
assert !keg.exist? refute_predicate keg, :exist?
assert !f.installed? refute_predicate f, :installed?
end end
def test_a_basic_install def test_a_basic_install
f=TestBall.new f=TestBall.new
assert !f.installed? refute_predicate f, :installed?
temporary_install f do temporary_install f do
# Test that things made it into the Keg # Test that things made it into the Keg
assert f.bin.directory? assert_predicate f.bin, :directory?
assert_equal 3, f.bin.children.length assert_equal 3, f.bin.children.length
libexec=f.prefix+'libexec'
assert libexec.directory? libexec = f.prefix+'libexec'
assert_predicate libexec, :directory?
assert_equal 1, libexec.children.length assert_equal 1, libexec.children.length
assert !(f.prefix+'main.c').exist?
assert f.installed? refute_predicate f.prefix+'main.c', :exist?
assert_predicate f, :installed?
# Test that things make it into the Cellar # Test that things make it into the Cellar
keg=Keg.new f.prefix keg = Keg.new f.prefix
keg.link keg.link
assert_equal 3, HOMEBREW_PREFIX.children.length assert_equal 3, HOMEBREW_PREFIX.children.length
assert((HOMEBREW_PREFIX+'bin').directory?) assert_predicate HOMEBREW_PREFIX+'bin', :directory?
assert_equal 3, (HOMEBREW_PREFIX+'bin').children.length assert_equal 3, (HOMEBREW_PREFIX+'bin').children.length
end end
end end

View File

@ -19,18 +19,18 @@ class FormulaPinTests < Homebrew::TestCase
end end
def test_not_pinnable def test_not_pinnable
assert !@pin.pinnable? refute_predicate @pin, :pinnable?
end end
def test_pinnable_if_kegs_exist def test_pinnable_if_kegs_exist
(@f.rack+'0.1').mkpath (@f.rack+'0.1').mkpath
assert @pin.pinnable? assert_predicate @pin, :pinnable?
end end
def test_pin def test_pin
(@f.rack+'0.1').mkpath (@f.rack+'0.1').mkpath
@pin.pin @pin.pin
assert @pin.pinned? assert_predicate @pin, :pinned?
assert_equal 1, FormulaPin::PINDIR.children.length assert_equal 1, FormulaPin::PINDIR.children.length
end end
@ -38,7 +38,7 @@ class FormulaPinTests < Homebrew::TestCase
(@f.rack+'0.1').mkpath (@f.rack+'0.1').mkpath
@pin.pin @pin.pin
@pin.unpin @pin.unpin
assert !@pin.pinned? refute_predicate @pin, :pinned?
assert_equal 0, FormulaPin::PINDIR.children.length assert_equal 0, FormulaPin::PINDIR.children.length
end end

View File

@ -27,7 +27,7 @@ class LinkTests < Homebrew::TestCase
def test_linking_keg def test_linking_keg
assert_equal 3, @keg.link assert_equal 3, @keg.link
(HOMEBREW_PREFIX/"bin").children.each { |c| assert c.readlink.relative? } (HOMEBREW_PREFIX/"bin").children.each { |c| assert_predicate c.readlink, :relative? }
end end
def test_unlinking_keg def test_unlinking_keg
@ -39,7 +39,7 @@ class LinkTests < Homebrew::TestCase
@mode.dry_run = true @mode.dry_run = true
assert_equal 0, @keg.link(@mode) assert_equal 0, @keg.link(@mode)
assert !@keg.linked? refute_predicate @keg, :linked?
['hiworld', 'helloworld', 'goodbye_cruel_world'].each do |file| ['hiworld', 'helloworld', 'goodbye_cruel_world'].each do |file|
assert_match "#{HOMEBREW_PREFIX}/bin/#{file}", $stdout.string assert_match "#{HOMEBREW_PREFIX}/bin/#{file}", $stdout.string
@ -89,7 +89,7 @@ class LinkTests < Homebrew::TestCase
@mode.dry_run = true @mode.dry_run = true
assert_equal 0, @keg.link(@mode) assert_equal 0, @keg.link(@mode)
assert !@keg.linked? refute_predicate @keg, :linked?
assert_equal "#{HOMEBREW_PREFIX}/bin/helloworld\n", $stdout.string assert_equal "#{HOMEBREW_PREFIX}/bin/helloworld\n", $stdout.string
end end
@ -101,7 +101,7 @@ class LinkTests < Homebrew::TestCase
@keg.unlink @keg.unlink
assert !File.directory?(HOMEBREW_PREFIX/"lib/foo") refute_predicate HOMEBREW_PREFIX/"lib/foo", :directory?
end end
def test_unlink_ignores_DS_Store_when_pruning_empty_dirs def test_unlink_ignores_DS_Store_when_pruning_empty_dirs
@ -112,8 +112,8 @@ class LinkTests < Homebrew::TestCase
@keg.unlink @keg.unlink
assert !File.directory?(HOMEBREW_PREFIX/"lib/foo") refute_predicate HOMEBREW_PREFIX/"lib/foo", :directory?
assert !File.exist?(HOMEBREW_PREFIX/"lib/foo/.DS_Store") refute_predicate HOMEBREW_PREFIX/"lib/foo/.DS_Store", :exist?
end end
def teardown def teardown

View File

@ -3,13 +3,11 @@ require 'requirements/language_module_dependency'
class LanguageModuleDependencyTests < Homebrew::TestCase class LanguageModuleDependencyTests < Homebrew::TestCase
def assert_deps_fail(spec) def assert_deps_fail(spec)
l = LanguageModuleDependency.new(*spec.shift.reverse) refute_predicate LanguageModuleDependency.new(*spec.shift.reverse), :satisfied?
assert !l.satisfied?
end end
def assert_deps_pass(spec) def assert_deps_pass(spec)
l = LanguageModuleDependency.new(*spec.shift.reverse) assert_predicate LanguageModuleDependency.new(*spec.shift.reverse), :satisfied?
assert l.satisfied?
end end
def test_unique_deps_are_not_eql def test_unique_deps_are_not_eql

View File

@ -11,106 +11,106 @@ class MachOPathnameTests < Homebrew::TestCase
def test_fat_dylib def test_fat_dylib
pn = dylib_path("fat") pn = dylib_path("fat")
assert pn.universal? assert_predicate pn, :universal?
assert !pn.i386? refute_predicate pn, :i386?
assert !pn.x86_64? refute_predicate pn, :x86_64?
assert !pn.ppc7400? refute_predicate pn, :ppc7400?
assert !pn.ppc64? refute_predicate pn, :ppc64?
assert pn.dylib? assert_predicate pn, :dylib?
assert !pn.mach_o_executable? refute_predicate pn, :mach_o_executable?
assert !pn.text_executable? refute_predicate pn, :text_executable?
assert_equal :universal, pn.arch assert_equal :universal, pn.arch
end end
def test_i386_dylib def test_i386_dylib
pn = dylib_path("i386") pn = dylib_path("i386")
assert !pn.universal? refute_predicate pn, :universal?
assert pn.i386? assert_predicate pn, :i386?
assert !pn.x86_64? refute_predicate pn, :x86_64?
assert !pn.ppc7400? refute_predicate pn, :ppc7400?
assert !pn.ppc64? refute_predicate pn, :ppc64?
assert pn.dylib? assert_predicate pn, :dylib?
assert !pn.mach_o_executable? refute_predicate pn, :mach_o_executable?
assert !pn.text_executable? refute_predicate pn, :text_executable?
assert !pn.mach_o_bundle? refute_predicate pn, :mach_o_bundle?
end end
def test_x86_64_dylib def test_x86_64_dylib
pn = dylib_path("x86_64") pn = dylib_path("x86_64")
assert !pn.universal? refute_predicate pn, :universal?
assert !pn.i386? refute_predicate pn, :i386?
assert pn.x86_64? assert_predicate pn, :x86_64?
assert !pn.ppc7400? refute_predicate pn, :ppc7400?
assert !pn.ppc64? refute_predicate pn, :ppc64?
assert pn.dylib? assert_predicate pn, :dylib?
assert !pn.mach_o_executable? refute_predicate pn, :mach_o_executable?
assert !pn.text_executable? refute_predicate pn, :text_executable?
assert !pn.mach_o_bundle? refute_predicate pn, :mach_o_bundle?
end end
def test_mach_o_executable def test_mach_o_executable
pn = Pathname.new("#{TEST_DIRECTORY}/mach/a.out") pn = Pathname.new("#{TEST_DIRECTORY}/mach/a.out")
assert pn.universal? assert_predicate pn, :universal?
assert !pn.i386? refute_predicate pn, :i386?
assert !pn.x86_64? refute_predicate pn, :x86_64?
assert !pn.ppc7400? refute_predicate pn, :ppc7400?
assert !pn.ppc64? refute_predicate pn, :ppc64?
assert !pn.dylib? refute_predicate pn, :dylib?
assert pn.mach_o_executable? assert_predicate pn, :mach_o_executable?
assert !pn.text_executable? refute_predicate pn, :text_executable?
assert !pn.mach_o_bundle? refute_predicate pn, :mach_o_bundle?
end end
def test_fat_bundle def test_fat_bundle
pn = bundle_path("fat") pn = bundle_path("fat")
assert pn.universal? assert_predicate pn, :universal?
assert !pn.i386? refute_predicate pn, :i386?
assert !pn.x86_64? refute_predicate pn, :x86_64?
assert !pn.ppc7400? refute_predicate pn, :ppc7400?
assert !pn.ppc64? refute_predicate pn, :ppc64?
assert !pn.dylib? refute_predicate pn, :dylib?
assert !pn.mach_o_executable? refute_predicate pn, :mach_o_executable?
assert !pn.text_executable? refute_predicate pn, :text_executable?
assert pn.mach_o_bundle? assert_predicate pn, :mach_o_bundle?
end end
def test_i386_bundle def test_i386_bundle
pn = bundle_path("i386") pn = bundle_path("i386")
assert !pn.universal? refute_predicate pn, :universal?
assert pn.i386? assert_predicate pn, :i386?
assert !pn.x86_64? refute_predicate pn, :x86_64?
assert !pn.ppc7400? refute_predicate pn, :ppc7400?
assert !pn.ppc64? refute_predicate pn, :ppc64?
assert !pn.dylib? refute_predicate pn, :dylib?
assert !pn.mach_o_executable? refute_predicate pn, :mach_o_executable?
assert !pn.text_executable? refute_predicate pn, :text_executable?
assert pn.mach_o_bundle? assert_predicate pn, :mach_o_bundle?
end end
def test_x86_64_bundle def test_x86_64_bundle
pn = bundle_path("x86_64") pn = bundle_path("x86_64")
assert !pn.universal? refute_predicate pn, :universal?
assert !pn.i386? refute_predicate pn, :i386?
assert pn.x86_64? assert_predicate pn, :x86_64?
assert !pn.ppc7400? refute_predicate pn, :ppc7400?
assert !pn.ppc64? refute_predicate pn, :ppc64?
assert !pn.dylib? refute_predicate pn, :dylib?
assert !pn.mach_o_executable? refute_predicate pn, :mach_o_executable?
assert !pn.text_executable? refute_predicate pn, :text_executable?
assert pn.mach_o_bundle? assert_predicate pn, :mach_o_bundle?
end end
def test_non_mach_o def test_non_mach_o
pn = Pathname.new("#{TEST_DIRECTORY}/tarballs/testball-0.1.tbz") pn = Pathname.new("#{TEST_DIRECTORY}/tarballs/testball-0.1.tbz")
assert !pn.universal? refute_predicate pn, :universal?
assert !pn.i386? refute_predicate pn, :i386?
assert !pn.x86_64? refute_predicate pn, :x86_64?
assert !pn.ppc7400? refute_predicate pn, :ppc7400?
assert !pn.ppc64? refute_predicate pn, :ppc64?
assert !pn.dylib? refute_predicate pn, :dylib?
assert !pn.mach_o_executable? refute_predicate pn, :mach_o_executable?
assert !pn.text_executable? refute_predicate pn, :text_executable?
assert !pn.mach_o_bundle? refute_predicate pn, :mach_o_bundle?
assert_equal :dunno, pn.arch assert_equal :dunno, pn.arch
end end
end end
@ -121,29 +121,29 @@ class ArchitectureListExtensionTests < MachOPathnameTests
end end
def test_architecture_list_extension_universal_checks def test_architecture_list_extension_universal_checks
assert @archs.universal? assert_predicate @archs, :universal?
assert @archs.intel_universal? assert_predicate @archs, :intel_universal?
assert @archs.ppc_universal? assert_predicate @archs, :ppc_universal?
assert @archs.cross_universal? assert_predicate @archs, :cross_universal?
assert @archs.fat? assert_predicate @archs, :fat?
non_universal = [:i386].extend ArchitectureListExtension non_universal = [:i386].extend ArchitectureListExtension
assert !non_universal.universal? refute_predicate non_universal, :universal?
intel_only = [:i386, :x86_64].extend ArchitectureListExtension intel_only = [:i386, :x86_64].extend ArchitectureListExtension
assert intel_only.universal? assert_predicate intel_only, :universal?
assert !intel_only.ppc_universal? refute_predicate intel_only, :ppc_universal?
assert !intel_only.cross_universal? refute_predicate intel_only, :cross_universal?
ppc_only = [:ppc970, :ppc64].extend ArchitectureListExtension ppc_only = [:ppc970, :ppc64].extend ArchitectureListExtension
assert ppc_only.universal? assert_predicate ppc_only, :universal?
assert !ppc_only.intel_universal? refute_predicate ppc_only, :intel_universal?
assert !ppc_only.cross_universal? refute_predicate ppc_only, :cross_universal?
cross = [:ppc7400, :i386].extend ArchitectureListExtension cross = [:ppc7400, :i386].extend ArchitectureListExtension
assert cross.universal? assert_predicate cross, :universal?
assert !cross.intel_universal? refute_predicate cross, :intel_universal?
assert !cross.ppc_universal? refute_predicate cross, :ppc_universal?
end end
def test_architecture_list_extension_massaging_flags def test_architecture_list_extension_massaging_flags
@ -155,7 +155,7 @@ class ArchitectureListExtensionTests < MachOPathnameTests
def test_architecture_list_arch_flags_methods def test_architecture_list_arch_flags_methods
pn = dylib_path("fat") pn = dylib_path("fat")
assert pn.archs.intel_universal? assert_predicate pn.archs, :intel_universal?
assert_equal "-arch x86_64 -arch i386", pn.archs.as_arch_flags assert_equal "-arch x86_64 -arch i386", pn.archs.as_arch_flags
assert_equal "x86_64;i386", pn.archs.as_cmake_arch_flags assert_equal "x86_64;i386", pn.archs.as_cmake_arch_flags
end end
@ -174,42 +174,42 @@ class TextExecutableTests < Homebrew::TestCase
def test_simple_shebang def test_simple_shebang
pn.write '#!/bin/sh' pn.write '#!/bin/sh'
assert !pn.universal? refute_predicate pn, :universal?
assert !pn.i386? refute_predicate pn, :i386?
assert !pn.x86_64? refute_predicate pn, :x86_64?
assert !pn.ppc7400? refute_predicate pn, :ppc7400?
assert !pn.ppc64? refute_predicate pn, :ppc64?
assert !pn.dylib? refute_predicate pn, :dylib?
assert !pn.mach_o_executable? refute_predicate pn, :mach_o_executable?
assert pn.text_executable? assert_predicate pn, :text_executable?
assert_equal [], pn.archs assert_equal [], pn.archs
assert_equal :dunno, pn.arch assert_equal :dunno, pn.arch
end end
def test_shebang_with_options def test_shebang_with_options
pn.write '#! /usr/bin/perl -w' pn.write '#! /usr/bin/perl -w'
assert !pn.universal? refute_predicate pn, :universal?
assert !pn.i386? refute_predicate pn, :i386?
assert !pn.x86_64? refute_predicate pn, :x86_64?
assert !pn.ppc7400? refute_predicate pn, :ppc7400?
assert !pn.ppc64? refute_predicate pn, :ppc64?
assert !pn.dylib? refute_predicate pn, :dylib?
assert !pn.mach_o_executable? refute_predicate pn, :mach_o_executable?
assert pn.text_executable? assert_predicate pn, :text_executable?
assert_equal [], pn.archs assert_equal [], pn.archs
assert_equal :dunno, pn.arch assert_equal :dunno, pn.arch
end end
def test_malformed_shebang def test_malformed_shebang
pn.write ' #!' pn.write ' #!'
assert !pn.universal? refute_predicate pn, :universal?
assert !pn.i386? refute_predicate pn, :i386?
assert !pn.x86_64? refute_predicate pn, :x86_64?
assert !pn.ppc7400? refute_predicate pn, :ppc7400?
assert !pn.ppc64? refute_predicate pn, :ppc64?
assert !pn.dylib? refute_predicate pn, :dylib?
assert !pn.mach_o_executable? refute_predicate pn, :mach_o_executable?
assert !pn.text_executable? refute_predicate pn, :text_executable?
assert_equal [], pn.archs assert_equal [], pn.archs
assert_equal :dunno, pn.arch assert_equal :dunno, pn.arch
end end

View File

@ -5,14 +5,14 @@ class PatchTests < Homebrew::TestCase
def test_create_simple def test_create_simple
patch = Patch.create(:p2) patch = Patch.create(:p2)
assert_kind_of ExternalPatch, patch assert_kind_of ExternalPatch, patch
assert patch.external? assert_predicate patch, :external?
assert_equal :p2, patch.strip assert_equal :p2, patch.strip
end end
def test_create_io def test_create_io
patch = Patch.create(:p0, StringIO.new("foo")) patch = Patch.create(:p0, StringIO.new("foo"))
assert_kind_of IOPatch, patch assert_kind_of IOPatch, patch
assert !patch.external? refute_predicate patch, :external?
assert_equal :p0, patch.strip assert_equal :p0, patch.strip
end end

View File

@ -22,18 +22,18 @@ class PathnameExtensionTests < Homebrew::TestCase
touch @dir+'foo' touch @dir+'foo'
assert !@dir.rmdir_if_possible assert !@dir.rmdir_if_possible
assert @dir.directory? assert_predicate @dir, :directory?
rm_f @dir+'foo' rm_f @dir+'foo'
assert @dir.rmdir_if_possible assert @dir.rmdir_if_possible
assert !@dir.exist? refute_predicate @dir, :exist?
end end
def test_rmdir_if_possible_ignore_DS_Store def test_rmdir_if_possible_ignore_DS_Store
mkdir_p @dir mkdir_p @dir
touch @dir+'.DS_Store' touch @dir+'.DS_Store'
assert @dir.rmdir_if_possible assert @dir.rmdir_if_possible
assert !@dir.exist? refute_predicate @dir, :exist?
end end
def test_write def test_write
@ -68,8 +68,8 @@ class PathnameExtensionTests < Homebrew::TestCase
def test_ensure_writable def test_ensure_writable
touch @file touch @file
chmod 0555, @file chmod 0555, @file
@file.ensure_writable { assert @file.writable? } @file.ensure_writable { assert_predicate @file, :writable? }
assert !@file.writable? refute_predicate @file, :writable?
end end
def test_extname def test_extname
@ -92,8 +92,8 @@ class PathnameExtensionTests < Homebrew::TestCase
touch @file touch @file
@dst.install(@file) @dst.install(@file)
assert (@dst/@file.basename).exist? assert_predicate @dst/@file.basename, :exist?
assert !@file.exist? refute_predicate @file, :exist?
end end
def setup_install_test def setup_install_test
@ -108,8 +108,8 @@ class PathnameExtensionTests < Homebrew::TestCase
setup_install_test do setup_install_test do
@dst.install 'a.txt' @dst.install 'a.txt'
assert((@dst+'a.txt').exist?, 'a.txt not installed.') assert_predicate @dst+"a.txt", :exist?, "a.txt was not installed"
assert(!(@dst+'b.txt').exist?, 'b.txt was installed.') refute_predicate @dst+"b.txt", :exist?, "b.txt was installed."
end end
end end
@ -117,8 +117,8 @@ class PathnameExtensionTests < Homebrew::TestCase
setup_install_test do setup_install_test do
@dst.install %w[a.txt b.txt] @dst.install %w[a.txt b.txt]
assert((@dst+'a.txt').exist?, 'a.txt not installed.') assert_predicate @dst+"a.txt", :exist?, "a.txt was not installed"
assert((@dst+'b.txt').exist?, 'b.txt not installed.') assert_predicate @dst+"b.txt", :exist?, "b.txt was not installed"
end end
end end
@ -126,8 +126,8 @@ class PathnameExtensionTests < Homebrew::TestCase
setup_install_test do setup_install_test do
@dst.install Dir['*.txt'] @dst.install Dir['*.txt']
assert((@dst+'a.txt').exist?, 'a.txt not installed.') assert_predicate @dst+"a.txt", :exist?, "a.txt was not installed"
assert((@dst+'b.txt').exist?, 'b.txt not installed.') assert_predicate @dst+"b.txt", :exist?, "b.txt was not installed"
end end
end end
@ -138,8 +138,8 @@ class PathnameExtensionTests < Homebrew::TestCase
@dst.install 'bin' @dst.install 'bin'
assert((@dst+'bin/a.txt').exist?, 'a.txt not installed.') assert_predicate @dst+"bin/a.txt", :exist?, "a.txt was not installed"
assert((@dst+'bin/b.txt').exist?, 'b.txt not installed.') assert_predicate @dst+"bin/b.txt", :exist?, "b.txt was not installed"
end end
end end
@ -147,9 +147,9 @@ class PathnameExtensionTests < Homebrew::TestCase
setup_install_test do setup_install_test do
@dst.install 'a.txt' => 'c.txt' @dst.install 'a.txt' => 'c.txt'
assert((@dst+'c.txt').exist?, 'c.txt not installed.') assert_predicate @dst+"c.txt", :exist?, "c.txt was not installed"
assert(!(@dst+'a.txt').exist?, 'a.txt was installed but not renamed.') refute_predicate @dst+"a.txt", :exist?, "a.txt was installed but not renamed"
assert(!(@dst+'b.txt').exist?, 'b.txt was installed.') refute_predicate @dst+"b.txt", :exist?, "b.txt was installed"
end end
end end
@ -157,10 +157,10 @@ class PathnameExtensionTests < Homebrew::TestCase
setup_install_test do setup_install_test do
@dst.install({'a.txt' => 'c.txt', 'b.txt' => 'd.txt'}) @dst.install({'a.txt' => 'c.txt', 'b.txt' => 'd.txt'})
assert((@dst+'c.txt').exist?, 'c.txt not installed.') assert_predicate @dst+"c.txt", :exist?, "c.txt was not installed"
assert((@dst+'d.txt').exist?, 'd.txt not installed.') assert_predicate @dst+"d.txt", :exist?, "d.txt was not installed"
assert(!(@dst+'a.txt').exist?, 'a.txt was installed but not renamed.') refute_predicate @dst+"a.txt", :exist?, "a.txt was installed but not renamed"
assert(!(@dst+'b.txt').exist?, 'b.txt was installed but not renamed.') refute_predicate @dst+"b.txt", :exist?, "b.txt was installed but not renamed"
end end
end end
@ -171,9 +171,9 @@ class PathnameExtensionTests < Homebrew::TestCase
@dst.install 'bin' => 'libexec' @dst.install 'bin' => 'libexec'
assert(!(@dst+'bin').exist?, 'bin was installed but not renamed.') refute_predicate @dst+"bin", :exist?, "bin was installed but not renamed"
assert((@dst+'libexec/a.txt').exist?, 'a.txt not installed.') assert_predicate @dst+"libexec/a.txt", :exist?, "a.txt was not installed"
assert((@dst+'libexec/b.txt').exist?, 'b.txt not installed.') assert_predicate @dst+"libexec/b.txt", :exist?, "b.txt was not installed"
end end
end end
@ -184,19 +184,19 @@ class PathnameExtensionTests < Homebrew::TestCase
@dst.install_symlink @src+'bin' @dst.install_symlink @src+'bin'
assert((@dst+'bin').symlink?) assert_predicate @dst+"bin", :symlink?
assert((@dst+'bin').directory?) assert_predicate @dst+"bin", :directory?
assert((@dst+'bin/a.txt').exist?) assert_predicate @dst+"bin/a.txt", :exist?
assert((@dst+'bin/b.txt').exist?) assert_predicate @dst+"bin/b.txt", :exist?
assert((@dst+'bin').readlink.relative?) assert_predicate (@dst+"bin").readlink, :relative?
end end
end end
def test_install_creates_intermediate_directories def test_install_creates_intermediate_directories
touch @file touch @file
assert !@dir.directory? refute_predicate @dir, :directory?
@dir.install(@file) @dir.install(@file)
assert @dir.directory? assert_predicate @dir, :directory?
end end
end end

View File

@ -24,28 +24,28 @@ class RequirementTests < Homebrew::TestCase
def test_dsl_fatal def test_dsl_fatal
req = Class.new(Requirement) { fatal true }.new req = Class.new(Requirement) { fatal true }.new
assert req.fatal? assert_predicate req, :fatal?
end end
def test_satisfy_true def test_satisfy_true
req = Class.new(Requirement) do req = Class.new(Requirement) do
satisfy(:build_env => false) { true } satisfy(:build_env => false) { true }
end.new end.new
assert req.satisfied? assert_predicate req, :satisfied?
end end
def test_satisfy_false def test_satisfy_false
req = Class.new(Requirement) do req = Class.new(Requirement) do
satisfy(:build_env => false) { false } satisfy(:build_env => false) { false }
end.new end.new
assert !req.satisfied? refute_predicate req, :satisfied?
end end
def test_satisfy_with_boolean def test_satisfy_with_boolean
req = Class.new(Requirement) do req = Class.new(Requirement) do
satisfy true satisfy true
end.new end.new
assert req.satisfied? assert_predicate req, :satisfied?
end end
def test_satisfy_sets_up_build_env_by_default def test_satisfy_sets_up_build_env_by_default
@ -55,7 +55,7 @@ class RequirementTests < Homebrew::TestCase
ENV.expects(:with_build_environment).yields.returns(true) ENV.expects(:with_build_environment).yields.returns(true)
assert req.satisfied? assert_predicate req, :satisfied?
end end
def test_satisfy_build_env_can_be_disabled def test_satisfy_build_env_can_be_disabled
@ -65,7 +65,7 @@ class RequirementTests < Homebrew::TestCase
ENV.expects(:with_build_environment).never ENV.expects(:with_build_environment).never
assert req.satisfied? assert_predicate req, :satisfied?
end end
def test_infers_path_from_satisfy_result def test_infers_path_from_satisfy_result
@ -83,7 +83,7 @@ class RequirementTests < Homebrew::TestCase
def test_dsl_build def test_dsl_build
req = Class.new(Requirement) { build true }.new req = Class.new(Requirement) { build true }.new
assert req.build? assert_predicate req, :build?
end end
def test_infer_name_from_class def test_infer_name_from_class
@ -101,7 +101,7 @@ class RequirementTests < Homebrew::TestCase
def test_dsl_default_formula def test_dsl_default_formula
req = Class.new(Requirement) { default_formula 'foo' }.new req = Class.new(Requirement) { default_formula 'foo' }.new
assert req.default_formula? assert_predicate req, :default_formula?
end end
def test_to_dependency def test_to_dependency

View File

@ -49,13 +49,13 @@ class ResourceTests < Homebrew::TestCase
def test_version def test_version
@resource.version('1.0') @resource.version('1.0')
assert_version_equal '1.0', @resource.version assert_version_equal '1.0', @resource.version
assert !@resource.version.detected_from_url? refute_predicate @resource.version, :detected_from_url?
end end
def test_version_from_url def test_version_from_url
@resource.url('http://example.com/foo-1.0.tar.gz') @resource.url('http://example.com/foo-1.0.tar.gz')
assert_version_equal '1.0', @resource.version assert_version_equal '1.0', @resource.version
assert @resource.version.detected_from_url? assert_predicate @resource.version, :detected_from_url?
end end
def test_version_with_scheme def test_version_with_scheme
@ -68,7 +68,7 @@ class ResourceTests < Homebrew::TestCase
def test_version_from_tag def test_version_from_tag
@resource.url('http://example.com/foo-1.0.tar.gz', :tag => 'v1.0.2') @resource.url('http://example.com/foo-1.0.tar.gz', :tag => 'v1.0.2')
assert_version_equal '1.0.2', @resource.version assert_version_equal '1.0.2', @resource.version
assert @resource.version.detected_from_url? assert_predicate @resource.version, :detected_from_url?
end end
def test_rejects_non_string_versions def test_rejects_non_string_versions

View File

@ -44,11 +44,11 @@ class CxxStdlibTests < Homebrew::TestCase
end end
def test_apple_compiler_reporting def test_apple_compiler_reporting
assert @clang.apple_compiler? assert_predicate @clang, :apple_compiler?
assert @gcc.apple_compiler? assert_predicate @gcc, :apple_compiler?
assert @llvm.apple_compiler? assert_predicate @llvm, :apple_compiler?
assert @gcc4.apple_compiler? assert_predicate @gcc4, :apple_compiler?
assert !@gcc48.apple_compiler? refute_predicate @gcc48, :apple_compiler?
end end
def test_type_string_formatting def test_type_string_formatting

View File

@ -61,13 +61,13 @@ class UpdaterTests < Homebrew::TestCase
def test_update_homebrew_without_any_changes def test_update_homebrew_without_any_changes
perform_update perform_update
assert @updater.expectations_met? assert_predicate @updater, :expectations_met?
assert_empty @report assert_empty @report
end end
def test_update_homebrew_without_formulae_changes def test_update_homebrew_without_formulae_changes
perform_update(fixture('update_git_diff_output_without_formulae_changes')) perform_update(fixture('update_git_diff_output_without_formulae_changes'))
assert @updater.expectations_met? assert_predicate @updater, :expectations_met?
assert_empty @report.select_formula(:M) assert_empty @report.select_formula(:M)
assert_empty @report.select_formula(:A) assert_empty @report.select_formula(:A)
assert_empty @report.select_formula(:R) assert_empty @report.select_formula(:R)
@ -75,7 +75,7 @@ class UpdaterTests < Homebrew::TestCase
def test_update_homebrew_with_formulae_changes def test_update_homebrew_with_formulae_changes
perform_update(fixture('update_git_diff_output_with_formulae_changes')) perform_update(fixture('update_git_diff_output_with_formulae_changes'))
assert @updater.expectations_met? assert_predicate @updater, :expectations_met?
assert_equal %w{ xar yajl }, @report.select_formula(:M) assert_equal %w{ xar yajl }, @report.select_formula(:M)
assert_equal %w{ antiword bash-completion ddrescue dict lua }, @report.select_formula(:A) assert_equal %w{ antiword bash-completion ddrescue dict lua }, @report.select_formula(:A)
assert_equal %w{ shapelib }, @report.select_formula(:R) assert_equal %w{ shapelib }, @report.select_formula(:R)
@ -83,7 +83,7 @@ class UpdaterTests < Homebrew::TestCase
def test_update_homebrew_with_tapped_formula_changes def test_update_homebrew_with_tapped_formula_changes
perform_update(fixture('update_git_diff_output_with_tapped_formulae_changes')) perform_update(fixture('update_git_diff_output_with_tapped_formulae_changes'))
assert @updater.expectations_met? assert_predicate @updater, :expectations_met?
assert_equal [ assert_equal [
HOMEBREW_LIBRARY.join("Taps", "someuser/sometap/Formula/antiword.rb"), HOMEBREW_LIBRARY.join("Taps", "someuser/sometap/Formula/antiword.rb"),
HOMEBREW_LIBRARY.join("Taps", "someuser/sometap/HomebrewFormula/lua.rb"), HOMEBREW_LIBRARY.join("Taps", "someuser/sometap/HomebrewFormula/lua.rb"),
@ -93,12 +93,12 @@ class UpdaterTests < Homebrew::TestCase
def test_update_homebrew_with_removed_formulae def test_update_homebrew_with_removed_formulae
perform_update(fixture('update_git_diff_output_with_removed_formulae')) perform_update(fixture('update_git_diff_output_with_removed_formulae'))
assert @updater.expectations_met? assert_predicate @updater, :expectations_met?
assert_equal %w{libgsasl}, @report.select_formula(:D) assert_equal %w{libgsasl}, @report.select_formula(:D)
end end
def test_update_homebrew_with_changed_filetype def test_update_homebrew_with_changed_filetype
perform_update(fixture('update_git_diff_output_with_changed_filetype')) perform_update(fixture('update_git_diff_output_with_changed_filetype'))
assert @updater.expectations_met? assert_predicate @updater, :expectations_met?
end end
end end