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
@@ -14,36 +14,36 @@ module Zenlish
14
14
  let(:feat_def) { FeatureDef.new(a_name, a_domain) }
15
15
  let(:plural_value) { a_domain.build_value(:plural) }
16
16
 
17
- subject { Feature.new(feat_def) }
17
+ subject(:a_feature) { described_class.new(feat_def) }
18
18
 
19
19
  context 'Initialization:' do
20
- it 'should be initialized with one definition argument' do
21
- expect { Feature.new(feat_def) }.not_to raise_error
20
+ it 'is initialized with one definition argument' do
21
+ expect { described_class.new(feat_def) }.not_to raise_error
22
22
  end
23
23
 
24
- it 'should know its definition' do
25
- expect(subject.definition).to eq(feat_def)
24
+ it 'knows its definition' do
25
+ expect(a_feature.definition).to eq(feat_def)
26
26
  end
27
27
 
28
- it "should'nt be bound yet to a value" do
29
- expect(subject.binding).to be_nil
30
- expect(subject).not_to be_bound
28
+ it "isn't bound yet to a value" do
29
+ expect(a_feature.binding).to be_nil
30
+ expect(a_feature).not_to be_bound
31
31
  end
32
32
  end # context
33
33
 
34
34
  context 'Provided services:' do
35
- it "should know the definition's name" do
36
- expect(subject.name).to eq(feat_def.name)
35
+ it "knows the definition's name" do
36
+ expect(a_feature.name).to eq(feat_def.name)
37
37
  end
38
38
 
39
- it 'should know the domain of its values' do
40
- expect(subject.domain).to eq(a_domain)
39
+ it 'knows the domain of its values' do
40
+ expect(a_feature.domain).to eq(a_domain)
41
41
  end
42
42
 
43
- it 'should accept a value binding' do
44
- expect { subject.bind_to(plural_value) }.not_to raise_error
45
- expect(subject).to be_bound
46
- expect(subject.binding).to eq(plural_value)
43
+ it 'accepts a value binding' do
44
+ expect { a_feature.bind_to(plural_value) }.not_to raise_error
45
+ expect(a_feature).to be_bound
46
+ expect(a_feature.binding).to eq(plural_value)
47
47
  end
48
48
  end # context
49
49
  end # describe
@@ -23,32 +23,32 @@ module Zenlish
23
23
  end # class
24
24
  # rubocop: enable Lint/ConstantDefinitionInBlock
25
25
 
26
- subject { Dummy.new(nil) }
26
+ subject(:bearer) { Dummy.new(nil) }
27
27
 
28
28
  context 'Mix-in initialization' do
29
- it 'should have initialized properly the injected data' do
29
+ it 'has initialized properly the injected data' do
30
30
  expect { Dummy.new(nil) }.not_to raise_error
31
- expect(subject.struct).to be_kind_of(FeatureStructDef)
31
+ expect(bearer.struct).to be_a(FeatureStructDef)
32
32
  end
33
33
 
34
- it 'should have the feature definitions created' do
35
- expect(subject['NUMBER']).not_to be_nil
36
- expect(subject['NUMBER']).to be_kind_of(FeatureDef)
37
- ft = subject['NUMBER']
34
+ it 'has the feature definitions created' do
35
+ expect(bearer['NUMBER']).not_to be_nil
36
+ expect(bearer['NUMBER']).to be_a(FeatureDef)
37
+ ft = bearer['NUMBER']
38
38
  expect(ft.domain.enum).to eq(%i[singular plural])
39
39
 
40
- expect(subject['COUNTABILITY']).to be_kind_of(FeatureDef)
41
- expect(subject['COUNTABILITY'].domain).to be_kind_of(BooleanDomain)
42
- expect(subject['PARADIGM']).to be_kind_of(FeatureDef)
43
- expect(subject['PARADIGM'].domain).to be_kind_of(IdentifierDomain)
44
- expect(subject['PARADIGM'].default).to be_kind_of(IdentifierValue)
40
+ expect(bearer['COUNTABILITY']).to be_a(FeatureDef)
41
+ expect(bearer['COUNTABILITY'].domain).to be_a(BooleanDomain)
42
+ expect(bearer['PARADIGM']).to be_a(FeatureDef)
43
+ expect(bearer['PARADIGM'].domain).to be_a(IdentifierDomain)
44
+ expect(bearer['PARADIGM'].default).to be_a(IdentifierValue)
45
45
  end
