Sha256: b541a6dd07d7936c8e2c42745e52d1dcc1d4417774b18294ef8b392501de92d7

Contents?: true

Size: 1.78 KB

Versions: 13

Compression:

Stored size: 1.78 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 '#initialize' do
        it { instance.must_be_instance_of(described) }
        it { instance.instance_variable_get('@model').must_equal(model) }
      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

13 entries across 13 versions & 1 rubygems

Version Path
vedeu-0.6.20 test/lib/vedeu/menus/dsl_test.rb
vedeu-0.6.19 test/lib/vedeu/menus/dsl_test.rb
vedeu-0.6.18 test/lib/vedeu/menus/dsl_test.rb
vedeu-0.6.17 test/lib/vedeu/menus/dsl_test.rb
vedeu-0.6.16 test/lib/vedeu/menus/dsl_test.rb
vedeu-0.6.15 test/lib/vedeu/menus/dsl_test.rb
vedeu-0.6.14 test/lib/vedeu/menus/dsl_test.rb
vedeu-0.6.13 test/lib/vedeu/menus/dsl_test.rb
vedeu-0.6.12 test/lib/vedeu/menus/dsl_test.rb
vedeu-0.6.11 test/lib/vedeu/menus/dsl_test.rb
vedeu-0.6.10 test/lib/vedeu/menus/dsl_test.rb
vedeu-0.6.9 test/lib/vedeu/menus/dsl_test.rb
vedeu-0.6.8 test/lib/vedeu/menus/dsl_test.rb