Sha256: 282296af7e6e0cc678fb51beae6ae86ade085e505d47349f03341b38d52b6aad

Contents?: true

Size: 1.31 KB

Versions: 2

Compression:

Stored size: 1.31 KB

Contents

require 'test_helper'

module Vedeu

  describe Interfaces do

    describe '#add' do
      before { Interfaces.reset }

      it 'adds the interface to the storage' do
        Interfaces.add({ name: 'germanium' })
        Interfaces.all.must_equal({ 'germanium' => { name: 'germanium' } })
      end

      it 'raises an exception if the attributes does not have a :name key' do
        attributes = { no_name_key: '' }

        proc { Interfaces.add(attributes) }.must_raise(MissingRequired)
      end
    end

    describe '#build' do
      let(:attributes) { { name: 'rhenium' } }

      before { Interfaces.add(attributes) }
      after  { Interfaces.reset }

      it 'returns a new instance of Interface based on the stored attributes' do
        Interfaces.build('rhenium').must_be_instance_of(Interface)
      end

      context 'when the interface cannot be found' do
        it 'raises an exception' do
          proc { Interfaces.build('manganese') }.must_raise(ModelNotFound)
        end
      end
    end

    describe '#reset' do
      before { Interfaces.reset }

      it 'removes all known interfaces from the storage' do
        Interfaces.add({ name: 'bromine' })
        Interfaces.all.must_equal({ 'bromine' => { name: 'bromine' } })
        Interfaces.reset.must_be_empty
      end
    end

  end # Interfaces

end # Vedeu

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vedeu-0.2.12 test/lib/vedeu/repositories/interfaces_test.rb
vedeu-0.2.11 test/lib/vedeu/repositories/interfaces_test.rb