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.4.0 spec/xcpretty/printer_spec.rb
xcpretty-security-patched-0.3.2 spec/xcpretty/printer_spec.rb
xcpretty-security-patched-0.3.0 spec/xcpretty/printer_spec.rb
xcpretty-0.3.0 spec/xcpretty/printer_spec.rb
xcpretty-0.2.8 spec/xcpretty/printer_spec.rb
xcpretty-0.2.7 spec/xcpretty/printer_spec.rb
xcpretty-0.2.6 spec/xcpretty/printer_spec.rb
xcpretty-0.2.4 spec/xcpretty/printer_spec.rb
xcpretty-0.2.3 spec/xcpretty/printer_spec.rb
xcpretty-bb-0.1.12.bb14 spec/xcpretty/printer_spec.rb
xcpretty-bb-0.1.12.bb13 spec/xcpretty/printer_spec.rb
xcpretty-bb-0.1.12.bb12 spec/xcpretty/printer_spec.rb
xcpretty-bb-0.1.12.bb11 spec/xcpretty/printer_spec.rb
xcpretty-bb-0.1.12.bb10 spec/xcpretty/printer_spec.rb
xcpretty-bb-0.1.12.bb9 spec/xcpretty/printer_spec.rb
xcpretty-bb-0.1.12.bb8 spec/xcpretty/printer_spec.rb
xcpretty-0.2.2 spec/xcpretty/printer_spec.rb
xcpretty-bb-0.1.12.bb7 spec/xcpretty/printer_spec.rb
xcpretty-0.2.1 spec/xcpretty/printer_spec.rb
xcpretty-bb-0.1.12.bb6 spec/xcpretty/printer_spec.rb