Sha256: c4de8a081a610c333e5ead372e7553eb9e679fb3a49cfa9264ecce5b7dd3f339

Contents?: true

Size: 1.62 KB

Versions: 18

Compression:

Stored size: 1.62 KB

Contents

require 'spec_helper'
require 'tempfile'
require 'timecop'

describe EY::Serverside::Shell do
  let(:output) { StringIO.new }

  if "".respond_to?(:force_encoding)
    it "status works for ut8" do
      shell = EY::Serverside::Shell.new(:verbose => true, :stdout => output, :stderr => output, :log_path => tmpdir.join("engineyard-serverside-#{Time.now.to_i}-#{$$}.log"), :start_time => Time.local(2008, 9, 1, 12, 10, 25))
      shell.status("\u2603".force_encoding("binary"))
    end
  end

  it "has a timestamp before each line" do
    time1 = Time.local(2008, 9, 1, 12, 0, 0)
    time2 = Time.local(2008, 9, 1, 12, 3, 5)
    time3 = Time.local(2008, 9, 1, 12, 10, 25)

    @shell = EY::Serverside::Shell.new(:verbose => true, :stdout => output, :stderr => output, :log_path => tmpdir.join("engineyard-serverside-#{Time.now.to_i}-#{$$}.log"), :start_time => time1)

    Timecop.freeze(time1) do
      @shell.debug('debug')
      @shell.notice('notice')
    end
    Timecop.freeze(time2) do
      @shell.status('STATUS')
      @shell.debug("multi\nline\ndebug")
      @shell.warning("multi\nline\nwarning")
    end
    Timecop.freeze(time3) do
      @shell.substatus("multi\nline\nsubstatus")
    end

    tstp_1 = "+    00s "
    tstp_2 = "+ 3m 05s "
    tstp_3 = "+10m 25s "
    notstp = "         "
    output.rewind
    output.read.should == <<-OUTPUT
#{notstp} debug

\e[1m\e[33m#{tstp_1} !> notice
\e[0m
\e[1m\e[37m#{tstp_2} ~> STATUS
\e[0m#{notstp} multi
#{notstp} line
#{notstp} debug

\e[1m\e[33m#{tstp_2} !> WARNING: multi
#{tstp_2} !> line
#{tstp_2} !> warning
\e[0m#{notstp}  ~ multi
#{notstp}  ~ line
#{notstp}  ~ substatus
    OUTPUT
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
engineyard-serverside-2.3.9 spec/shell_spec.rb
engineyard-serverside-2.3.7 spec/shell_spec.rb
engineyard-serverside-2.3.6 spec/shell_spec.rb
engineyard-serverside-2.3.5 spec/shell_spec.rb
engineyard-serverside-2.3.4 spec/shell_spec.rb
engineyard-serverside-2.3.3 spec/shell_spec.rb
engineyard-serverside-2.3.2 spec/shell_spec.rb
engineyard-serverside-2.3.1 spec/shell_spec.rb
engineyard-serverside-2.3.1.pre.archivefix spec/shell_spec.rb
engineyard-serverside-2.3.0 spec/shell_spec.rb
engineyard-serverside-2.2.1 spec/shell_spec.rb
engineyard-serverside-2.2.0 spec/shell_spec.rb
engineyard-serverside-2.2.0.rc2 spec/shell_spec.rb
engineyard-serverside-2.2.0.rc1 spec/shell_spec.rb
engineyard-serverside-2.2.0.pre3 spec/shell_spec.rb
engineyard-serverside-2.2.0.pre2 spec/shell_spec.rb
engineyard-serverside-2.2.0.pre spec/shell_spec.rb
engineyard-serverside-2.1.4 spec/shell_spec.rb