zenlish 0.2.06 → 0.2.07

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +48 -275
  3. data/CHANGELOG.md +8 -0
  4. data/LICENSE.txt +1 -1
  5. data/lib/zenlish/feature/feature_struct_def.rb +0 -2
  6. data/lib/zenlish/inflect/output_expression.rb +4 -0
  7. data/lib/zenlish/version.rb +1 -1
  8. data/lib/zenlish/wclasses/irregular_verb_extension.rb +0 -1
  9. data/lib/zenlish.rb +3 -3
  10. data/spec/zenlish/feature/boolean_domain_spec.rb +14 -14
  11. data/spec/zenlish/feature/boolean_value_spec.rb +6 -5
  12. data/spec/zenlish/feature/enumeration_domain_spec.rb +16 -16
  13. data/spec/zenlish/feature/feature_def_spec.rb +15 -14
  14. data/spec/zenlish/feature/feature_spec.rb +16 -16
  15. data/spec/zenlish/feature/feature_struct_def_bearer_spec.rb +16 -16
  16. data/spec/zenlish/feature/feature_struct_def_spec.rb +23 -23
  17. data/spec/zenlish/feature/identifier_domain_spec.rb +12 -12
  18. data/spec/zenlish/feature/identifier_value_spec.rb +6 -5
  19. data/spec/zenlish/feature/symbol_value_spec.rb +6 -5
  20. data/spec/zenlish/inflect/concatenation_spec.rb +8 -8
  21. data/spec/zenlish/inflect/equals_literal_spec.rb +17 -16
  22. data/spec/zenlish/inflect/feature_heading_spec.rb +14 -13
  23. data/spec/zenlish/inflect/formal_argument_spec.rb +5 -5
  24. data/spec/zenlish/inflect/function_call_spec.rb +8 -9
  25. data/spec/zenlish/inflect/inflection_rule_spec.rb +20 -20
  26. data/spec/zenlish/inflect/inflection_table_builder_spec.rb +37 -37
  27. data/spec/zenlish/inflect/inflection_table_spec.rb +33 -32
  28. data/spec/zenlish/inflect/input_asis_spec.rb +10 -9
  29. data/spec/zenlish/inflect/literal_asis_spec.rb +7 -7
  30. data/spec/zenlish/inflect/matches_pattern_spec.rb +15 -14
  31. data/spec/zenlish/inflect/membership_spec.rb +16 -15
  32. data/spec/zenlish/inflect/method_heading_spec.rb +12 -11
  33. data/spec/zenlish/inflect/not_equals_literal_spec.rb +17 -16
  34. data/spec/zenlish/inflect/substitution_spec.rb +9 -10
  35. data/spec/zenlish/inflect/unconditionally_true_spec.rb +7 -5
  36. data/spec/zenlish/lang/dictionary_spec.rb +17 -19
  37. data/spec/zenlish/lang/lemmatizer_spec.rb +23 -23
  38. data/spec/zenlish/lang/zenlish_grammar_spec.rb +3 -3
  39. data/spec/zenlish/lex/empty_lexicon_factory_spec.rb +8 -8
  40. data/spec/zenlish/lex/lexeme_spec.rb +18 -18
  41. data/spec/zenlish/lex/lexical_entry_spec.rb +14 -13
  42. data/spec/zenlish/lex/lexicon_spec.rb +44 -43
  43. data/spec/zenlish/lex/literal_spec.rb +6 -6
  44. data/spec/zenlish/lexer/lexer_spec.rb +10 -10
  45. data/spec/zenlish/parser/lesson1_spec.rb +79 -79
  46. data/spec/zenlish/parser/lesson2_spec.rb +102 -102
  47. data/spec/zenlish/parser/lesson3_spec.rb +89 -89
  48. data/spec/zenlish/parser/zparser_spec.rb +6 -6
  49. data/spec/zenlish/support/var2word.rb +0 -2
  50. data/spec/zenlish/trie/base_trie_node_spec.rb +11 -11
  51. data/spec/zenlish/trie/trie_spec.rb +46 -46
  52. data/spec/zenlish/wclasses/common_noun_spec.rb +9 -9
  53. data/spec/zenlish/wclasses/demonstrative_determiner_spec.rb +11 -11
  54. data/spec/zenlish/wclasses/irregular_verb_can_spec.rb +10 -10
  55. data/spec/zenlish/wclasses/irregular_verb_extension_spec.rb +10 -10
  56. data/spec/zenlish/wclasses/irregular_verb_spec.rb +19 -19
  57. data/spec/zenlish/wclasses/lexical_verb_spec.rb +7 -7
  58. data/spec/zenlish/wclasses/modal_verb_can_spec.rb +9 -9
  59. data/spec/zenlish/wclasses/noun_spec.rb +7 -7
  60. data/spec/zenlish/wclasses/personal_pronoun_spec.rb +15 -15
  61. data/spec/zenlish/wclasses/possessive_determiner_spec.rb +15 -15
  62. data/spec/zenlish/wclasses/preposition_spec.rb +5 -5
  63. data/spec/zenlish/wclasses/proper_noun_spec.rb +3 -3
  64. data/spec/zenlish/wclasses/regular_verb_spec.rb +12 -12
  65. data/spec/zenlish/wclasses/regular_verb_want_spec.rb +7 -7
  66. data/spec/zenlish/wclasses/verb_spec.rb +9 -9
  67. data/spec/zenlish_spec.rb +1 -1
  68. data/zenlish.gemspec +6 -5
  69. metadata +32 -16