46
46
 
47
- it 'should support the addition of feature def' do
48
- subject.feature_def_dsl { feature_def 'CASE' => boolean }
47
+ it 'supports the addition of feature def' do
48
+ bearer.feature_def_dsl { feature_def 'CASE' => boolean }
49
49
 
50
- expect(subject['CASE']).to be_kind_of(FeatureDef)
51
- expect(subject['CASE'].domain).to be_kind_of(BooleanDomain)
50
+ expect(bearer['CASE']).to be_a(FeatureDef)
51
+ expect(bearer['CASE'].domain).to be_a(BooleanDomain)
52
52
  end
53
53
  end # context
54
54
  end # describe
@@ -14,55 +14,55 @@ module Zenlish
14
14
  let(:ft_number) { FeatureDef.new('NUMBER', enum_number) }
15
15
  let(:countable_domain) { BooleanDomain.instance }
16
16
  let(:ft_countability) { FeatureDef.new('COUNTABILITY', countable_domain) }
17
- let(:sample_parent) { FeatureStructDef.new }
17
+ let(:sample_parent) { described_class.new }
18
18
  let(:case_domain) { EnumerationDomain.new(:common, :genitive) }
19
19
  let(:ft_case) { FeatureDef.new('CASE', case_domain) }
20
20
 
21
- subject { FeatureStructDef.new(sample_parent) }
21
+ subject(:struct_def) { described_class.new(sample_parent) }
22
22
 
23
23
  context 'Initialization:' do
24
- it 'could be initialized without argument' do
25
- expect { FeatureStructDef.new }.not_to raise_error
24
+ it 'can be initialized without argument' do
25
+ expect { described_class.new }.not_to raise_error
26
26
  end
27
27
 
28
- it 'could be initialized with a parent struct' do
29
- expect { FeatureStructDef.new(sample_parent) }.not_to raise_error
28
+ it 'can be initialized with a parent struct' do
29
+ expect { described_class.new(sample_parent) }.not_to raise_error
30
30
  end
31
31
 
32
- it 'should have an empty structure at initialization' do
33
- expect(subject.struct).to be_empty
32
+ it 'has an empty structure at initialization' do
33
+ expect(struct_def.struct).to be_empty
34
34
  end
35
35
 
36
- it 'should know its parent (if any)' do
37
- expect(subject.parent).to eq(sample_parent)
38
- instance = FeatureStructDef.new
36
+ it 'knows its parent (if any)' do
37
+ expect(struct_def.parent).to eq(sample_parent)
38
+ instance = described_class.new
39
39
  expect(instance.parent).to be_nil
40
40
  end
41
41
  end # context
42
42
 
43
43
  context 'Provided services:' do
44
- it 'should accept the addition of a feature definition' do
45
- expect { subject.add_feature_def(ft_number) }.not_to raise_error
46
- expect(subject.struct.size).to eq(1)
47
- expect(subject['NUMBER']).to eq(ft_number)
44
+ it 'accepts the addition of a feature definition' do
45
+ expect { struct_def.add_feature_def(ft_number) }.not_to raise_error
46
+ expect(struct_def.struct.size).to eq(1)
47
+ expect(struct_def['NUMBER']).to eq(ft_number)
48
48
 
49
- expect { subject.add_feature_def(ft_countability) }.not_to raise_error
50
- expect(subject.struct.size).to eq(2)
51
- expect(subject['COUNTABILITY']).to eq(ft_countability)
49
+ expect { struct_def.add_feature_def(ft_countability) }.not_to raise_error
50
+ expect(struct_def.struct.size).to eq(2)
51
+ expect(struct_def['COUNTABILITY']).to eq(ft_countability)
52
52
  end
53
53
 
54
- it 'should inherit the feature definition of its parent' do
54
+ it 'inherits the feature definition of its parent' do
55
55
  sample_parent.add_feature_def(ft_case)
