Sha256: ba7855693a885dc1cc46eee61b8aabe53a1cba9bda07a7c42510eb8b98e4188a

Contents?: true

Size: 1.07 KB

Versions: 3

Compression:

Stored size: 1.07 KB

Contents

require 'spec/spec_helper'
require 'lib/stowaway/output'

describe Stowaway::Output do

  before(:each) do
    @klass = Class.new do
      include Stowaway::Output
    end.new
  end

  describe "clr_print" do
    it "should reset current line and print message" do
      reset = "\r\e[0K"
      msg = "yo yo sucka beeches!"
      @klass.should_receive(:print).once.with("#{reset}#{msg}")
      @klass.clr_print(msg)
    end
  end

  describe "flush" do
    it "should reset current line" do
      @klass.should_receive(:print).once.with("\r\e[0K")
      @klass.flush
    end

    it "should call flush on stdout" do
      $stdout.should_receive(:flush)
      @klass.flush
    end
  end

  describe "new_line" do
    it "should print 1 new line" do
      @klass.should_receive(:print).once.with("\n")
      @klass.new_line
    end

    it "should print 2 new lines" do
      @klass.should_receive(:print).twice.with("\n")
      @klass.new_line(2)
    end

    it "should print 8 new lines" do
      @klass.should_receive(:print).exactly(8).times.with("\n")
      @klass.new_line(8)
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
stowaway-0.2.5 spec/lib/output_spec.rb
stowaway-0.2.2 spec/lib/output_spec.rb
stowaway-0.2.0 spec/lib/output_spec.rb