diff options
| author | Markus Reiter | 2017-03-11 11:31:32 +0100 | 
|---|---|---|
| committer | Markus Reiter | 2017-03-11 21:12:51 +0100 | 
| commit | 00306a4ced339f9bf2384a4fd94b26530995dd6c (patch) | |
| tree | a41e80276e8a4f61397746b1c6b47d581d44d177 /Library/Homebrew/test/formatter_spec.rb | |
| parent | c594ffefbc18933fbd89750a8720e1c0576f4ee7 (diff) | |
| download | brew-00306a4ced339f9bf2384a4fd94b26530995dd6c.tar.bz2 | |
Add test for `Formatter::pluralize`.
Diffstat (limited to 'Library/Homebrew/test/formatter_spec.rb')
| -rw-r--r-- | Library/Homebrew/test/formatter_spec.rb | 23 | 
1 files changed, 23 insertions, 0 deletions
| diff --git a/Library/Homebrew/test/formatter_spec.rb b/Library/Homebrew/test/formatter_spec.rb index e8bd34416..6357853d8 100644 --- a/Library/Homebrew/test/formatter_spec.rb +++ b/Library/Homebrew/test/formatter_spec.rb @@ -52,4 +52,27 @@ describe Formatter do        it { is_expected.to eq("\n") }      end    end + +  describe "::pluralize" do +    it "pluralizes words" do +      expect(described_class.pluralize(0, "cask")).to eq("0 casks") +      expect(described_class.pluralize(1, "cask")).to eq("1 cask") +      expect(described_class.pluralize(2, "cask")).to eq("2 casks") +    end + +    it "allows specifying custom plural forms" do +      expect(described_class.pluralize(1, "child", "children")).to eq("1 child") +      expect(described_class.pluralize(2, "child", "children")).to eq("2 children") +    end + +    it "has plural forms of Homebrew jargon" do +      expect(described_class.pluralize(1, "formula")).to eq("1 formula") +      expect(described_class.pluralize(2, "formula")).to eq("2 formulae") +    end + +    it "pluralizes the last word of a string" do +      expect(described_class.pluralize(1, "new formula")).to eq("1 new formula") +      expect(described_class.pluralize(2, "new formula")).to eq("2 new formulae") +    end +  end  end | 
