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/test/formatter_spec.rb | |
| 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/test/formatter_spec.rb')
| -rw-r--r-- | Library/Homebrew/test/formatter_spec.rb | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/Library/Homebrew/test/formatter_spec.rb b/Library/Homebrew/test/formatter_spec.rb new file mode 100644 index 000000000..e8bd34416 --- /dev/null +++ b/Library/Homebrew/test/formatter_spec.rb @@ -0,0 +1,55 @@ +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 |