@@ -9,35 +9,35 @@ module Zenlish
9
9
  # rubocop: disable Naming/VariableNumber
10
10
 
11
11
  describe InflectionTableBuilder do
12
- subject { InflectionTableBuilder.new }
12
+ subject(:builder) { described_class.new }
13
13
 
14
14
  context 'Initialization:' do
15
- it 'should be initialized without argument' do
16
- expect { InflectionTableBuilder.new }.not_to raise_error
15
+ it 'is initialized without argument' do
16
+ expect { described_class.new }.not_to raise_error
17
17
  end
18
18
 
19
- it 'should not have headings after initialization' do
20
- expect(subject.headings).to be_empty
19
+ it "doesn't not have headings after initialization" do
20
+ expect(builder.headings).to be_empty
21
21
  end
22
22
  end # context
23
23
 
24
24
  context 'Basic services:' do
25
- it 'should retain the table name' do
26
- subject.build('Common_form')
27
- expect(subject.table.name).to eq('Common_form')
25
+ it 'retains the table name' do
26
+ builder.build('Common_form')
27
+ expect(builder.table.name).to eq('Common_form')
28
28
  end
29
29
 
30
- it 'should accept heading creation' do
30
+ it 'accepts heading creation' do
31
31
  # First way
32
- subject.feature_heading 'NUMBER'
33
- expect(subject.headings.size).to eq(1)
34
- expect(subject.headings.last.label).to eq('NUMBER')
35
- subject.method_heading 'base_form'
36
- expect(subject.headings.last).to be_kind_of(MethodHeading)
37
- expect(subject.headings.last.label).to eq('base_form')
32
+ builder.feature_heading 'NUMBER'
33
+ expect(builder.headings.size).to eq(1)
34
+ expect(builder.headings.last.label).to eq('NUMBER')
35
+ builder.method_heading 'base_form'
36
+ expect(builder.headings.last).to be_a(MethodHeading)
37
+ expect(builder.headings.last.label).to eq('base_form')
38
38
 
39
39
  # Second way
40
- table = subject.build('Common_form') do
40
+ table = builder.build('Common_form') do
41
41
  feature_heading 'NUMBER'
42
42
  method_heading 'base_form'
43
43
  end
@@ -47,8 +47,10 @@ module Zenlish
47
47
  end # context
48
48
 
49
49
  context 'Table building:' do
50
- it 'should be able to build consequents' do
51
- table = subject.build('Common_form') do
50
+ let(:mock_feature_bearer) { Struct.new(:NUMBER, :base_form) }
51
+
52
+ it 'is able to build consequents' do
53
+ table = builder.build('Common_form') do
52
54
  feature_heading 'NUMBER'
53
55
  method_heading 'base_form'
54
56
  rule([], col('base_form'))
@@ -57,23 +59,23 @@ module Zenlish
57
59
  end
58
60
  expect(table.rules).not_to be_empty
59
61
  consequent_0 = table.rules[0].consequent
60
- expect(consequent_0).to be_kind_of(InputAsIs)
62
+ expect(consequent_0).to be_a(InputAsIs)
61
63
  expect(consequent_0.formal.index).to eq(1)
62
64
 
63
65
  consequent_1 = table.rules[1].consequent
64
- expect(consequent_1).to be_kind_of(Substitution)
66
+ expect(consequent_1).to be_a(Substitution)
65
67
  expect(consequent_1.children[0].formal.index).to eq(1)
