diff options
| author | Markus Reiter | 2017-03-04 18:37:21 +0100 |
|---|---|---|
| committer | GitHub | 2017-03-04 18:37:21 +0100 |
| commit | 370c711da23fa0f7c7944f7d15928e44a67656a9 (patch) | |
| tree | a945a042a6d4b6dd7cd8ce4e53849735e83f9226 /Library/Homebrew/cask | |
| parent | 1d216bc661169d43e00d5897f3657cb2015a76c0 (diff) | |
| parent | 40ec2974f4d164689d05fe27b52da4ebf3f4b816 (diff) | |
| download | brew-370c711da23fa0f7c7944f7d15928e44a67656a9.tar.bz2 | |
Merge pull request #2236 from reitermarkus/spec-formatter-locale
Move Formatter and Locale specs.
Diffstat (limited to 'Library/Homebrew/cask')
| -rw-r--r-- | Library/Homebrew/cask/spec/formatter_spec.rb | 55 | ||||
| -rw-r--r-- | Library/Homebrew/cask/spec/locale_spec.rb | 71 |
2 files changed, 0 insertions, 126 deletions
diff --git a/Library/Homebrew/cask/spec/formatter_spec.rb b/Library/Homebrew/cask/spec/formatter_spec.rb deleted file mode 100644 index e8bd34416..000000000 --- a/Library/Homebrew/cask/spec/formatter_spec.rb +++ /dev/null @@ -1,55 +0,0 @@ -require "utils/formatter" -require "utils/tty" - -describe Formatter do - describe "::columns" do - let(:input) { - [ - "aa", - "bbb", - "ccc", - "dd", - ] - } - subject { described_class.columns(input) } - - it "doesn't output columns if $stdout is not a TTY." do - allow_any_instance_of(IO).to receive(:tty?).and_return(false) - allow(Tty).to receive(:width).and_return(10) - - expect(subject).to eq( - "aa\n" \ - "bbb\n" \ - "ccc\n" \ - "dd\n", - ) - end - - describe "$stdout is a TTY" do - it "outputs columns" do - allow_any_instance_of(IO).to receive(:tty?).and_return(true) - allow(Tty).to receive(:width).and_return(10) - - expect(subject).to eq( - "aa ccc\n" \ - "bbb dd\n", - ) - end - - it "outputs only one line if everything fits" do - allow_any_instance_of(IO).to receive(:tty?).and_return(true) - allow(Tty).to receive(:width).and_return(20) - - expect(subject).to eq( - "aa bbb ccc dd\n", - ) - end - end - - describe "with empty input" do - let(:input) { [] } - - it { is_expected.to eq("\n") } - end - end -end diff --git a/Library/Homebrew/cask/spec/locale_spec.rb b/Library/Homebrew/cask/spec/locale_spec.rb deleted file mode 100644 index 41ca87ede..000000000 --- a/Library/Homebrew/cask/spec/locale_spec.rb +++ /dev/null @@ -1,71 +0,0 @@ -require "locale" - -describe Locale do - describe "::parse" do - it "parses a string in the correct format" do - expect(described_class.parse("zh")).to eql(described_class.new("zh", nil, nil)) - expect(described_class.parse("zh-CN")).to eql(described_class.new("zh", "CN", nil)) - expect(described_class.parse("zh-Hans")).to eql(described_class.new("zh", nil, "Hans")) - expect(described_class.parse("zh-CN-Hans")).to eql(described_class.new("zh", "CN", "Hans")) - end - - context "raises a ParserError when given" do - it "an empty string" do - expect { described_class.parse("") }.to raise_error(Locale::ParserError) - end - - it "a string in a wrong format" do - expect { described_class.parse("zh_CN_Hans") }.to raise_error(Locale::ParserError) - expect { described_class.parse("zhCNHans") }.to raise_error(Locale::ParserError) - expect { described_class.parse("zh-CN_Hans") }.to raise_error(Locale::ParserError) - expect { described_class.parse("zhCN") }.to raise_error(Locale::ParserError) - expect { described_class.parse("zh_Hans") }.to raise_error(Locale::ParserError) - end - end - end - - describe "::new" do - it "raises an ArgumentError when all arguments are nil" do - expect { described_class.new(nil, nil, nil) }.to raise_error(ArgumentError) - end - - it "raises a ParserError when one of the arguments does not match the locale format" do - expect { described_class.new("ZH", nil, nil) }.to raise_error(Locale::ParserError) - expect { described_class.new(nil, "cn", nil) }.to raise_error(Locale::ParserError) - expect { described_class.new(nil, nil, "hans") }.to raise_error(Locale::ParserError) - end - end - - subject { described_class.new("zh", "CN", "Hans") } - - describe "#include?" do - it { is_expected.to include("zh") } - it { is_expected.to include("zh-CN") } - it { is_expected.to include("CN") } - it { is_expected.to include("CN-Hans") } - it { is_expected.to include("Hans") } - it { is_expected.to include("zh-CN-Hans") } - end - - describe "#eql?" do - subject { described_class.new("zh", "CN", "Hans") } - - context "all parts match" do - it { is_expected.to eql("zh-CN-Hans") } - it { is_expected.to eql(subject) } - end - - context "only some parts match" do - it { is_expected.to_not eql("zh") } - it { is_expected.to_not eql("zh-CN") } - it { is_expected.to_not eql("CN") } - it { is_expected.to_not eql("CN-Hans") } - it { is_expected.to_not eql("Hans") } - end - - it "does not raise if 'other' cannot be parsed" do - expect { subject.eql?("zh_CN_Hans") }.not_to raise_error - expect(subject.eql?("zh_CN_Hans")).to be false - end - end -end |
