Sha256: d154b86b3319987aa55f5eca300f70adc3c3601133a89f0ba07c85f26f64b982

Contents?: true

Size: 1.5 KB

Versions: 2

Compression:

Stored size: 1.5 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"
          ])
        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"
          ])
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vedeu-0.2.3 test/lib/vedeu/output/compositor_test.rb
vedeu-0.2.2 test/lib/vedeu/output/compositor_test.rb