66
68
  expect(consequent_1.pattern).to eq(/y$/)
67
69
  expect(consequent_1.children[-1].text).to eq('ies')
68
70
 
69
71
  consequent_2 = table.rules[2].consequent
70
72
  expect(consequent_2.children[0].formal.index).to eq(1)
71
- expect(consequent_2).to be_kind_of(Concatenation)
73
+ expect(consequent_2).to be_a(Concatenation)
72
74
  expect(consequent_2.children[-1].text).to eq('s')
73
75
  end
74
76
 
75
- it 'should be able to build conditions' do
76
- table = subject.build('Common_form') do
77
+ it 'is able to build conditions' do
78
+ table = builder.build('Common_form') do
77
79
  feature_heading 'NUMBER'
78
80
  method_heading 'base_form'
79
81
  rule([equals(:singular), dont_care], col('base_form'))
@@ -82,26 +84,24 @@ module Zenlish
82
84
  end
83
85
 
84
86
  conds_0 = table.rules[0].conditions
85
- expect(conds_0[0]).to be_kind_of(EqualsLiteral)
87
+ expect(conds_0[0]).to be_a(EqualsLiteral)
86
88
  expect(conds_0[0].literal).to eq(:singular)
87
- expect(conds_0[1]).to be_kind_of(UnconditionallyTrue)
89
+ expect(conds_0[1]).to be_a(UnconditionallyTrue)
88
90
 
89
91
  conds_1 = table.rules[1].conditions
90
- expect(conds_1[0]).to be_kind_of(EqualsLiteral)
92
+ expect(conds_1[0]).to be_a(EqualsLiteral)
91
93
  expect(conds_1[0].literal).to eq(:plural)
92
- expect(conds_1[1]).to be_kind_of(MatchesPattern)
94
+ expect(conds_1[1]).to be_a(MatchesPattern)
93
95
  expect(conds_1[1].pattern).to eq(/[^aeiouy]y$/)
94
96
 
95
97
  conds_2 = table.rules[2].conditions
96
- expect(conds_2[0]).to be_kind_of(EqualsLiteral)
98
+ expect(conds_2[0]).to be_a(EqualsLiteral)
97
99
  expect(conds_2[0].literal).to eq(:plural)
98
- expect(conds_2[1]).to be_kind_of(UnconditionallyTrue)
100
+ expect(conds_2[1]).to be_a(UnconditionallyTrue)
99
101
  end
100
102
 
101
- let(:mock_feature_bearer) { Struct.new(:NUMBER, :base_form) }
102
-
103
- it 'should build default paradigm for common nouns' do
104
- table = subject.build('Common_form') do
103
+ it 'builds default paradigm for common nouns' do
104
+ table = builder.build('Common_form') do
105
105
  feature_heading 'NUMBER'
106
106
  method_heading 'base_form'
107
107
  rule([equals(:singular), dont_care], col('base_form'))
@@ -126,8 +126,8 @@ module Zenlish
126
126
  end
127
127
 
128
128
  MockRegularVerb = Struct.new(:base_form, :PERSON, :NUMBER, :TIME)
129
- it 'should build default paradigm for regular verbs' do
130
- table = subject.build('Regular_form') do
129
+ it 'builds default paradigm for regular verbs' do
130
+ table = builder.build('Regular_form') do
131
131
  feature_heading 'PERSON'
132
132
  feature_heading 'NUMBER'
133
133
  feature_heading 'TIME'
@@ -178,8 +178,8 @@ module Zenlish
178
178
  end
179
179
 
180
180
  MockIrregularVerb = Struct.new(:base_form, :PERSON, :NUMBER, :TIME, :past_simple, :past_participle)
181
- it 'should build default paradigm for irregular verbs' do
182
- table = subject.build('Irregular_inflection') do
181
+ it 'builds default paradigm for irregular verbs' do
182
+ table = builder.build('Irregular_inflection') do
183
183
  feature_heading 'PERSON'
184
184
  feature_heading 'NUMBER'
185
185
  feature_heading 'TIME'
@@ -23,23 +23,24 @@ module Zenlish
23
23
 
24
24
  describe InflectionTable do
25
25
  let(:table_name) { 'Common_form' }
26
- subject { InflectionTable.new(table_name) }
26
+
27
+ subject(:inflection) { described_class.new(table_name) }
27
28
 
28
29
  context 'Initialization:' do
