diff options
| author | Mike McQuaid | 2014-10-16 13:00:20 +0100 |
|---|---|---|
| committer | Mike McQuaid | 2014-10-19 13:58:52 +0100 |
| commit | 02e10beb7c79f29d5c8a17d89649af344034d541 (patch) | |
| tree | 478793f3d98c59d0296dee316113605d91d7d588 /Library/Homebrew/test | |
| parent | da0a65356d662575c0005b70371050b8015227b2 (diff) | |
| download | brew-02e10beb7c79f29d5c8a17d89649af344034d541.tar.bz2 | |
Add deprecated_option to software_spec.
Allows remapping one option name to another and updates build options
and flags accordingly.
Diffstat (limited to 'Library/Homebrew/test')
| -rw-r--r-- | Library/Homebrew/test/test_options.rb | 17 | ||||
| -rw-r--r-- | Library/Homebrew/test/test_software_spec.rb | 24 |
2 files changed, 41 insertions, 0 deletions
diff --git a/Library/Homebrew/test/test_options.rb b/Library/Homebrew/test/test_options.rb index 1bd5ba3b0..fcf49a8d8 100644 --- a/Library/Homebrew/test/test_options.rb +++ b/Library/Homebrew/test/test_options.rb @@ -37,6 +37,23 @@ class DeprecatedOptionTests < Homebrew::TestCase def test_current assert_equal "bar", @deprecated_option.current end + + def test_old + assert_equal "--foo", @deprecated_option.old_flag + end + + def test_current + assert_equal "--bar", @deprecated_option.current_flag + end + + def test_equality + foobar = DeprecatedOption.new("foo", "bar") + boofar = DeprecatedOption.new("boo", "far") + assert_equal foobar, @deprecated_option + refute_equal boofar, @deprecated_option + assert_eql @deprecated_option, foobar + refute_eql @deprecated_option, boofar + end end class OptionsTests < Homebrew::TestCase diff --git a/Library/Homebrew/test/test_software_spec.rb b/Library/Homebrew/test/test_software_spec.rb index d4b271177..e067f2f10 100644 --- a/Library/Homebrew/test/test_software_spec.rb +++ b/Library/Homebrew/test/test_software_spec.rb @@ -72,6 +72,30 @@ class SoftwareSpecTests < Homebrew::TestCase assert_equal "", @spec.options.first.description end + def test_deprecated_option + @spec.deprecated_option('foo' => 'bar') + assert @spec.deprecated_options.any? + assert_equal "foo", @spec.deprecated_options.first.old + assert_equal "bar", @spec.deprecated_options.first.current + end + + 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 + end + + def test_deprecated_option_raises_when_empty + assert_raises(ArgumentError) { @spec.deprecated_option({}) } + end + def test_depends_on @spec.depends_on('foo') assert_equal 'foo', @spec.deps.first.name |
