Sha256: f24a2caf97eb63bf978d2f4300496aa5c2e9c48a0e2816104547d992543f9a22

Contents?: true

Size: 1.39 KB

Versions: 2

Compression:

Stored size: 1.39 KB

Contents

require 'test_helper'

module Vedeu
    describe Store do
      before { Store.reset }

      describe '#create' do
        it 'stores the interface attributes and returns the storage collection' do
          attributes = { name: 'sulphur' }

          Store.create(attributes).must_equal({ 'sulphur' => { name: 'sulphur' } })
        end
      end

      describe '#query' do
        before do
          Store.reset
          Vedeu.interface('chlorine')
        end

        it 'returns the record when found' do
          Store.query('chlorine').must_equal(
            {
              name: 'chlorine',
              group: '',
              lines: [],
              colour: {},
              style: '',
              geometry: {},
              cursor: true,
              delay: 0.0
            }
          )
        end

        it 'raises an exception when name is empty' do
          proc { Store.query('') }.must_raise(EntityNotFound)
        end

        it 'raises an exception when name is nil' do
          proc { Store.query(nil) }.must_raise(EntityNotFound)
        end

        it 'raises an exception when the record cannot be found' do
          proc { Store.query('dummy') }.must_raise(EntityNotFound)
        end
      end

      describe '#reset' do
        it 'deletes all records stored' do
          Vedeu.interface('potassium')

          Store.reset.must_equal({})
        end
      end
    end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vedeu-0.1.15 test/lib/vedeu/models/store_test.rb
vedeu-0.1.14 test/lib/vedeu/models/store_test.rb