29
- it 'should be initialized with a name' do
30
- expect { InflectionTable.new(table_name) }.not_to raise_error
30
+ it 'is initialized with a name' do
31
+ expect { described_class.new(table_name) }.not_to raise_error
31
32
  end
32
33
 
33
- it 'should now its name' do
34
- expect(subject.name).to eq(table_name)
34
+ it 'knows its name' do
35
+ expect(inflection.name).to eq(table_name)
35
36
  end
36
37
 
37
- it 'should not have headings at start' do
38
- expect(subject.headings).to be_empty
38
+ it "doesn't have headings at start" do
39
+ expect(inflection.headings).to be_empty
39
40
  end
40
41
 
41
- it 'should not have rules at start' do
42
- expect(subject.rules).to be_empty
42
+ it "doesn't not have rules at start" do
43
+ expect(inflection.rules).to be_empty
43
44
  end
44
45
  end # context
45
46
 
@@ -82,20 +83,20 @@ module Zenlish
82
83
  let(:lexm_body) { Lex::Lexeme.new(a_wclass, an_entry) }
83
84
  let(:mock_feature_bearer) { Struct.new(:NUMBER, :base_form) }
84
85
 
85
- it 'should accept the addition of heading(s)' do
86
- expect { subject.add_heading(heading0) }.not_to raise_error
87
- expect(subject.headings.size).to eq(1)
88
- subject.add_heading(heading1)
89
- expect(subject.headings.last).to eq(heading1)
86
+ it 'accepts the addition of heading(s)' do
87
+ expect { inflection.add_heading(heading0) }.not_to raise_error
88
+ expect(inflection.headings.size).to eq(1)
89
+ inflection.add_heading(heading1)
90
+ expect(inflection.headings.last).to eq(heading1)
90
91
  end
91
92
 
92
- it 'should accept the addition of rule(s)' do
93
- expect { subject.add_rule(rule_a) }.not_to raise_error
94
- expect(subject.rules.size).to eq(1)
95
- subject.add_rule(rule_b)
96
- expect(subject.rules.last).to eq(rule_b)
97
- subject.add_rule(rule_c)
98
- expect(subject.rules.last).to eq(rule_c)
93
+ it 'accepts the addition of rule(s)' do
94
+ expect { inflection.add_rule(rule_a) }.not_to raise_error
95
+ expect(inflection.rules.size).to eq(1)
96
+ inflection.add_rule(rule_b)
97
+ expect(inflection.rules.last).to eq(rule_b)
98
+ inflection.add_rule(rule_c)
99
+ expect(inflection.rules.last).to eq(rule_c)
99
100
  end
100
101
 
101
102
  def init_table(aTable)
@@ -119,25 +120,25 @@ module Zenlish
119
120
  # rule(equals(:plural) , matches(/[^aeiouy]y$/), sub(col(1), /y$/, 'ies'))
120
121
  # rule(equals(:plural) , dont_care , concat(col(1), 's'))
121
122
  # end
122
- it 'should determine the word form given input entries' do
123
- init_table(subject)
123
+ it 'determines the word form given input entries' do
124
+ init_table(inflection)
124
125
  mck1 = mock_feature_bearer.new(:singular, 'animal')
125
- expect(subject.inflect(mck1, [nil, nil])).to eq('animal')
126
+ expect(inflection.inflect(mck1, [nil, nil])).to eq('animal')
126
127
  mck1['NUMBER'] = :plural
127
- expect(subject.inflect(mck1, [nil, nil])).to eq('animals')
128
+ expect(inflection.inflect(mck1, [nil, nil])).to eq('animals')
128
129
 
129
130
  mck2 = mock_feature_bearer.new(:singular, 'boy')
130
- expect(subject.inflect(mck2, [nil, nil])).to eq('boy')
131
+ expect(inflection.inflect(mck2, [nil, nil])).to eq('boy')
131
132
  mck2['NUMBER'] = :plural
132
- expect(subject.inflect(mck2, [nil, nil])).to eq('boys')
133
+ expect(inflection.inflect(mck2, [nil, nil])).to eq('boys')
133
134
 
134
- expect(subject.inflect(lexm_body, [:singular, nil])).to eq('body')
135
- expect(subject.inflect(lexm_body, [:plural, nil])).to eq('bodies')
135
+ expect(inflection.inflect(lexm_body, [:singular, nil])).to eq('body')
136
+ expect(inflection.inflect(lexm_body, [:plural, nil])).to eq('bodies')
136
137
  end
137
138
 
