From 66735b91a316e2d56ad484699178496da5c83656 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 15 Feb 2017 03:33:21 +0100 Subject: [PATCH] Convert Descriptions test to spec. --- Library/Homebrew/test/descriptions_spec.rb | 42 +++++++++++++++++++ Library/Homebrew/test/descriptions_test.rb | 48 ---------------------- 2 files changed, 42 insertions(+), 48 deletions(-) create mode 100644 Library/Homebrew/test/descriptions_spec.rb delete mode 100644 Library/Homebrew/test/descriptions_test.rb diff --git a/Library/Homebrew/test/descriptions_spec.rb b/Library/Homebrew/test/descriptions_spec.rb new file mode 100644 index 0000000000..e873c73b46 --- /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 baeeb7b192..0000000000 --- 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