Sha256: 8d5a2420a32b7d0af0a558790dbdc763e310290be799833fa80cf81df882d7d0

Contents?: true

Size: 1.55 KB

Versions: 3

Compression:

Stored size: 1.55 KB

Contents

require 'test_helper'

module Vedeu
  describe Compositor do
    before { Terminal.console.stubs(:print) }

    describe '.render' do
      it 'raises an exception if the buffer/interface cannot be found' do
        proc { Compositor.render('') }.must_raise(BufferNotFound)
      end

      context 'when the buffer is nil' do
        it 'clears the defined area for the interface' do
          Vedeu.interface('xenon') do
            x      1
            y      1
            width  5
            height 3
          end

          Compositor.render('xenon').must_equal([
            "\e[1;1H     \e[1;1H" \
            "\e[2;1H     \e[2;1H" \
            "\e[3;1H     \e[3;1H" \
            "\e[?25h"
          ])
        end
      end

      context 'when the buffer is not nil' do
        it 'renders the content in the defined area for the interface' do
          Vedeu.interface('neon') do
            x      1
            y      1
            width  5
            height 3
          end

          class MyCompositorView < Vedeu::View
            def render
              view 'neon' do
                line 'argon'
                line 'boron'
                line 'radon'
              end
            end
          end

          MyCompositorView.render

          Compositor.render('neon').must_equal([
            "\e[1;1H     \e[1;1H" \
            "\e[2;1H     \e[2;1H" \
            "\e[3;1H     \e[3;1H" \
            "\e[1;1Hargon" \
            "\e[2;1Hboron" \
            "\e[3;1Hradon" \
            "\e[?25h"
          ])
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
vedeu-0.2.1 test/lib/vedeu/output/compositor_test.rb
vedeu-0.2.0 test/lib/vedeu/output/compositor_test.rb
vedeu-0.1.19 test/lib/vedeu/output/compositor_test.rb