spec/zenlish/inflect/inflection_table_spec.rb in zenlish-0.2.05 vs spec/zenlish/inflect/inflection_table_spec.rb in zenlish-0.2.06
- old
+ new
@@ -17,10 +17,12 @@
# Load the class under test
require_relative '../../../lib/zenlish/inflect/inflection_table'
module Zenlish
module Inflect
+ # rubocop: disable Naming/VariableNumber
+
describe InflectionTable do
let(:table_name) { 'Common_form' }
subject { InflectionTable.new(table_name) }
context 'Initialization:' do
@@ -37,11 +39,11 @@
end
it 'should not have rules at start' do
expect(subject.rules).to be_empty
end
- end # context
+ end # context
context 'Provided services:' do
# DecisionTable: Common_form
# | NUMBER | .base_form | Common_form |
# | singular | X | base_form |
@@ -75,13 +77,12 @@
let(:rule_b) { InflectionRule.new([cond_b_0, cond_b_1], cons_b) }
let(:rule_c) { InflectionRule.new([cond_c_0, cond_c_1], cons_c) }
let(:a_wclass) { WClasses::CommonNoun.new }
let(:a_lemma) { 'body' }
let(:an_entry) { Lex::LexicalEntry.new(a_lemma) }
- let(:lexm_body) { Lex::Lexeme.new(a_wclass, an_entry) }
-
- MockFeatureBearer = Struct.new(:NUMBER, :base_form)
+ let(:lexm_body) { Lex::Lexeme.new(a_wclass, an_entry) }
+ let(:mock_feature_bearer) { Struct.new(:NUMBER, :base_form) }
it 'should accept the addition of heading(s)' do
expect { subject.add_heading(heading0) }.not_to raise_error
expect(subject.headings.size).to eq(1)
subject.add_heading(heading1)
@@ -94,17 +95,17 @@
subject.add_rule(rule_b)
expect(subject.rules.last).to eq(rule_b)
subject.add_rule(rule_c)
expect(subject.rules.last).to eq(rule_c)
end
-
+
def init_table(aTable)
aTable.add_heading(heading0)
aTable.add_heading(heading1)
aTable.add_rule(rule_a)
aTable.add_rule(rule_b)
- aTable.add_rule(rule_c)
+ aTable.add_rule(rule_c)
end
# DecisionTable: Common_form
# | NUMBER | .base_form | Common_form |
# | singular | X | base_form |
@@ -118,27 +119,28 @@
# rule(equals(:plural) , matches(/[^aeiouy]y$/), sub(col(1), /y$/, 'ies'))
# rule(equals(:plural) , dont_care , concat(col(1), 's'))
# end
it 'should determine the word form given input entries' do
init_table(subject)
- mck_1 = MockFeatureBearer.new(:singular, 'animal')
- expect(subject.inflect(mck_1, [nil, nil])).to eq('animal')
- mck_1['NUMBER'] = :plural
- expect(subject.inflect(mck_1, [nil, nil])).to eq('animals')
+ mck1 = mock_feature_bearer.new(:singular, 'animal')
+ expect(subject.inflect(mck1, [nil, nil])).to eq('animal')
+ mck1['NUMBER'] = :plural
+ expect(subject.inflect(mck1, [nil, nil])).to eq('animals')
- mck_2 = MockFeatureBearer.new(:singular, 'boy')
- expect(subject.inflect(mck_2, [nil, nil])).to eq('boy')
- mck_2['NUMBER'] = :plural
- expect(subject.inflect(mck_2, [nil, nil])).to eq('boys')
+ mck2 = mock_feature_bearer.new(:singular, 'boy')
+ expect(subject.inflect(mck2, [nil, nil])).to eq('boy')
+ mck2['NUMBER'] = :plural
+ expect(subject.inflect(mck2, [nil, nil])).to eq('boys')
expect(subject.inflect(lexm_body, [:singular, nil])).to eq('body')
expect(subject.inflect(lexm_body, [:plural, nil])).to eq('bodies')
end
it 'should know all the word forms of a given lexeme' do
init_table(subject)
- expect(subject.all_inflections(lexm_body)).to eq(['body', 'bodies'])
+ expect(subject.all_inflections(lexm_body)).to eq(%w[body bodies])
end
end # context
end # describe
+ # rubocop: enable Naming/VariableNumber
end # module
-end # module
\ No newline at end of file
+end # module