Sha256: 9c4ea9459dc8254a2e2693d1125bbd220ed8a0113c66d36a01d2277d235949eb

Contents?: true

Size: 1.84 KB

Versions: 7

Compression:

Stored size: 1.84 KB

Contents

require 'test_helper'

module Vedeu

  describe Viewport do

    let(:interface) {
      Interface.new({
        name:     'fluorine',
        geometry: {
          width:  30,
          height: 2,
        },
        lines: [
          {
            streams: [{
              text: 'Something interesting ',
            },{
              text: 'on this line ',
            },{
              text: 'would be cool, eh?'
            }]
          }, {
            streams: [{
              text: 'Maybe a lyric, a little ditty ',
            },{
              text: 'to help you unwind.',
            }]
          }
        ]
      })
    }

    describe '#initialize' do
      it 'returns an instance of itself' do
        Viewport.new(interface).must_be_instance_of(Viewport)
      end
    end

    describe '.show' do
      it 'returns an Array' do
        Viewport.show(interface).must_be_instance_of(Array)
      end

      context 'when there is no content' do
        before { interface.stubs(:content).returns([]) }

        it 'returns an empty collection' do
          Viewport.show(interface).must_equal([])
        end
      end

      context 'when there is content, it returns only the visible content '  \
              'determined by the geometry of the interface and the current ' \
              'offset stored' do
        it 'returns a collection of lines, each a collection of characters' do
          Viewport.show(interface).must_equal(
            [
              ['S', 'o', 'm', 'e', 't', 'h', 'i', 'n', 'g', ' ', 'i', 'n', 't', 'e', 'r', 'e', 's', 't', 'i', 'n', 'g', ' ', 'o', 'n', ' ', 't', 'h', 'i', 's', ' '],
              ['M', 'a', 'y', 'b', 'e', ' ', 'a', ' ', 'l', 'y', 'r', 'i', 'c', ',', ' ', 'a', ' ', 'l', 'i', 't', 't', 'l', 'e', ' ', 'd', 'i', 't', 't', 'y', ' ']
            ]
          )
        end
      end
    end

  end # Viewport

end # Vedeu

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
vedeu-0.2.11 test/lib/vedeu/output/viewport_test.rb
vedeu-0.2.10 test/lib/vedeu/output/viewport_test.rb
vedeu-0.2.9 test/lib/vedeu/output/viewport_test.rb
vedeu-0.2.8 test/lib/vedeu/output/viewport_test.rb
vedeu-0.2.7 test/lib/vedeu/output/viewport_test.rb
vedeu-0.2.6 test/lib/vedeu/output/viewport_test.rb
vedeu-0.2.5 test/lib/vedeu/output/viewport_test.rb