Sha256: c67b2040b6ff4070bb57b98e8c221dff52d386d039b77fc998a18d8572778378

Contents?: true

Size: 1.87 KB

Versions: 1

Compression:

Stored size: 1.87 KB

Contents

require 'test_helper'

module Vedeu

  describe Registrar do

    before do
      Buffers.reset
      Interfaces.reset
      Groups.reset
      Focus.reset
    end

    describe '.record' do
      let(:attributes) {
        {
          name:  'mendelevium',
          group: 'elements'
        }
      }

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

        proc { Registrar.record(attributes) }.must_raise(MissingRequired)
      end

      it 'raises an exception if the value for :name is nil' do
        attributes = { name: nil }

        proc { Registrar.record(attributes) }.must_raise(MissingRequired)
      end

      it 'raises an exception if the value for :name is empty' do
        attributes = { name: '' }

        proc { Registrar.record(attributes) }.must_raise(MissingRequired)
      end

      it 'sends the attributes to the Buffers repository' do
        Registrar.record(attributes)

        Buffers.registered?('mendelevium').must_equal(true)
      end

      it 'sends the attributes to the Offsets repository' do
        Registrar.record(attributes)

        Offsets.registered?('mendelevium').must_equal(true)
      end

      it 'sends the attributes to the Interfaces repository' do
        Registrar.record(attributes)

        Interfaces.registered?('mendelevium').must_equal(true)
      end

      it 'sends the attributes to the Cursors repository' do
        Registrar.record(attributes)

        Cursors.registered?('mendelevium').must_equal(true)
      end

      it 'sends the attributes to the Groups repository' do
        Registrar.record(attributes)

        Groups.registered?('elements').must_equal(true)
      end

      it 'sends the attributes to the Focus repository' do
        Registrar.record(attributes)

        Focus.registered?('mendelevium').must_equal(true)
      end

    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vedeu-0.2.4 test/lib/vedeu/support/registrar_test.rb