138
- it 'should know all the word forms of a given lexeme' do
139
- init_table(subject)
140
- expect(subject.all_inflections(lexm_body)).to eq(%w[body bodies])
139
+ it 'knows all the word forms of a given lexeme' do
140
+ init_table(inflection)
141
+ expect(inflection.all_inflections(lexm_body)).to eq(%w[body bodies])
141
142
  end
142
143
  end # context
143
144
  end # describe
@@ -13,32 +13,33 @@ module Zenlish
13
13
  describe InputAsIs do
14
14
  let(:sample_argument) { FormalArgument.new(2) }
15
15
  let(:sample_values) { [nil, nil, 'Hello, world.', nil] }
16
- subject { InputAsIs.new(sample_argument) }
16
+
17
+ subject(:input) { described_class.new(sample_argument) }
17
18
 
18
19
  context 'Initialization:' do
19
- it 'should be initialized with a formal rgument' do
20
- expect { InputAsIs.new(sample_argument) }.not_to raise_error
20
+ it 'is initialized with a formal rgument' do
21
+ expect { described_class.new(sample_argument) }.not_to raise_error
21
22
  end
22
23
 
23
- it 'should know its text value' do
24
- expect(subject.formal).to eq(sample_argument)
24
+ it 'knows its text value' do
25
+ expect(input.formal).to eq(sample_argument)
25
26
  end
26
27
  end # context
27
28
 
28
29
  context 'Provided services:' do
29
- it 'should return the text of given argument during generation' do
30
+ it 'returns the text of given argument during generation' do
30
31
  lexeme = double('fake-lexeme')
31
32
  headings = double('fake-headings')
32
- expect(subject.generate(headings, lexeme, sample_values)).to eq('Hello, world.')
33
+ expect(input.generate(headings, lexeme, sample_values)).to eq('Hello, world.')
33
34
  end
34
35
 
35
- it 'should return the text of given lexeme during generation' do
36
+ it 'returns the text of given lexeme during generation' do
36
37
  c_noun = WClasses::CommonNoun.new
37
38
  an_entry = Lex::LexicalEntry.new('cherry')
38
39
  lexeme = Lex::Lexeme.new(c_noun, an_entry)
39
40
  heading = MethodHeading.new('base_form')
40
41
  headings = [nil, nil, heading, nil]
41
- expect(subject.generate(headings, lexeme, [])).to eq('cherry')
42
+ expect(input.generate(headings, lexeme, [])).to eq('cherry')
42
43
  end
43
44
  end # context
44
45
  end # describe
@@ -6,24 +6,24 @@ require_relative '../../../lib/zenlish/inflect/literal_asis'
6
6
  module Zenlish
7
7
  module Inflect
8
8
  describe LiteralAsIs do
9
- subject { LiteralAsIs.new('s') }
9
+ subject(:literal) { described_class.new('s') }
10
10
 
11
11
  context 'Initialization:' do
12
- it 'should be initialized with a text literal' do
13
- expect { LiteralAsIs.new('s') }.not_to raise_error
12
+ it 'is initialized with a text literal' do
13
+ expect { described_class.new('s') }.not_to raise_error
14
14
  end
15
15
 
16
- it 'should know its text value' do
17
- expect(subject.text).to eq('s')
16
+ it 'knows its text value' do
17
+ expect(literal.text).to eq('s')
18
18
  end
19
19
  end # context
20
20
 
21
21
  context 'Provided services:' do
22
- it 'should return the affix during word form generation' do
22
+ it 'returns the affix during word form generation' do
23
23
  headings = double('fake-headings')
24
24
  lexeme = double('fake-lexeme')
25
25
  values = double('fake-values')
26
- expect(subject.generate(headings, lexeme, values)).to eq('s')
26
+ expect(literal.generate(headings, lexeme, values)).to eq('s')
27
27
  end
28
28
  end # context
29
29
  end # describe
@@ -13,44 +13,45 @@ module Zenlish
13
13
  describe MatchesPattern do
14
14
  let(:an_argument) { FormalArgument.new(1) }
15
15
  let(:patt) { /[^aeiouy]y$/ }
16
- subject { MatchesPattern.new(an_argument, patt) }
16
+
17
+ subject(:pattern) { described_class.new(an_argument, patt) }
17
18
 
18
19
  context 'Initialization:' do
19
- it 'should be initialized with an argument and pattern' do
20
- expect { MatchesPattern.new(an_argument, patt) }.not_to raise_error
20
+ it 'is initialized with an argument and pattern' do
21
+ expect { described_class.new(an_argument, patt) }.not_to raise_error
21
22
  end
