Sha256: 4c3be415c7764f69e10ac8651f8ea15cf76273b551582f8bc5eff7608643fcc7

Contents?: true

Size: 1.75 KB

Versions: 134

Compression:

Stored size: 1.75 KB

Contents

require 'recog/formatter'

describe Recog::Formatter do
  let(:output) { StringIO.new }

  context "with no color" do
    subject { Recog::Formatter.new(double(color: false), output) }

    describe "#message" do
      it "outputs the text" do
        subject.status_message 'some text'
        expect(output.string).to eq("some text\n")
      end
    end

    describe "#success_message" do
      it "outputs the text" do
        subject.success_message 'a success'
        expect(output.string).to eq("a success\n")
      end
    end

    describe "#warning_message" do
      it "outputs the text" do
        subject.warning_message 'a warning'
        expect(output.string).to eq("a warning\n")
      end
    end

    describe "#failure_message" do
      it "outputs the text" do
        subject.failure_message 'a failure'
        expect(output.string).to eq("a failure\n")
      end
    end
  end

  context "with color" do
    subject { Recog::Formatter.new(double(color: true), output) }

    describe "#message" do
      it "outputs the text in white" do
        subject.status_message 'some text'
        expect(output.string).to eq("\e[15msome text\e[0m\n")
      end
    end

    describe "#success_message" do
      it "outputs the text in green" do
        subject.success_message 'a success'
        expect(output.string).to eq("\e[32ma success\e[0m\n")
      end
    end

    describe "#warning_message" do
      it "outputs the text in yellow" do
        subject.warning_message 'a warning'
        expect(output.string).to eq("\e[33ma warning\e[0m\n")
      end
    end

    describe "#failure_message" do
      it "outputs the text in red" do
        subject.failure_message 'a failure'
        expect(output.string).to eq("\e[31ma failure\e[0m\n")
      end
    end
  end
end

Version data entries

134 entries across 134 versions & 2 rubygems

Version Path
recog-3.1.1 spec/lib/recog/formatter_spec.rb
recog-3.1.0 spec/lib/recog/formatter_spec.rb
recog-3.0.3 spec/lib/recog/formatter_spec.rb
recog-3.0.2 spec/lib/recog/formatter_spec.rb
recog-3.0.1 spec/lib/recog/formatter_spec.rb
recog-2.3.23 spec/lib/recog/formatter_spec.rb
recog-2.3.22 spec/lib/recog/formatter_spec.rb
recog-2.3.21 spec/lib/recog/formatter_spec.rb
recog-2.3.20 spec/lib/recog/formatter_spec.rb
recog-2.3.19 spec/lib/recog/formatter_spec.rb
recog-2.3.18 spec/lib/recog/formatter_spec.rb
recog-2.3.17 spec/lib/recog/formatter_spec.rb
recog-2.3.16 spec/lib/recog/formatter_spec.rb
recog-2.3.15 spec/lib/recog/formatter_spec.rb
recog-intrigue-2.3.14 spec/lib/recog/formatter_spec.rb
recog-2.3.14 spec/lib/recog/formatter_spec.rb
recog-2.3.13 spec/lib/recog/formatter_spec.rb
recog-2.3.12 spec/lib/recog/formatter_spec.rb
recog-2.3.11 spec/lib/recog/formatter_spec.rb
recog-2.3.10 spec/lib/recog/formatter_spec.rb