aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorJosh Hagins2016-04-14 11:48:04 -0400
committerBaptiste Fontaine2016-04-16 16:15:08 +0200
commit0fe6acea3a2552c08a21952db8ac8f0a1df555b2 (patch)
treeada22bc168f945d14e89bf617f2c744f189392c1 /Library
parentbad28dc5460aa5bbe4d620bc4362b6cc1239bff3 (diff)
downloadbrew-0fe6acea3a2552c08a21952db8ac8f0a1df555b2.tar.bz2
tests: ensure desc prints short name only if there are conflicts
Fixes #70. Signed-off-by: Baptiste Fontaine <batifon@yahoo.fr>
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/test/test_descriptions.rb45
1 files changed, 45 insertions, 0 deletions
diff --git a/Library/Homebrew/test/test_descriptions.rb b/Library/Homebrew/test/test_descriptions.rb
new file mode 100644
index 000000000..de38fdbd1
--- /dev/null
+++ b/Library/Homebrew/test/test_descriptions.rb
@@ -0,0 +1,45 @@
+require "testing_env"
+require "descriptions"
+
+class DescriptionsTest < Homebrew::TestCase
+ def setup
+ @descriptions_hash = {}
+ @descriptions = Descriptions.new(@descriptions_hash)
+
+ @old_stdout = $stdout
+ $stdout = StringIO.new
+ end
+
+ def teardown
+ $stdout = @old_stdout
+ end
+
+ def test_single_core_formula
+ @descriptions_hash["homebrew/core/foo"] = "Core foo"
+ @descriptions.print
+ assert_equal "foo: Core foo", $stdout.string.chomp
+ end
+
+ def test_single_external_formula
+ @descriptions_hash["somedev/external/foo"] = "External foo"
+ @descriptions.print
+ assert_equal "foo: External foo", $stdout.string.chomp
+ end
+
+ def test_even_dupes
+ @descriptions_hash["homebrew/core/foo"] = "Core foo"
+ @descriptions_hash["somedev/external/foo"] = "External foo"
+ @descriptions.print
+ assert_equal "homebrew/core/foo: Core foo\nsomedev/external/foo: External foo",
+ $stdout.string.chomp
+ end
+
+ def test_odd_dupes
+ @descriptions_hash["homebrew/core/foo"] = "Core foo"
+ @descriptions_hash["somedev/external/foo"] = "External foo"
+ @descriptions_hash["otherdev/external/foo"] = "Other external foo"
+ @descriptions.print
+ assert_equal "homebrew/core/foo: Core foo\notherdev/external/foo: Other external foo\nsomedev/external/foo: External foo",
+ $stdout.string.chomp
+ end
+end