Sha256: cd1cbcda63d7f65ac0bc3a4a58cd2a1be0fe010037e9c91f2defbab36114c8db

Contents?: true

Size: 1.89 KB

Versions: 7

Compression:

Stored size: 1.89 KB

Contents

require 'test_helper'

module Vedeu

  module API

    describe Menu do

      describe '.define' do
        before { Menus.reset }

        it 'raises an exception if no block was given' do
          proc { Menu.define }.must_raise(InvalidSyntax)
        end

        it 'raises an exception if no name was specified for the menu' do
          proc { Menu.define { } }.must_raise(MissingRequired)
        end

        it 'adds the menu to the menus repository' do
          Menu.define do
            name  'elements'
            items [:sodium, :magnesium, :aluminium, :silicon]
          end

          Vedeu::Menus.registered.must_equal(['elements'])
        end

        it 'returns the API::Menu instance' do
          Menu.define do
            name 'elements'
          end.must_be_instance_of(API::Menu)
        end
      end

      describe '#initialize' do
        it 'returns an instance of itself' do
          Menu.new.must_be_instance_of(Menu)
        end
      end

      describe '#items' do
        it 'returns an empty collection when no items are provided' do
          Menu.new.items.must_equal([])
        end

        it 'assigns the instance of Vedeu::Menu to the attributes' do
          items = [:sodium, :magnesium, :aluminium, :silicon]

          menu = Menu.new
          menu.items(items)
          menu.attributes[:items].must_equal(items)
        end
      end

      describe '#name' do
        it 'returns the name of the menu' do
          menu = Menu.new
          menu.name('elements').must_equal('elements')
        end

        it 'assigns the name to the attributes' do
          menu = Menu.new
          menu.name('elements')
          menu.attributes[:name].must_equal('elements')
        end
      end

      describe '#method_missing' do
        it 'returns nil' do
          Menu.new.some_missing_method(:test).must_equal(nil)
        end
      end

    end # Menu

  end # API

end # Vedeu

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
vedeu-0.2.11 test/lib/vedeu/api/menu_test.rb
vedeu-0.2.10 test/lib/vedeu/api/menu_test.rb
vedeu-0.2.9 test/lib/vedeu/api/menu_test.rb
vedeu-0.2.8 test/lib/vedeu/api/menu_test.rb
vedeu-0.2.7 test/lib/vedeu/api/menu_test.rb
vedeu-0.2.6 test/lib/vedeu/api/menu_test.rb
vedeu-0.2.5 test/lib/vedeu/api/menu_test.rb