Sha256: b27422096725792601482d119d2bf44b01c137a77def6b996f16e6a061870f53

Contents?: true

Size: 1.84 KB

Versions: 16

Compression:

Stored size: 1.84 KB

Contents

require 'spec_helper'

describe Konacha::Formatter do
  let(:io) { StringIO.new }
  subject { described_class.new(io) }

  shared_examples "test result" do |method, dot|
    it "stores the example in the examples array" do
      subject.send(method, nil)
      subject.examples.should be_present
    end
    
    it "outputs the dot" do
      subject.send(method, nil)
      io.rewind
      io.read.should include(dot)
    end
  end

  describe "#example_passed" do
    it_behaves_like "test result", :example_passed, "."
  end

  describe "#example_failed" do
    it_behaves_like "test result", :example_failed, "F"
  end

  describe "#example_pending" do
    it_behaves_like "test result", :example_pending, "P"
  end

  describe "#dump_pending" do
    let(:example) { double('example', :pending? => true, :full_description => "Pending example") }
    before { subject.stub(:examples => [example]) }

    it "outputs the pending message" do
      subject.dump_pending
      io.rewind
      io.read.should include("  Pending: Pending example")
    end
  end

  describe "#dump_failures" do
    let(:example) do
      double('example',
             :failed?            => true,
             :full_description   => "Failed example",
             :exception          => double('exception',
                                           :message   => "exception",
                                           :backtrace => nil))
    end

    before { subject.stub(:examples => [example]) }

    it "outputs the failure message" do
      subject.dump_failures
      io.rewind
      io.read.should include("  Failed: Failed example\n    exception")
    end
  end

  describe "#dump_summary" do
    it "outputs the summary" do
      subject.dump_summary(10, 10, 2, 3)
      io.rewind
      io.read.should == "\nFinished in 10.00 seconds\n10 examples, 2 failed, 3 pending\n"
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
konacha-3.2.3 spec/formatter_spec.rb
konacha-3.2.2 spec/formatter_spec.rb
konacha-3.2.1 spec/formatter_spec.rb
konacha-3.2.0 spec/formatter_spec.rb
konacha-3.1.0 spec/formatter_spec.rb
konacha-3.0.0 spec/formatter_spec.rb
konacha-2.7.0 spec/formatter_spec.rb
konacha-2.6.0 spec/formatter_spec.rb
konacha-2.5.1 spec/formatter_spec.rb
konacha-2.5.0 spec/formatter_spec.rb
konacha-2.4.0 spec/formatter_spec.rb
konacha-2.3.0 spec/formatter_spec.rb
konacha-2.2.0 spec/formatter_spec.rb
konacha-2.1.0 spec/formatter_spec.rb
konacha-2.0.0 spec/formatter_spec.rb
konacha-2.0.0.beta3 spec/formatter_spec.rb