22
23
 
23
- it 'should know its argument' do
24
- expect(subject.argument).to eq(an_argument)
24
+ it 'knows its argument' do
25
+ expect(pattern.argument).to eq(an_argument)
25
26
  end
26
27
 
27
- it 'should know the pattern' do
28
- expect(subject.pattern).to eq(patt)
28
+ it 'knows the pattern' do
29
+ expect(pattern.pattern).to eq(patt)
29
30
  end
30
31
  end # context
31
32
 
32
33
  context 'Provided services:' do
33
- it 'should check the actual argument' do
34
+ it 'checks the actual argument' do
34
35
  lexeme = double('dummy-lexeme')
35
36
  headings = double('fake-headings')
36
37
  actual_args = [nil, 'cherry', nil]
37
- expect(subject.success?(headings, lexeme, actual_args)).to be_truthy
38
+ expect(pattern).to be_success(headings, lexeme, actual_args)
38
39
  actual_args[1] = 'boy'
39
- expect(subject.success?(headings, lexeme, actual_args)).to be_falsy
40
+ expect(pattern).not_to be_success(headings, lexeme, actual_args)
40
41
  actual_args[1] = 'girl'
41
- expect(subject.success?(headings, lexeme, actual_args)).to be_falsy
42
+ expect(pattern).not_to be_success(headings, lexeme, actual_args)
42
43
  end
43
44
 
44
- it 'should test the lexeme' do
45
+ it 'tests the lexeme' do
45
46
  c_noun = WClasses::CommonNoun.new
46
47
  entry = Lex::LexicalEntry.new('cherry')
47
48
  lexeme = Lex::Lexeme.new(c_noun, entry)
48
49
  headings = [nil, MethodHeading.new('lemma'), nil]
49
- expect(subject.success?(headings, lexeme, [])).to be_truthy
50
+ expect(pattern).to be_success(headings, lexeme, [])
50
51
 
51
52
  entry2 = Lex::LexicalEntry.new('boy')
52
53
  lexeme2 = Lex::Lexeme.new(c_noun, entry2)
53
- expect(subject.success?(headings, lexeme2, [])).to be_falsey
54
+ expect(pattern).not_to be_success(headings, lexeme2, [])
54
55
 
55
56
  # instance = EqualsLiteral.new(an_argument, :irregular)
56
57
  # expect(instance.success?(headings, lexeme, [])).to be_falsey
@@ -13,45 +13,46 @@ module Zenlish
13
13
  describe Membership do
14
14
  let(:an_argument) { FormalArgument.new(1) }
15
15
  let(:feat_val) { %i[singular plural] }
16
- subject { Membership.new(an_argument, feat_val) }
16
+
17
+ subject(:membership) { described_class.new(an_argument, feat_val) }
17
18
 
18
19
  context 'Initialization:' do
19
- it 'should be initialized with a formal argument and an array' do
20
- expect { Membership.new(an_argument, feat_val) }.not_to raise_error
20
+ it 'is initialized with a formal argument and an array' do
21
+ expect { described_class.new(an_argument, feat_val) }.not_to raise_error
21
22
  end
22
23
 
23
- it 'should know its argument' do
24
- expect(subject.argument).to eq(an_argument)
24
+ it 'knows its argument' do
25
+ expect(membership.argument).to eq(an_argument)
25
26
  end
26
27
 
27
- it 'should know the array of literals' do
28
- expect(subject.members).to eq(feat_val)
28
+ it 'knows the array of literals' do
29
+ expect(membership.members).to eq(feat_val)
29
30
  end
30
31
  end # context
31
32
 
32
33
  context 'Provided services:' do
33
- it 'should test the actual values' do
34
+ it 'tests the actual values' do
34
35
  lexeme = double('dummy-lexeme')
35
36
  headings = double('fake-headings')
36
37
  actual_args = [nil, :plural, nil]
37
- expect(subject.success?(headings, lexeme, actual_args)).to be_truthy
38
+ expect(membership).to be_success(headings, lexeme, actual_args)
38
39
  actual_args[1] = :singular
39
- expect(subject.success?(headings, lexeme, actual_args)).to be_truthy
40
+ expect(membership).to be_success(headings, lexeme, actual_args)
40
41
  actual_args[1] = :dual
41
- expect(subject.success?(headings, lexeme, actual_args)).to be_falsy
42
+ expect(membership).not_to be_success(headings, lexeme, actual_args)
42
43
  end
