Sha256: 31d328b2b78e59157cf4d51a0c29a1f60a94e8c8a9dcde9c06350a56ee779cd0

Contents?: true

Size: 1.66 KB

Versions: 5

Compression:

Stored size: 1.66 KB

Contents

require_relative '../../../test_helper'
require_relative '../../../../lib/vedeu/models/line_collection'
require_relative '../../../../lib/vedeu/models/interface'

module Vedeu
  describe LineCollection do
    let(:described_class) { LineCollection }

    describe '#coerce' do
      let(:subject) { Vedeu::Interface.new({ lines: lines }).lines }
      let(:lines) {}

      context 'when there are no lines' do
        it 'returns a Array' do
          subject.must_be_instance_of(Array)
        end

        it 'returns an empty array' do
          subject.must_equal([])
        end
      end

      context 'when the line is just a String' do
        let(:lines) { 'some text' }

        it 'returns an Array' do
          subject.must_be_instance_of(Array)
        end

        it 'contains a single Line object' do
          subject.size.must_equal(1)
        end
      end

      context 'when there is a single line' do
        let(:lines) { { streams: { text: 'some text' } } }

        it 'returns an Array' do
          subject.must_be_instance_of(Array)
        end

        it 'contains a single Line object' do
          subject.size.must_equal(1)
        end
      end

      context 'when there are multiple lines' do
        let(:lines) {
          [
            { text: 'some text' },
            { text: 'some more text' }
          ]
        }

        it 'returns an Array' do
          subject.must_be_instance_of(Array)
        end

        it 'returns a collection of Line objects' do
          subject.first.must_be_instance_of(Line)
        end

        it 'contains multiple Line objects' do
          subject.size.must_equal(2)
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
vedeu-0.0.30 test/lib/vedeu/models/line_collection_test.rb
vedeu-0.0.29 test/lib/vedeu/models/line_collection_test.rb
vedeu-0.0.28 test/lib/vedeu/models/line_collection_test.rb
vedeu-0.0.27 test/lib/vedeu/models/line_collection_test.rb
vedeu-0.0.26 test/lib/vedeu/models/line_collection_test.rb