Sha256: 7810b384e74b56be9bcdf5c45f6475a2f131e1a8e531d093f2f5554b0e912b29

Contents?: true

Size: 1.21 KB

Versions: 18

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

18 entries across 18 versions & 2 rubygems

Version Path
learn-xcpretty-0.1.12 spec/xcpretty/printer_spec.rb
xcpretty-0.1.12 spec/xcpretty/printer_spec.rb
xcpretty-0.1.11 spec/xcpretty/printer_spec.rb
xcpretty-0.1.10 spec/xcpretty/printer_spec.rb
learn-xcpretty-0.1.11 spec/xcpretty/printer_spec.rb
xcpretty-0.1.9 spec/xcpretty/printer_spec.rb
xcpretty-0.1.8 spec/xcpretty/printer_spec.rb
xcpretty-0.1.7 spec/xcpretty/printer_spec.rb
xcpretty-0.1.6 spec/xcpretty/printer_spec.rb
xcpretty-0.1.5 spec/xcpretty/printer_spec.rb
xcpretty-0.1.4 spec/xcpretty/printer_spec.rb
xcpretty-0.1.3 spec/xcpretty/printer_spec.rb
xcpretty-0.1.2 spec/xcpretty/printer_spec.rb
xcpretty-0.1.1 spec/xcpretty/printer_spec.rb
xcpretty-0.1.0 spec/xcpretty/printer_spec.rb
xcpretty-0.0.9 spec/xcpretty/printer_spec.rb
xcpretty-0.0.8 spec/xcpretty/printer_spec.rb
xcpretty-0.0.7 spec/xcpretty/printer_spec.rb