43
44
 
44
- # it 'should test the lexeme' do
45
+ # it 'tests the lexeme' do
45
46
  # c_noun = WClasses::CommonNoun.new
46
47
  # entry = Lex::LexicalEntry.new('animal')
47
48
  # lexeme = Lex::Lexeme.new(c_noun, entry)
48
49
  # headings = [nil, FeatureHeading.new('NUMBER'), nil]
49
- # expect(subject.success?(headings, lexeme, [])).to be_truthy
50
+ # expect(membership.success?(headings, lexeme, [])).to be_truthy
50
51
 
51
- # instance = Membership.new(an_argument, :singular)
52
+ # instance = described_class.new(an_argument, :singular)
52
53
  # expect(instance.success?(headings, lexeme, [])).to be_truthy
53
54
 
54
- # instance = Membership.new(an_argument, :irregular)
55
+ # instance = described_class.new(an_argument, :irregular)
55
56
  # expect(instance.success?(headings, lexeme, [])).to be_falsey
56
57
  # end
57
58
  end # context
@@ -7,29 +7,30 @@ module Zenlish
7
7
  module Inflect
8
8
  describe MethodHeading do
9
9
  let(:method_name) { 'base_form' }
10
- subject { MethodHeading.new(method_name) }
10
+
11
+ subject(:heading) { described_class.new(method_name) }
11
12
 
12
13
  context 'Initialization:' do
13
- it 'should be initialized with a method name' do
14
- expect { MethodHeading.new(method_name) }.not_to raise_error
14
+ it 'is initialized with a method name' do
15
+ expect { described_class.new(method_name) }.not_to raise_error
15
16
  end
16
17
 
17
- it 'should know its label' do
18
- expect(subject.label).to eq(method_name)
18
+ it 'knows its label' do
19
+ expect(heading.label).to eq(method_name)
19
20
  end
20
21
  end # context
21
22
 
22
23
  context 'Provided services:' do
23
- it 'should obtain the method result from a word' do
24
+ it 'obtains the method result from a word' do
24
25
  mocked = double('dummy-lexeme')
25
- expect(mocked).to receive(:base_form).and_return('cherry')
26
- expect(subject.evaluate_for(mocked)).to eq('cherry')
26
+ allow(mocked).to receive(:base_form).and_return('cherry')
27
+ expect(heading.evaluate_for(mocked)).to eq('cherry')
27
28
  end
28
29
 
29
- it 'should obtain the method result as an array' do
30
+ it 'obtains the method result as an array' do
30
31
  mocked = double('dummy-lexeme')
31
- expect(mocked).to receive(:base_form).and_return('cherry')
32
- expect(subject.all_matches(mocked)).to eq(['cherry'])
32
+ allow(mocked).to receive(:base_form).and_return('cherry')
33
+ expect(heading.all_matches(mocked)).to eq(['cherry'])
33
34
  end
34
35
  end # context
35
36
  end # describe
@@ -13,44 +13,45 @@ module Zenlish
13
13
  describe NotEqualsLiteral do
14
14
  let(:an_argument) { FormalArgument.new(1) }
15
15
  let(:feat_val) { :plural }
16
- subject { NotEqualsLiteral.new(an_argument, feat_val) }
16
+
17
+ subject(:literal) { described_class.new(an_argument, feat_val) }
17
18
 
18
19
  context 'Initialization:' do
19
- it 'should be initialized with formal argument and a literal' do
20
- expect { NotEqualsLiteral.new(an_argument, feat_val) }.not_to raise_error
20
+ it 'is initialized with formal argument and a literal' do
21
+ expect { described_class.new(an_argument, feat_val) }.not_to raise_error
21
22
  end
22
23
 
23
- it 'should know its argument' do
24
- expect(subject.argument).to eq(an_argument)
24
+ it 'knows its argument' do
25
+ expect(literal.argument).to eq(an_argument)
25
26
  end
26
27
 
27
- it 'should know the literal' do
28
- expect(subject.literal).to eq(feat_val)
28
+ it 'knows the literal' do
29
+ expect(literal.literal).to eq(feat_val)
29
30
  end
30
31
  end # context
31
32
 
32
33
  context 'Provided services:' do
33
- it 'should test the actual argument' do
34
+ it 'tests the actual argument' do
34
35
  lexeme = double('dummy-lexeme')
35
36
  headings = double('fake-headings')
36
37
  actual_args = [nil, :plural, nil]
