Sha256: 8f5db41c0352b748986eb0060434723a124f891f8dcbb30a1384dcdecf74a53a

Contents?: true

Size: 1.88 KB

Versions: 6

Compression:

Stored size: 1.88 KB

Contents

# frozen_string_literal: true

# Load the class under test
require_relative '../../../lib/zenlish/feature/feature_struct_def_bearer'

module Zenlish
  module Feature
    describe FeatureStructDefBearer do
      # @nodoc Class created just for testing purposes.
      class Dummy
        include FeatureStructDefBearer

        def initialize(aParent)
          feature_hash = {
            'NUMBER' => enumeration(:singular, :plural),
            'COUNTABILITY' => boolean,
            'PARADIGM' => [identifier, 'CommonForm']
          }

          init_struct_def(aParent, feature_hash)
        end
      end # class

      subject { Dummy.new (nil) }

      context 'Mix-in initialization' do
        it 'should have initialized properly the injected data' do
          expect { Dummy.new(nil) }.not_to raise_error
          expect(subject.struct).to be_kind_of(FeatureStructDef)
        end

        it 'should have the feature definitions created' do
          expect(subject['NUMBER']).not_to be_nil
          expect(subject['NUMBER']).to be_kind_of(FeatureDef)
          ft = subject['NUMBER']
          expect(ft.domain.enum).to eq([:singular, :plural])
          
          expect(subject['COUNTABILITY']).to be_kind_of(FeatureDef)
          expect(subject['COUNTABILITY'].domain).to be_kind_of(BooleanDomain)
          expect(subject['PARADIGM']).to be_kind_of(FeatureDef)
          expect(subject['PARADIGM'].domain).to be_kind_of(IdentifierDomain)
          expect(subject['PARADIGM'].default).to be_kind_of(IdentifierValue)          
        end
        
        it 'should support the addition of feature def' do
          subject.feature_def_dsl { feature_def 'CASE' => boolean }
          
          expect(subject['CASE']).to be_kind_of(FeatureDef)
          expect(subject['CASE'].domain).to be_kind_of(BooleanDomain)          
        end
      end # context
    end # describe
  end # module
end # module

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
zenlish-0.2.05 spec/zenlish/feature/feature_struct_def_bearer_spec.rb
zenlish-0.2.04 spec/zenlish/feature/feature_struct_def_bearer_spec.rb
zenlish-0.2.03 spec/zenlish/feature/feature_struct_def_bearer_spec.rb
zenlish-0.2.02 spec/zenlish/feature/feature_struct_def_bearer_spec.rb
zenlish-0.2.01 spec/zenlish/feature/feature_struct_def_bearer_spec.rb
zenlish-0.2.00 spec/zenlish/feature/feature_struct_def_bearer_spec.rb