BigW Consortium Gitlab

message_spec.rb 1.07 KB
Newer Older
1 2 3 4 5 6 7
require 'spec_helper'

describe Gitlab::DowntimeCheck::Message do
  describe '#to_s' do
    it 'returns an ANSI formatted String for an offline migration' do
      message = described_class.new('foo.rb', true, 'hello')

8
      expect(message.to_s).to eq("[\e[31moffline\e[0m]: foo.rb:\n\nhello\n\n")
9 10 11 12 13
    end

    it 'returns an ANSI formatted String for an online migration' do
      message = described_class.new('foo.rb')

14
      expect(message.to_s).to eq("[\e[32monline\e[0m]: foo.rb")
15 16
    end
  end
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38

  describe '#reason?' do
    it 'returns false when no reason is specified' do
      message = described_class.new('foo.rb')

      expect(message.reason?).to eq(false)
    end

    it 'returns true when a reason is specified' do
      message = described_class.new('foo.rb', true, 'hello')

      expect(message.reason?).to eq(true)
    end
  end

  describe '#reason' do
    it 'strips excessive whitespace from the returned String' do
      message = described_class.new('foo.rb', true, " hello\n world\n\n foo")

      expect(message.reason).to eq("hello\nworld\n\nfoo")
    end
  end
39
end