Sha256: ec6f5c3372497682f074702937049b0344e8ff261de72424ec05fd5f2c7681d2

Contents?: true

Size: 1.63 KB

Versions: 11

Compression:

Stored size: 1.63 KB

Contents

require File.dirname(__FILE__) + '/../../spec_helper'
require 'mspec/runner/formatters/describe'
require 'mspec/runner/example'

describe DescribeFormatter, "#finish" do
  before :each do
    MSpec.stub!(:register)
    MSpec.stub!(:unregister)

    @timer = mock("timer", :null_object => true)
    TimerAction.stub!(:new).and_return(@timer)
    @timer.stub!(:format).and_return("Finished in 2.0 seconds")

    $stdout = @out = IOStub.new
    context = ContextState.new "Class#method"
    @state = ExampleState.new(context, "runs")

    @formatter = DescribeFormatter.new
    @formatter.register

    @tally = @formatter.tally
    @counter = @tally.counter

    @counter.files!
    @counter.examples!
    @counter.expectations! 2
  end

  after :each do
    $stdout = STDOUT
  end

  it "prints a summary of elapsed time" do
    @formatter.finish
    @out.should =~ /^Finished in 2.0 seconds$/
  end

  it "prints a tally of counts" do
    @formatter.finish
    @out.should =~ /^1 file, 1 example, 2 expectations, 0 failures, 0 errors$/
  end

  it "does not print exceptions" do
    @formatter.finish
    @out.should == %[

Finished in 2.0 seconds

1 file, 1 example, 2 expectations, 0 failures, 0 errors
]
  end

  it "prints a summary of failures and errors for each describe block" do
    exc = ExceptionState.new @state, nil, MSpecExampleError.new("broken")
    exc.stub!(:backtrace).and_return("path/to/some/file.rb:35:in method")
    @formatter.exception exc
    @formatter.finish
    @out.should == %[

Class#method                             0 failures, 1 error

Finished in 2.0 seconds

1 file, 1 example, 2 expectations, 0 failures, 0 errors
]
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
mspec-1.5.17 spec/runner/formatters/describe_spec.rb
mspec-1.5.16 spec/runner/formatters/describe_spec.rb
mspec-1.5.15 spec/runner/formatters/describe_spec.rb
mspec-1.5.14 spec/runner/formatters/describe_spec.rb
mspec-1.5.13 spec/runner/formatters/describe_spec.rb
mspec-1.5.12 spec/runner/formatters/describe_spec.rb
mspec-1.5.10 spec/runner/formatters/describe_spec.rb
mspec-1.5.11 spec/runner/formatters/describe_spec.rb
mspec-1.5.9 spec/runner/formatters/describe_spec.rb
mspec-1.5.7 spec/runner/formatters/describe_spec.rb
mspec-1.5.8 spec/runner/formatters/describe_spec.rb