Sha256: 0d83f5aa9f3a6efe875ea5544f4926c9134d57b800220bc52392a90b07941da9

Contents?: true

Size: 1.98 KB

Versions: 44

Compression:

Stored size: 1.98 KB

Contents

require 'test_helper'

module Vedeu

  module Menus

    describe DSL do

      let(:described)  { Vedeu::Menus::DSL }
      let(:instance)   { described.new(model) }
      let(:model)      { Vedeu::Menus::Menu.new(attributes) }
      let(:attributes) {
        {
          collection: collection,
          name:       menu_name,
        }
      }
      let(:collection) { [:sodium, :magnesium, :aluminium, :silicon] }
      let(:menu_name)  { 'elements' }

      describe '.menu' do
        subject {
          described.menu('elements') do
            # ...
          end
        }

        it { subject.must_be_instance_of(Vedeu::Menus::Menu) }

        context 'when the block is not given' do
          subject { described.menu }

          it { proc { subject }.must_raise(Vedeu::Error::RequiresBlock) }
        end
      end

      describe '#item' do
        let(:_value) { :platinum }

        subject { instance.item(_value) }

        it { instance.must_respond_to(:item=) }

        context 'when items are provided' do
          it { subject.must_equal([:sodium,
                                    :magnesium,
                                    :aluminium,
                                    :silicon,
                                    :platinum]) }
        end
      end

      describe '#items' do
        let(:_value) { [] }

        subject { instance.items(_value) }

        it { instance.must_respond_to(:items=) }

        context 'when no items are provided' do
          it { subject.must_equal([]) }
        end

        context 'when items are provided' do
          let(:_value) { [:gold, :silver, :tin] }

          it { subject.must_equal(_value)}
        end
      end

      describe '#name' do
        let(:_value) { 'metals' }

        subject { instance.name(_value) }

        it { instance.must_respond_to(:name=) }

        it 'returns the name of the menu' do
          subject
          model.name.must_equal('metals')
        end
      end

    end # DSL

  end # Menus

end # Vedeu

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
vedeu-0.7.4 test/lib/vedeu/menus/dsl_test.rb
vedeu-0.7.3 test/lib/vedeu/menus/dsl_test.rb
vedeu-0.7.2 test/lib/vedeu/menus/dsl_test.rb
vedeu-0.7.1 test/lib/vedeu/menus/dsl_test.rb
vedeu-0.7.0 test/lib/vedeu/menus/dsl_test.rb
vedeu-0.6.71 test/lib/vedeu/menus/dsl_test.rb
vedeu-0.6.70 test/lib/vedeu/menus/dsl_test.rb
vedeu-0.6.69 test/lib/vedeu/menus/dsl_test.rb
vedeu-0.6.68 test/lib/vedeu/menus/dsl_test.rb
vedeu-0.6.67 test/lib/vedeu/menus/dsl_test.rb
vedeu-0.6.66 test/lib/vedeu/menus/dsl_test.rb
vedeu-0.6.65 test/lib/vedeu/menus/dsl_test.rb
vedeu-0.6.64 test/lib/vedeu/menus/dsl_test.rb
vedeu-0.6.63 test/lib/vedeu/menus/dsl_test.rb
vedeu-0.6.62 test/lib/vedeu/menus/dsl_test.rb
vedeu-0.6.61 test/lib/vedeu/menus/dsl_test.rb
vedeu-0.6.60 test/lib/vedeu/menus/dsl_test.rb
vedeu-0.6.59 test/lib/vedeu/menus/dsl_test.rb
vedeu-0.6.58 test/lib/vedeu/menus/dsl_test.rb
vedeu-0.6.57 test/lib/vedeu/menus/dsl_test.rb