aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/test/descriptions_spec.rb42
-rw-r--r--Library/Homebrew/test/descriptions_test.rb48
2 files changed, 42 insertions, 48 deletions
diff --git a/Library/Homebrew/test/descriptions_spec.rb b/Library/Homebrew/test/descriptions_spec.rb
new file mode 100644
index 000000000..e873c73b4
--- /dev/null
+++ b/Library/Homebrew/test/descriptions_spec.rb
@@ -0,0 +1,42 @@
+require "descriptions"
+
+describe Descriptions do
+ subject { described_class.new(descriptions_hash) }
+ let(:descriptions_hash) { {} }
+
+ it "can print description for a core Formula" do
+ descriptions_hash["homebrew/core/foo"] = "Core foo"
+ expect { subject.print }.to output("foo: Core foo\n").to_stdout
+ end
+
+ it "can print description for an external Formula" do
+ descriptions_hash["somedev/external/foo"] = "External foo"
+ expect { subject.print }.to output("foo: External foo\n").to_stdout
+ end
+
+ it "can print descriptions for duplicate Formulae" do
+ descriptions_hash["homebrew/core/foo"] = "Core foo"
+ descriptions_hash["somedev/external/foo"] = "External foo"
+
+ expect { subject.print }.to output(
+ <<-EOS.undent
+ homebrew/core/foo: Core foo
+ somedev/external/foo: External foo
+ EOS
+ ).to_stdout
+ end
+
+ it "can print descriptions for duplicate core and external Formulae" do
+ descriptions_hash["homebrew/core/foo"] = "Core foo"
+ descriptions_hash["somedev/external/foo"] = "External foo"
+ descriptions_hash["otherdev/external/foo"] = "Other external foo"
+
+ expect { subject.print }.to output(
+ <<-EOS.undent
+ homebrew/core/foo: Core foo
+ otherdev/external/foo: Other external foo
+ somedev/external/foo: External foo
+ EOS
+ ).to_stdout
+ end
+end
diff --git a/Library/Homebrew/test/descriptions_test.rb b/Library/Homebrew/test/descriptions_test.rb
deleted file mode 100644
index baeeb7b19..000000000
--- a/Library/Homebrew/test/descriptions_test.rb
+++ /dev/null
@@ -1,48 +0,0 @@
-require "testing_env"
-require "descriptions"
-
-class DescriptionsTest < Homebrew::TestCase
- def setup
- super
-
- @descriptions_hash = {}
- @descriptions = Descriptions.new(@descriptions_hash)
-
- @old_stdout = $stdout
- $stdout = StringIO.new
- end
-
- def teardown
- $stdout = @old_stdout
- super
- 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