Sha256: 11afb347525760e0f45e5cf0a28298e758835f8a86f7e014bde1cc93f35c58b9

Contents?: true

Size: 1.78 KB

Versions: 4

Compression:

Stored size: 1.78 KB

Contents

require_relative '../../../test_helper'

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

    before { InterfaceRepository.create({ name: 'dummy', width: 15, height: 2 }) }
    after  { InterfaceRepository.reset }

    describe '.find' do
      let(:subject) { described_class.find(value) }
      let(:value)   { 'dummy' }

      context 'when the interface exists' do
        it 'returns an Interface' do
          subject.must_be_instance_of(Interface)
        end
      end

      context 'when the interface does not exist' do
        before { InterfaceRepository.reset }

        it 'raises an exception' do
          proc { subject }.must_raise(UndefinedInterface)
        end
      end
    end

    describe '.refresh' do
      let(:subject) { described_class.refresh }

      before { Compositor.stubs(:arrange) }

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

    describe '.entity' do
      let(:subject) { described_class.entity }

      it 'returns an Interface' do
        subject.must_equal(Interface)
      end
    end

    describe '.by_layer' do
      let(:subject) { described_class.by_layer }

      before do
        InterfaceRepository.reset
        @case_a = InterfaceRepository.create({ name: 'a', width: 15, height: 2, layer: 1 })
        @case_b = InterfaceRepository.create({ name: 'b', width: 15, height: 2, layer: 0 })
        @case_c = InterfaceRepository.create({ name: 'c', width: 15, height: 2, layer: 2 })
      end
      after  { InterfaceRepository.reset }

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

      it 'returns the collection in order they should be drawn' do
        subject.must_equal([@case_b, @case_a, @case_c])
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
vedeu-0.0.25 test/lib/vedeu/repository/interface_repository_test.rb
vedeu-0.0.24 test/lib/vedeu/repository/interface_repository_test.rb
vedeu-0.0.23 test/lib/vedeu/repository/interface_repository_test.rb
vedeu-0.0.22 test/lib/vedeu/repository/interface_repository_test.rb