formula: add spec deprecated_option DSL.

This commit is contained in:
Mike McQuaid 2014-10-16 13:01:05 +01:00
parent 02e10beb7c
commit d0240e7cd4
3 changed files with 17 additions and 13 deletions

View File

@ -108,6 +108,10 @@ class Formula
active_spec.options
end
def deprecated_options
active_spec.deprecated_options
end
def option_defined?(name)
active_spec.option_defined?(name)
end
@ -714,6 +718,10 @@ class Formula
specs.each { |spec| spec.option(name, description) }
end
def deprecated_option hash
specs.each { |spec| spec.deprecated_option(hash) }
end
def patch strip=:p1, src=nil, &block
specs.each { |spec| spec.patch(strip, src, &block) }
end

View File

@ -113,10 +113,11 @@ class SoftwareSpec
old_flag = deprecated_option.old_flag
new_flag = deprecated_option.current_flag
next unless @flags.include? old_flag
@flags -= [old_flag]
@flags |= [new_flag]
@deprecated_flags << deprecated_option
if @flags.include? old_flag
@flags -= [old_flag]
@flags |= [new_flag]
@deprecated_flags << deprecated_option
end
end
end
end

View File

@ -81,15 +81,10 @@ class SoftwareSpecTests < Homebrew::TestCase
def test_deprecated_options
@spec.deprecated_option(['foo1', 'foo2'] => 'bar1', 'foo3' => ['bar2', 'bar3'])
refute_empty @spec.deprecated_options
assert_equal "foo1", @spec.deprecated_options.first.old
assert_equal "bar1", @spec.deprecated_options.first.current
assert_equal "foo2", @spec.deprecated_options[1].old
assert_equal "bar1", @spec.deprecated_options[1].current
assert_equal "foo3", @spec.deprecated_options[2].old
assert_equal "bar2", @spec.deprecated_options[2].current
assert_equal "foo3", @spec.deprecated_options.last.old
assert_equal "bar3", @spec.deprecated_options.last.current
assert_includes @spec.deprecated_options, DeprecatedOption.new("foo1", "bar1")
assert_includes @spec.deprecated_options, DeprecatedOption.new("foo2", "bar1")
assert_includes @spec.deprecated_options, DeprecatedOption.new("foo3", "bar2")
assert_includes @spec.deprecated_options, DeprecatedOption.new("foo3", "bar3")
end
def test_deprecated_option_raises_when_empty