Sha256: 7f2b72c831103f59a70644973f336a198802545bb9ba9f4862ec45ff5bf5bea4

Contents?: true

Size: 1.97 KB

Versions: 1

Compression:

Stored size: 1.97 KB

Contents

require File.expand_path(File.dirname(__FILE__) + "/../../../example_helper")

describe Micronaut::Formatters::ProgressFormatter do
  
  before do
    @output = StringIO.new
    @formatter = Micronaut::Formatters::ProgressFormatter.new
    @formatter.stubs(:color_enabled?).returns(false)
    @formatter.stubs(:output).returns(@output)
  end

  it "should produce line break on start dump" do
    @formatter.start_dump
    @output.string.should == "\n"
  end

  it "should produce standard summary without pending when pending has a 0 count" do
    @formatter.dump_summary(3, 2, 1, 0)
    @output.string.should =~ /Finished in 3 seconds\n2 examples, 1 failures/i
  end
  
  it "should produce standard summary" do
    @formatter.example_pending(running_example, "message")
    @output.rewind
    @formatter.dump_summary(3, 2, 1, 1)
    @output.string.should =~ /Finished in 3 seconds\n2 examples, 1 failures, 1 pending/i
  end
  
  describe "when color is enabled" do
    
    before do
      @formatter.stubs(:color_enabled?).returns(true)
    end

    it "should output a green dot for passing spec" do
      @formatter.example_passed("spec")
      @output.string.should == "\e[32m.\e[0m"
    end

    it "should push red F for failure spec" do
      @formatter.example_failed("spec", Micronaut::Expectations::ExpectationNotMetError.new)
      @output.string.should == "\e[31mF\e[0m"
    end

    it "should push magenta F for error spec" do
      @formatter.example_failed("spec", RuntimeError.new)
      @output.string.should == "\e[35mF\e[0m"
    end
    
  end
  
  it "should push nothing on start" do
    @formatter.start(4)
    @output.string.should == ""
  end

  it "should ensure two ':' in the first backtrace" do
    backtrace = ["/tmp/x.rb:1", "/tmp/x.rb:2", "/tmp/x.rb:3"]
    @formatter.format_backtrace(backtrace).should == "/tmp/x.rb:1"

    backtrace = ["/tmp/x.rb:1: message", "/tmp/x.rb:2", "/tmp/x.rb:3"]
    @formatter.format_backtrace(backtrace).should == "/tmp/x.rb:1: message"
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spicycode-micronaut-0.1.4.3 examples/lib/micronaut/formatters/progress_formatter_example.rb