Sha256: eb07a26e495cfde04a364600370ea8089e9665c02bd32c989ff8d27a1c045800

Contents?: true

Size: 715 Bytes

Versions: 2

Compression:

Stored size: 715 Bytes

Contents

# -*- encoding : utf-8 -*-
require 'megingiard/ansi_escape_sequence'

describe Megingiard::AnsiEscapeSequence do
  let(:code) { double('Integer', to_s: code_as_string) }
  let(:code_as_string) { '1' }
  let(:validator) { double }

  subject { Megingiard::AnsiEscapeSequence.new(code) }

  before do
    allow(Megingiard::AnsiEscapeCodeValidator).to receive(:instance)
      .and_return(validator)
    allow(validator).to receive(:validate)
  end

  describe 'to_s' do
    it 'should convert the code into a string' do
      expect(code).to receive(:to_s)
      subject.to_s
    end

    it 'should return the code as an escape sequence' do
      expect(subject.to_s).to eq "\e[#{code_as_string}m"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
megingiard-0.1.0 spec/unit/ansi_escape_sequence/to_s_spec.rb
megingiard-0.0.1 spec/unit/ansi_escape_sequence/to_s_spec.rb