Sha256: 22e3b7a9adb36c55101c96382c82e60fa6472eba02246f9c7108a9af7cd7b015

Contents?: true

Size: 1.93 KB

Versions: 1

Compression:

Stored size: 1.93 KB

Contents

# frozen_string_literal: true

require_relative '../../spec_helper' # Use the RSpec framework
require_relative '../../../lib/zenlish/lex/lexical_entry'
require_relative '../../../lib/zenlish/lex/lexeme'

# Load the class under test
require_relative '../../../lib/zenlish/wclasses/irregular_verb_can'

module Zenlish
  module WClasses
    describe IrregularVerbCan do
      subject { IrregularVerbCan.new }

      context 'Initialization:' do
        it 'should be initialized without argument' do
          expect { IrregularVerbCan.new }.not_to raise_error
        end
      end # context

      context 'Provided services:' do
        it 'should know its inherited feature definitions' do
          expect(subject['NUMBER']).to be_kind_of(Feature::FeatureDef)
          expect(subject['PERSON']).to be_kind_of(Feature::FeatureDef)
          expect(subject['PARADIGM'].default.val).to eq('Verb_can_inflection')
        end

        def build_verb(aBaseForm)
          entry = Zenlish::Lex::LexicalEntry.new(aBaseForm)
          lexeme = Zenlish::Lex::Lexeme.new(subject, entry)
        end

        def test_inflection_of(verb_form, pairs)
          verb = build_verb(verb_form)
          pairs.each do |(time, expected_form)|
            expect(verb.inflect([time])).to eq(expected_form)
          end
        end
        
        def test_all_inflections(verb_form, wforms)
          verb = build_verb(verb_form)
          inflected = verb.all_inflections
          expect(inflected.sort).to eq(wforms.sort)
        end        

        it 'should know how to inflect modal verb can' do
          expectations_1 = [
            [:present,     'can'],
            [:past_simple, 'could']
          ]
          test_inflection_of('can', expectations_1)
        end
        
        it 'should give all word forms of a given verb' do
          test_all_inflections('can', ['can', 'could'])
        end        
      end # context
    end # describe
  end # module
end # module

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
zenlish-0.2.05 spec/zenlish/wclasses/irregular_verb_can_spec.rb