56
- expect(subject['CASE']).to eq(ft_case)
56
+ expect(struct_def['CASE']).to eq(ft_case)
57
57
  end
58
58
 
59
- it "should be able to override parent's feature def" do
59
+ it "is able to override parent's feature def" do
60
60
  sample_parent.add_feature_def(ft_case)
61
61
 
62
62
  other_case_domain = BooleanDomain.instance
63
63
  other_ft_case = FeatureDef.new('CASE', other_case_domain)
64
- subject.add_feature_def(other_ft_case)
65
- expect(subject['CASE']).to eq(other_ft_case)
64
+ struct_def.add_feature_def(other_ft_case)
65
+ expect(struct_def['CASE']).to eq(other_ft_case)
66
66
  end
67
67
  end # context
68
68
  end # describe
@@ -5,30 +5,30 @@ require_relative '../../../lib/zenlish/feature/identifier_domain' # Load the cla
5
5
  module Zenlish
6
6
  module Feature
7
7
  describe IdentifierDomain do
8
- subject { IdentifierDomain.instance }
8
+ subject(:domain) { described_class.instance }
9
9
 
10
10
  context 'Initialization:' do
11
- it 'should be instantiated without argument' do
12
- expect { IdentifierDomain.instance }.not_to raise_error
11
+ it 'is instantiated without argument' do
12
+ expect { described_class.instance }.not_to raise_error
13
13
  end
14
14
  end # context
15
15
 
16
16
  context 'Provided services:' do
17
- it 'should know whether a value is in domain' do
18
- expect(subject.include?('CommonForm')).to be_truthy
19
- expect(subject.include?('Common Form')).to be_falsey
20
- expect(subject.include?('+123')).to be_falsey
17
+ it 'knows whether a value is in domain' do
18
+ expect(domain).to include('CommonForm')
19
+ expect(domain).not_to include('Common Form')
20
+ expect(domain).not_to include('+123')
21
21
  end
22
22
 
23
- it 'should provide a factory method for identifier values' do
24
- expect(subject.build_value('CommonForm')).to be_kind_of(IdentifierValue)
25
- expect(subject.build_value('Common_Form')).to be_kind_of(IdentifierValue)
23
+ it 'provides a factory method for identifier values' do
24
+ expect(domain.build_value('CommonForm')).to be_a(IdentifierValue)
25
+ expect(domain.build_value('Common_Form')).to be_a(IdentifierValue)
26
26
  end
27
27
 
28
- it 'should complain when asked to build an invalid identifier' do
28
+ it 'complains when asked to build an invalid identifier' do
29
29
  err = StandardError
30
30
  err_msg = "?1234 isn't a valid identifier."
31
- expect { subject.build_value('?1234') }.to raise_error(err, err_msg)
31
+ expect { domain.build_value('?1234') }.to raise_error(err, err_msg)
32
32
  end
33
33
  end # context
34
34
  end # describe
@@ -7,15 +7,16 @@ module Zenlish
7
7
  module Feature
8
8
  describe IdentifierValue do
9
9
  let(:its_value) { 'CommonForm' }
10
- subject { IdentifierValue.new(its_value) }
10
+
11
+ subject(:identifier) { described_class.new(its_value) }
11
12
 
12
13
  context 'Initialization:' do
13
- it 'should be initialized with a value argument' do
14
- expect { IdentifierValue.new(its_value) }.not_to raise_error
14
+ it 'is initialized with a value argument' do
15
+ expect { described_class.new(its_value) }.not_to raise_error
15
16
  end
16
17
 
17
- it 'should know its internal value' do
18
- expect(subject.val).to eq(its_value)
18
+ it 'knows its internal value' do
19
+ expect(identifier.val).to eq(its_value)
19
20
  end
20
21
  end # context
21
22
 
@@ -8,15 +8,16 @@ module Zenlish
8
8
  module Feature
9
9
  describe SymbolValue do
10
10
  let(:its_value) { :plural }
11
- subject { SymbolValue.new(its_value) }
11
+
12
+ subject(:symbolic) { described_class.new(its_value) }
12
13
 
13
14
  context 'Initialization:' do
