Use assert_includes

This commit is contained in:
Jack Nagel 2014-06-11 13:03:06 -05:00
parent 58a75b0f71
commit 4b6abc7da2
6 changed files with 23 additions and 23 deletions

View File

@ -22,9 +22,9 @@ class BuildOptionsTests < Homebrew::TestCase
end
def test_include
assert @build.include?("with-foo")
assert !@build.include?("with-qux")
assert !@build.include?("--with-foo")
assert_includes @build, "with-foo"
refute_includes @build, "with-qux"
refute_includes @build, "--with-foo"
end
def test_with_without
@ -35,23 +35,23 @@ class BuildOptionsTests < Homebrew::TestCase
end
def test_used_options
assert @build.used_options.include?("--with-foo")
assert @build.used_options.include?("--with-bar")
assert_includes @build.used_options, "--with-foo"
assert_includes @build.used_options, "--with-bar"
end
def test_unused_options
assert @build.unused_options.include?("--without-baz")
assert_includes @build.unused_options, "--without-baz"
end
def test_implicit_options
# --without-baz is not explicitly specified on the command line (i.e. args)
# therefore --with-baz should be implicitly assumed:
assert @build.implicit_options.include?("--with-baz")
assert_includes @build.implicit_options, "--with-baz"
# But all these should not be in the implict_options:
assert !@build.implicit_options.include?("--without-baz")
assert !@build.implicit_options.include?("--with-bar")
assert !@build.implicit_options.include?("--without-bar")
assert !@build.implicit_options.include?("--with-qux")
refute_includes @build.implicit_options, "--without-baz"
refute_includes @build.implicit_options, "--with-bar"
refute_includes @build.implicit_options, "--without-bar"
refute_includes @build.implicit_options, "--with-qux"
end
def test_opposite_of

View File

@ -34,7 +34,7 @@ class DependencyCollectorTests < Homebrew::TestCase
def test_dependency_tags
assert_predicate Dependency.new('foo', [:build]), :build?
assert_predicate Dependency.new('foo', [:build, :optional]), :optional?
assert Dependency.new('foo', [:universal]).options.include? '--universal'
assert_includes Dependency.new('foo', [:universal]).options, "--universal"
assert_empty Dependency.new('foo').tags
end

View File

@ -3,11 +3,11 @@ require 'hardware'
class HardwareTests < Homebrew::TestCase
def test_hardware_cpu_type
assert [:intel, :ppc].include?(Hardware::CPU.type)
assert_includes [:intel, :ppc], Hardware::CPU.type
end
def test_hardware_intel_family
families = [:core, :core2, :penryn, :nehalem, :arrandale, :sandybridge, :ivybridge, :haswell]
assert families.include?(Hardware::CPU.family)
assert_includes families, Hardware::CPU.family
end if Hardware::CPU.intel?
end

View File

@ -22,7 +22,7 @@ class LanguageModuleDependencyTests < Homebrew::TestCase
mod_name = "foo"
import_name = "bar"
l = LanguageModuleDependency.new(:python, mod_name, import_name)
assert l.message.include?(mod_name)
assert_includes l.message, mod_name
assert l.the_test.one? { |c| c.include?(import_name) }
end

View File

@ -50,7 +50,7 @@ class OptionsTests < Homebrew::TestCase
def test_no_duplicate_options
@options << Option.new("foo")
@options << Option.new("foo")
assert @options.include? "--foo"
assert_includes @options, "--foo"
assert_equal 1, @options.count
end
@ -65,9 +65,9 @@ class OptionsTests < Homebrew::TestCase
def test_include
@options << Option.new("foo")
assert @options.include? "--foo"
assert @options.include? "foo"
assert @options.include? Option.new("foo")
assert_includes @options, "--foo"
assert_includes @options, "foo"
assert_includes @options, Option.new("foo")
end
def test_union_returns_options
@ -102,7 +102,7 @@ class OptionsTests < Homebrew::TestCase
def test_concat_array
option = Option.new("foo")
@options.concat([option])
assert @options.include?(option)
assert_includes @options, option
assert_equal [option], @options.to_a
end
@ -111,7 +111,7 @@ class OptionsTests < Homebrew::TestCase
opts = Options.new
opts << option
@options.concat(opts)
assert @options.include?(option)
assert_includes @options, option
assert_equal [option], @options.to_a
end

View File

@ -16,8 +16,8 @@ class PatchingTests < Homebrew::TestCase
def assert_patched(path)
s = File.read(path)
assert !s.include?("NOOP"), "File was unpatched."
assert s.include?("ABCD"), "File was not patched as expected."
refute_includes s, "NOOP", "#{path} was not patched as expected"
assert_includes s, "ABCD", "#{path} was not patched as expected"
end
def test_single_patch