37
- expect(subject.success?(headings, lexeme, actual_args)).to be_falsy
38
+ expect(literal).not_to be_success(headings, lexeme, actual_args)
38
39
  actual_args[1] = :singular
39
- expect(subject.success?(headings, lexeme, actual_args)).to be_truthy
40
+ expect(literal).to be_success(headings, lexeme, actual_args)
40
41
  end
41
42
 
42
- it 'should test the lexeme' do
43
+ it 'tests the lexeme' do
43
44
  c_noun = WClasses::CommonNoun.new
44
45
  entry = Lex::LexicalEntry.new('animal')
45
46
  lexeme = Lex::Lexeme.new(c_noun, entry)
46
47
  headings = [nil, FeatureHeading.new('NUMBER'), nil]
47
- expect(subject.success?(headings, lexeme, [])).to be_falsy
48
+ expect(literal).not_to be_success(headings, lexeme, [])
48
49
 
49
- instance = NotEqualsLiteral.new(an_argument, :singular)
50
- expect(instance.success?(headings, lexeme, [])).to be_falsy
50
+ instance = described_class.new(an_argument, :singular)
51
+ expect(instance).not_to be_success(headings, lexeme, [])
51
52
 
52
- instance = NotEqualsLiteral.new(an_argument, :irregular)
53
- expect(instance.success?(headings, lexeme, [])).to be_truthy
53
+ instance = described_class.new(an_argument, :irregular)
54
+ expect(instance).to be_success(headings, lexeme, [])
54
55
  end
55
56
  end # context
56
57
  end # describe
@@ -13,18 +13,17 @@ module Zenlish
13
13
  let(:base) { InputAsIs.new(sample_argument) }
14
14
  let(:pattern) { /y$/ }
15
15
 
16
-
17
- subject { Substitution.new(base, pattern, suffix) }
16
+ subject(:substitution) { described_class.new(base, pattern, suffix) }
18
17
 
19
18
  context 'Initialization:' do
20
- it 'should be initialized with two arguments' do
21
- expect { Substitution.new(base, pattern, suffix) }.not_to raise_error
19
+ it 'is initialized with two arguments' do
20
+ expect { described_class.new(base, pattern, suffix) }.not_to raise_error
22
21
  end
23
22
 
24
- it 'should know its arguments' do
25
- expect(subject.children.first).to eq(base)
26
- expect(subject.children[1]).to eq(pattern)
27
- expect(subject.children.last).to eq(suffix)
23
+ it 'knows its arguments' do
24
+ expect(substitution.children.first).to eq(base)
25
+ expect(substitution.children[1]).to eq(pattern)
26
+ expect(substitution.children.last).to eq(suffix)
28
27
  end
29
28
  end # context
30
29
 
@@ -32,10 +31,10 @@ module Zenlish
32
31
  let(:sample_heading) { double('fake-headings') }
33
32
  let(:sample_values) { [nil, 'cherry', nil] }
34
33
 
35
- it 'should do the concatenation of children results' do
34
+ it 'concatenates children results' do
36
35
  lexeme = double('fake-lexeme')
37
36
 
38
- expect(subject.generate(sample_heading, lexeme, sample_values)).to eq('cherries')
37
+ expect(substitution.generate(sample_heading, lexeme, sample_values)).to eq('cherries')
39
38
  end
40
39
  end # context
41
40
  end # describe
@@ -7,20 +7,22 @@ module Zenlish
7
7
  module Inflect
8
8
  describe UnconditionallyTrue do
9
9
  let(:method_name) { 'base_form' }
10
- subject { UnconditionallyTrue.new }
10
+
11
+ subject(:u_true) { described_class.new }
11
12
 
12
13
  context 'Initialization:' do
13
- it 'should be initialized without argument' do
14
- expect { UnconditionallyTrue.new }.not_to raise_error
14
+ it 'is initialized without argument' do
15
+ expect { described_class.new }.not_to raise_error
15
16
  end
16
17
  end # context
17
18
 
18
19
  context 'Provided services:' do
19
- it 'should always return true' do
20
+ it 'always return true' do
20
21
  headings = double('dummy-headings')
21
22
  lexeme = double('dummy-lexeme')
22
23
  values = double('dummy-heading-values')
23
- expect(subject.success?(headings, lexeme, values)).to be_truthy
24
+ # expect(u_true.success?(headings, lexeme, values)).to be_truthy
25
+ expect(u_true).to be_success(headings, lexeme, values)
24
26
  end
25
27
  end # context
26
28
  end # describe