14
- it 'should be initialized with a value argument' do
15
- expect { SymbolValue.new(its_value) }.not_to raise_error
15
+ it 'is initialized with a value argument' do
16
+ expect { described_class.new(its_value) }.not_to raise_error
16
17
  end
17
18
 
18
- it 'should know its internal value' do
19
- expect(subject.val).to eq(its_value)
19
+ it 'knows its internal value' do
20
+ expect(symbolic.val).to eq(its_value)
20
21
  end
21
22
  end # context
22
23
 
@@ -12,27 +12,27 @@ module Zenlish
12
12
  let(:sample_argument) { FormalArgument.new(2) }
13
13
  let(:base_form) { InputAsIs.new(sample_argument) }
14
14
 
15
- subject { Concatenation.new(base_form, suffix) }
15
+ subject(:concatenation) { described_class.new(base_form, suffix) }
16
16
 
17
17
  context 'Initialization:' do
18
- it 'should be initialized with two arguments' do
19
- expect { Concatenation.new(base_form, suffix) }.not_to raise_error
18
+ it 'is initialized with two arguments' do
19
+ expect { described_class.new(base_form, suffix) }.not_to raise_error
20
20
  end
21
21
 
22
- it 'should know its arguments' do
23
- expect(subject.children.first).to eq(base_form)
24
- expect(subject.children.last).to eq(suffix)
22
+ it 'knows its arguments' do
23
+ expect(concatenation.children.first).to eq(base_form)
24
+ expect(concatenation.children.last).to eq(suffix)
25
25
  end
26
26
  end # context
27
27
 
28
28
  context 'Provided services:' do
29
29
  let(:sample_values) { [nil, nil, 'place', nil] }
30
30
 
31
- it 'should do the concatenation of children results' do
31
+ it 'concatenates children results' do
32
32
  headings = double('fake-headings')
33
33
  lexeme = double('fake-lexeme')
34
34
 
35
- expect(subject.generate(headings, lexeme, sample_values)).to eq('places')
35
+ expect(concatenation.generate(headings, lexeme, sample_values)).to eq('places')
36
36
  end
37
37
  end # context
38
38
  end # describe
@@ -13,44 +13,45 @@ module Zenlish
13
13
  describe EqualsLiteral do
14
14
  let(:an_argument) { FormalArgument.new(1) }
15
15
  let(:feat_val) { :plural }
