Skip to content
This repository
tree: 0e850f7575
Fetching contributors…

Cannot retrieve contributors at this time

file 43 lines (36 sloc) 1.325 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
require "spec_helper"

module RSpec::Core::Formatters

  describe BaseTextFormatter do
    describe "#summary_line" do
      let(:output) { StringIO.new }
      let(:formatter) { RSpec::Core::Formatters::BaseTextFormatter.new(output) }

      context "with 0s" do
        it "outputs pluralized (excluding pending)" do
          formatter.summary_line(0,0,0).should eq("0 examples, 0 failures")
        end
      end

      context "with 1s" do
        it "outputs singular (including pending)" do
          formatter.summary_line(1,1,1).should eq("1 example, 1 failure, 1 pending")
        end
      end

      context "with 2s" do
        it "outputs pluralized (including pending)" do
          formatter.summary_line(2,2,2).should eq("2 examples, 2 failures, 2 pending")
        end
      end
    end

    describe "#dump_failures" do
      it "preserves formatting" do
        output = StringIO.new
        group = RSpec::Core::ExampleGroup.describe
        example = group.example { "this".should eq("that") }
        formatter = RSpec::Core::Formatters::BaseTextFormatter.new(output)
        group.run_all(formatter)

        RSpec.configuration.stub(:color_enabled?) { false }
        formatter.dump_failures
        output.string.should =~ /(\s+)expected \"that\"\n\1 got \"this\"/m
      end
    end
  end
end
Something went wrong with that request. Please try again.