Sha256: ef8907797ca369e2f8b04e0879ba252d330216ea4fa8793122c7a2858b89b1af

Contents?: true

Size: 1.21 KB

Versions: 26

Compression:

Stored size: 1.21 KB

Contents

require "xcpretty/printer"
require 'xcpretty/formatters/formatter'
require 'xcpretty/formatters/simple'

module XCPretty
  describe Printer do

    before(:each) do
      STDOUT.stub(:print) { |text| text }
      @printer = Printer.new(colorize: true, unicode: true, formatter: DummyFormatter)
    end

    it "prints to stdout" do
      STDOUT.should receive(:print).with("hey ho let's go\n")
      @printer.pretty_print("hey ho let's go")
    end

    it "doesn't print empty lines" do
      STDOUT.should_not receive(:print)
      @printer.pretty_print("")
    end

    it "prints with newlines only when needed" do
      @printer.formatter.stub(:optional_newline).and_return("")

      STDOUT.should receive(:print).with("hey ho let's go")
      @printer.pretty_print("hey ho let's go")
    end

    it "makes a formatter with unicode and colorized flags" do
      @printer.formatter.colorize?.should == true
      @printer.formatter.use_unicode?.should == true
    end

  end
end

module XCPretty
  class DummyFormatter < Formatter

    def initialize(unicode, colorize)
      @use_unicode = unicode
      @colorize = colorize
    end

    def pretty_format(text)
      text
    end

    def optional_newline
      "\n"
    end
  end
end

Version data entries

26 entries across 26 versions & 3 rubygems

Version Path
xcpretty-0.2.0 spec/xcpretty/printer_spec.rb
xcpretty-bb-0.1.12.bb5 spec/xcpretty/printer_spec.rb
xcpretty-bb-0.1.12.bb4 spec/xcpretty/printer_spec.rb
xcpretty-bb-0.1.12.bb3 spec/xcpretty/printer_spec.rb
xcpretty-bb-0.1.12.bb2 spec/xcpretty/printer_spec.rb
xcpretty-bb-0.1.12.bb1 spec/xcpretty/printer_spec.rb