16
- subject { EqualsLiteral.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 a formal argument and a literal' do
20
- expect { EqualsLiteral.new(an_argument, feat_val) }.not_to raise_error
20
+ it 'is initialized with a 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_truthy
38
+ expect(literal).to be_success(headings, lexeme, actual_args)
38
39
  actual_args[1] = :singular
39
- expect(subject.success?(headings, lexeme, actual_args)).to be_falsy
40
+ expect(literal).not_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_truthy
48
+ expect(literal).to be_success(headings, lexeme, [])
48
49
 
49
- instance = EqualsLiteral.new(an_argument, :singular)
50
- expect(instance.success?(headings, lexeme, [])).to be_truthy
50
+ instance = described_class.new(an_argument, :singular)
51
+ expect(instance).to be_success(headings, lexeme, [])
51
52
 
52
- instance = EqualsLiteral.new(an_argument, :irregular)
53
- expect(instance.success?(headings, lexeme, [])).to be_falsey
53
+ instance = described_class.new(an_argument, :irregular)
54
+ expect(instance).not_to be_success(headings, lexeme, [])
54
55
  end
55
56
  end # context
56
57
  end # describe
@@ -7,15 +7,16 @@ module Zenlish
7
7
  module Inflect
8
8
  describe FeatureHeading do
9
9
  let(:feature_name) { 'NUMBER' }
10
- subject { FeatureHeading.new(feature_name) }
10
+
11
+ subject(:ft_heading) { described_class.new(feature_name) }
11
12
 
12
13
  context 'Initialization:' do
13
- it 'should be initialized with a feature name' do
14
- expect { FeatureHeading.new(feature_name) }.not_to raise_error
14
+ it 'is initialized with a feature name' do
15
+ expect { described_class.new(feature_name) }.not_to raise_error
15
16
  end
16
17
 
17
- it 'should know its label' do
18
- expect(subject.label).to eq(feature_name)
18
+ it 'knows its label' do
19
+ expect(ft_heading.label).to eq(feature_name)
19
20
  end
20
21
  end # context
21
22
 
@@ -25,24 +26,24 @@ module Zenlish
25
26
  let(:b_domain) { Feature::BooleanDomain.instance }
26
27
  let(:bool_def) { Feature::FeatureDef.new(feature_name, b_domain) }
27
28
 
28
- it 'should obtain the value of a feature' do
29
+ it 'obtains the value of a feature' do
29
30
  mocked = { 'NUMBER' => :plural }
30
- expect(subject.evaluate_for(mocked)).to eq(:plural)
31
+ expect(ft_heading.evaluate_for(mocked)).to eq(:plural)
31
32
  end
32
33
 
33
- it 'should obtain all possible values of a feature' do
34
+ it 'obtains all possible values of a feature' do
34
35
  mocked = { 'NUMBER' => :plural }
35
- expect(subject.all_matches(mocked)).to eq([:plural])
36
+ expect(ft_heading.all_matches(mocked)).to eq([:plural])
36
37
  end
37
38
 
38
- it 'should obtain all possible values of a enumeration domain' do
39
+ it 'obtains all possible values of a enumeration domain' do
39
40
  mocked = { 'NUMBER' => enum_def }
40
- expect(subject.all_matches(mocked)).to eq(%i[singular plural])
41
+ expect(ft_heading.all_matches(mocked)).to eq(%i[singular plural])
41
42
  end
42
43
 
43
- it 'should obtain all possible values of a enumeration domain' do
44
+ it 'obtains all possible values of a enumeration domain' do
44
45
  mocked = { 'NUMBER' => bool_def }
45
- expect(subject.all_matches(mocked)).to eq([false, true])
46
+ expect(ft_heading.all_matches(mocked)).to eq([false, true])
46
47
  end
47
48
  end # context
48
49
  end # describe
@@ -6,15 +6,15 @@ require_relative '../../../lib/zenlish/inflect/formal_argument'
6
6
  module Zenlish
7
7
  module Inflect
8
8
  describe FormalArgument do
9
- subject { FormalArgument.new(3) }
9
+ subject(:arg) { described_class.new(3) }
10
10
 
11
11
  context 'Initialization:' do
12
- it 'should be initialized with a text literal' do
13
- expect { FormalArgument.new(1) }.not_to raise_error
12
+ it 'is initialized with a text literal' do
13
+ expect { described_class.new(1) }.not_to raise_error
14
14
  end
15
15
 
16
- it 'should know its index value' do
17
- expect(subject.index).to eq(3)
16
+ it 'knows its index value' do
17
+ expect(arg.index).to eq(3)
18
18
  end
19
19
  end # context
20
20
 
@@ -1,30 +1,29 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'ostruct'
4
3
  # Load the class under test
5
4
  require_relative '../../../lib/zenlish/inflect/function_call'
6
5
 
7
6
  module Zenlish
8
7
  module Inflect
9
8
  describe FunctionCall do
10
- subject { FunctionCall.new('greet') }
9
+ subject(:func_call) { described_class.new('greet') }
11
10
 
12
11
  context 'Initialization:' do
13
- it 'should be initialized with a text literal' do
14
- expect { FunctionCall.new('greet') }.not_to raise_error
12
+ it 'is initialized with a text literal' do
13
+ expect { described_class.new('greet') }.not_to raise_error
15
14
  end
16
15
 
17
- it 'should know its method name' do
18
- expect(subject.mth_name).to eq('greet')
16
+ it 'knows its method name' do
17
+ expect(func_call.mth_name).to eq('greet')
19
18
  end
20
19
  end # context
21
20
 
22
21
  context 'Provided services:' do
23
- it 'should return the affix during word form generation' do
22
+ it 'returns the affix during word form generation' do
24
23
  headings = double('fake-headings')
25
- lexeme = OpenStruct.new(greet: 'Hello, world')
24
+ lexeme = double('fake-lexeme', greet: 'Hello, world')
26
25
  values = double('fake-values')
27
- expect(subject.generate(headings, lexeme, values)).to eq('Hello, world')
26
+ expect(func_call.generate(headings, lexeme, values)).to eq('Hello, world')
28
27
  end
29
28
  end # context
30
29
  end # describe
@@ -44,21 +44,21 @@ module Zenlish
44
44
  let(:pattern) { /y$/ }
45
45
  let(:consequent) { Substitution.new(base, pattern, suffix) }
46
46
 
47
- subject { InflectionRule.new(conditions, consequent) }
47
+ subject(:i_rule) { described_class.new(conditions, consequent) }
48
48
 
49
49
  context 'Initialization:' do
50
- it 'should be initialized with condition and consequent parts' do
50
+ it 'is initialized with condition and consequent parts' do
51
51
  expect do
52
- InflectionRule.new(conditions, consequent)
52
+ described_class.new(conditions, consequent)
53
53
  end.not_to raise_error
54
54
  end
55
55
 
56
- it 'should know its condition part' do
57
- expect(subject.conditions).to eq(conditions)
56
+ it 'knows its condition part' do
57
+ expect(i_rule.conditions).to eq(conditions)
58
58
  end
59
59
 
60
- it 'should know its consequent part' do
61
- expect(subject.consequent).to eq(consequent)
60
+ it 'knows its consequent part' do
61
+ expect(i_rule.consequent).to eq(consequent)
62
62
  end
63
63
  end # context
64
64
 
@@ -68,36 +68,36 @@ module Zenlish
68
68
  let(:an_entry) { Lex::LexicalEntry.new('cherry') }
69
69
  let(:lexeme) { Lex::Lexeme.new(c_noun, an_entry) }
70
70
 
71
- it 'should succeed when all conditions succeed with actuals' do
71
+ it 'succeeds when all conditions succeed with actuals' do
72
72
  actuals = [:plural, 'cherry']
73
- expect(subject.success?(headings, fake_lexeme, actuals)).to be_truthy
73
+ expect(i_rule).to be_success(headings, fake_lexeme, actuals)
74
74
  end
75
75
 
76
- it 'should fail when one condition fails with actuals' do
76
+ it 'fails when one condition fails with actuals' do
77
77
  actuals = [:singular, 'cherry']
78
- expect(subject.success?(headings, fake_lexeme, actuals)).to be_falsy
78
+ expect(i_rule).not_to be_success(headings, fake_lexeme, actuals)
79
79
 
80
80
  actuals = [:plural, 'girl']
81
- expect(subject.success?(headings, fake_lexeme, actuals)).to be_falsy
81
+ expect(i_rule).not_to be_success(headings, fake_lexeme, actuals)
82
82
  end
83
83
 
84
- it 'should generate inflected form when rule iworks for actuals' do
84
+ it 'generates inflected form when rule iworks for actuals' do
85
85
  actuals = [:plural, 'cherry']
86
- expect(subject.apply(headings, fake_lexeme, actuals)).to eq('cherries')
86
+ expect(i_rule.apply(headings, fake_lexeme, actuals)).to eq('cherries')
87
87
  end
88
88
 
89
- it 'should succeed when all conditions succeed for given lexeme' do
90
- expect(subject.success?(headings, lexeme, [])).to be_truthy
89
+ it 'succeeds when all conditions succeed for given lexeme' do
90
+ expect(i_rule).to be_success(headings, lexeme, [])
91
91
  end
92
92
 
93
- it 'should fail when one condition fails with given lexeme' do
93
+ it 'fails when one condition fails with given lexeme' do
94
94
  entry_2 = Lex::LexicalEntry.new('animal')
95
95
  lex_m2 = Lex::Lexeme.new(c_noun, entry_2)
96
- expect(subject.success?(headings, lex_m2, [])).to be_falsy
96
+ expect(i_rule).not_to be_success(headings, lex_m2, [])
97
97
  end
98
98
 
99
- it 'should generate inflected form when rule works for given lexeme' do
100
- expect(subject.apply(headings, lexeme, [])).to eq('cherries')
99
+ it 'generates inflected form when rule works for given lexeme' do
100
+ expect(i_rule.apply(headings, lexeme, [])).to eq('cherries')
101
101
  end
102
102
  end # context
103
103
  end # describe