Sha256: fff9711f0dfcaeae466a0e0bc4f11c18f5c94a86613b5e837b693243d0a51d3f

Contents?: true

Size: 1.15 KB

Versions: 2

Compression:

Stored size: 1.15 KB

Contents

require 'test_helper'

module Vedeu
  module API
    describe Store do
      before { Store.reset }

      describe '#create' do
        it 'creates and returns the stored record' do
          attributes = { name: 'sulphur' }

          Store.create(attributes).must_equal({ 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', geometry: {} })
        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
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vedeu-0.1.12 test/lib/vedeu/api/store_test.rb
vedeu-0.1.10 test/lib/vedeu/api/store_test.rb