tests: rely on fewer implementation details

These tests were using too much semi-global state (instance variables)
and relied unnecessarily on the exact number of calls to `optional?` and
`recommended?` in the `Depedable` module.
This commit is contained in:
Martin Afanasjew 2015-12-15 10:27:19 +01:00
parent 6d802d8087
commit 10f066197e

View File

@ -48,15 +48,15 @@ class DependencyExpansionTests < Homebrew::TestCase
end
def test_expand_skips_optionals_by_default
@foo.expects(:optional?).returns(true)
@f = stub(:deps => @deps, :build => stub(:with? => false), :name => "f")
assert_equal [@bar, @baz, @qux], Dependency.expand(@f)
deps = [build_dep(:foo, [:optional]), @bar, @baz, @qux]
f = stub(:deps => deps, :build => stub(:with? => false), :name => "f")
assert_equal [@bar, @baz, @qux], Dependency.expand(f)
end
def test_expand_keeps_recommendeds_by_default
@foo.expects(:recommended?).returns(true)
@f = stub(:deps => @deps, :build => stub(:with? => true), :name => "f")
assert_equal @deps, Dependency.expand(@f)
deps = [build_dep(:foo, [:recommended]), @bar, @baz, @qux]
f = stub(:deps => deps, :build => stub(:with? => true), :name => "f")
assert_equal deps, Dependency.expand(f)
end
def test_merges_repeated_deps_with_differing_options