LittleWeasel 3.0.3 → 5.0.0

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 (151) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +3 -0
  3. data/.reek.yml +17 -0
  4. data/.rspec +4 -2
  5. data/.rubocop.yml +187 -0
  6. data/.ruby-version +1 -1
  7. data/.yardopts +2 -0
  8. data/CHANGELOG.md +22 -1
  9. data/Gemfile +3 -1
  10. data/Jenkinsfile +20 -0
  11. data/LittleWeasel.gemspec +31 -18
  12. data/README.md +408 -42
  13. data/Rakefile +296 -3
  14. data/lib/LittleWeasel/block_results.rb +81 -0
  15. data/lib/LittleWeasel/configure.rb +98 -0
  16. data/lib/LittleWeasel/dictionary.rb +125 -0
  17. data/lib/LittleWeasel/dictionary_key.rb +48 -0
  18. data/lib/LittleWeasel/dictionary_manager.rb +91 -0
  19. data/lib/LittleWeasel/errors/dictionary_file_already_loaded_error.rb +9 -0
  20. data/lib/LittleWeasel/errors/dictionary_file_empty_error.rb +8 -0
  21. data/lib/LittleWeasel/errors/dictionary_file_not_found_error.rb +8 -0
  22. data/lib/LittleWeasel/errors/dictionary_file_too_large_error.rb +16 -0
  23. data/lib/LittleWeasel/errors/language_required_error.rb +8 -0
  24. data/lib/LittleWeasel/errors/must_override_error.rb +8 -0
  25. data/lib/LittleWeasel/filters/en_us/currency_filter.rb +19 -0
  26. data/lib/LittleWeasel/filters/en_us/numeric_filter.rb +19 -0
  27. data/lib/LittleWeasel/filters/en_us/single_character_word_filter.rb +21 -0
  28. data/lib/LittleWeasel/filters/word_filter.rb +59 -0
  29. data/lib/LittleWeasel/filters/word_filter_managable.rb +80 -0
  30. data/lib/LittleWeasel/filters/word_filter_validatable.rb +31 -0
  31. data/lib/LittleWeasel/filters/word_filterable.rb +19 -0
  32. data/lib/LittleWeasel/filters/word_filters_validatable.rb +29 -0
  33. data/lib/LittleWeasel/metadata/dictionary_metadata.rb +145 -0
  34. data/lib/LittleWeasel/metadata/invalid_words_metadata.rb +134 -0
  35. data/lib/LittleWeasel/metadata/invalid_words_service_results.rb +45 -0
  36. data/lib/LittleWeasel/metadata/metadata_observable_validatable.rb +22 -0
  37. data/lib/LittleWeasel/metadata/metadata_observerable.rb +90 -0
  38. data/lib/LittleWeasel/metadata/metadatable.rb +134 -0
  39. data/lib/LittleWeasel/modules/class_name_to_symbol.rb +26 -0
  40. data/lib/LittleWeasel/modules/configurable.rb +26 -0
  41. data/lib/LittleWeasel/modules/deep_dup.rb +11 -0
  42. data/lib/LittleWeasel/modules/dictionary_cache_keys.rb +34 -0
  43. data/lib/LittleWeasel/modules/dictionary_cache_servicable.rb +26 -0
  44. data/lib/LittleWeasel/modules/dictionary_cache_validatable.rb +18 -0
  45. data/lib/LittleWeasel/modules/dictionary_creator_servicable.rb +27 -0
  46. data/lib/LittleWeasel/modules/dictionary_file_loader.rb +67 -0
  47. data/lib/LittleWeasel/modules/dictionary_key_validatable.rb +17 -0
  48. data/lib/LittleWeasel/modules/dictionary_keyable.rb +24 -0
  49. data/lib/LittleWeasel/modules/dictionary_metadata_servicable.rb +29 -0
  50. data/lib/LittleWeasel/modules/dictionary_metadata_validatable.rb +15 -0
  51. data/lib/LittleWeasel/modules/dictionary_source_validatable.rb +15 -0
  52. data/lib/LittleWeasel/modules/dictionary_sourceable.rb +86 -0
  53. data/lib/LittleWeasel/modules/dictionary_validatable.rb +18 -0
  54. data/lib/LittleWeasel/modules/language.rb +24 -0
  55. data/lib/LittleWeasel/modules/language_validatable.rb +14 -0
  56. data/lib/LittleWeasel/modules/locale.rb +23 -0
  57. data/lib/LittleWeasel/modules/order_validatable.rb +16 -0
  58. data/lib/LittleWeasel/modules/orderable.rb +17 -0
  59. data/lib/LittleWeasel/modules/region.rb +24 -0
  60. data/lib/LittleWeasel/modules/region_validatable.rb +14 -0
  61. data/lib/LittleWeasel/modules/tag_validatable.rb +14 -0
  62. data/lib/LittleWeasel/modules/taggable.rb +31 -0
  63. data/lib/LittleWeasel/modules/word_results_validatable.rb +28 -0
  64. data/lib/LittleWeasel/preprocessors/en_us/capitalize_preprocessor.rb +22 -0
  65. data/lib/LittleWeasel/preprocessors/preprocessed_word.rb +29 -0
  66. data/lib/LittleWeasel/preprocessors/preprocessed_word_validatable.rb +56 -0
  67. data/lib/LittleWeasel/preprocessors/preprocessed_words.rb +59 -0
  68. data/lib/LittleWeasel/preprocessors/preprocessed_words_validatable.rb +28 -0
  69. data/lib/LittleWeasel/preprocessors/word_preprocessable.rb +19 -0
  70. data/lib/LittleWeasel/preprocessors/word_preprocessor.rb +123 -0
  71. data/lib/LittleWeasel/preprocessors/word_preprocessor_managable.rb +114 -0
  72. data/lib/LittleWeasel/preprocessors/word_preprocessor_validatable.rb +40 -0
  73. data/lib/LittleWeasel/preprocessors/word_preprocessors_validatable.rb +24 -0
  74. data/lib/LittleWeasel/services/dictionary_cache_service.rb +211 -0
  75. data/lib/LittleWeasel/services/dictionary_creator_service.rb +94 -0
  76. data/lib/LittleWeasel/services/dictionary_file_loader_service.rb +37 -0
  77. data/lib/LittleWeasel/services/dictionary_killer_service.rb +35 -0
  78. data/lib/LittleWeasel/services/dictionary_metadata_service.rb +116 -0
  79. data/lib/LittleWeasel/services/invalid_words_service.rb +59 -0
  80. data/lib/LittleWeasel/version.rb +3 -1
  81. data/lib/LittleWeasel/word_results.rb +146 -0
  82. data/lib/LittleWeasel.rb +5 -184
  83. data/spec/factories/dictionary.rb +43 -0
  84. data/spec/factories/dictionary_cache_service.rb +95 -0
  85. data/spec/factories/dictionary_creator_service.rb +16 -0
  86. data/spec/factories/dictionary_file_loader_service.rb +13 -0
  87. data/spec/factories/dictionary_hash.rb +39 -0
  88. data/spec/factories/dictionary_key.rb +14 -0
  89. data/spec/factories/dictionary_killer_service.rb +14 -0
  90. data/spec/factories/dictionary_manager.rb +10 -0
  91. data/spec/factories/dictionary_metadata.rb +16 -0
  92. data/spec/factories/dictionary_metadata_service.rb +16 -0
  93. data/spec/factories/numeric_filter.rb +12 -0
  94. data/spec/factories/preprocessed_word.rb +16 -0
  95. data/spec/factories/preprocessed_words.rb +41 -0
  96. data/spec/factories/single_character_word_filter.rb +12 -0
  97. data/spec/factories/word_results.rb +16 -0
  98. data/spec/lib/LittleWeasel/block_results_spec.rb +248 -0
  99. data/spec/lib/LittleWeasel/configure_spec.rb +74 -0
  100. data/spec/lib/LittleWeasel/dictionary_key_spec.rb +118 -0
  101. data/spec/lib/LittleWeasel/dictionary_manager_spec.rb +166 -0
  102. data/spec/lib/LittleWeasel/dictionary_spec.rb +289 -0
  103. data/spec/lib/LittleWeasel/filters/en_us/currency_filter_spec.rb +80 -0
  104. data/spec/lib/LittleWeasel/filters/en_us/numeric_filter_spec.rb +66 -0
  105. data/spec/lib/LittleWeasel/filters/en_us/single_character_word_filter_spec.rb +58 -0
  106. data/spec/lib/LittleWeasel/filters/word_filter_managable_spec.rb +180 -0
  107. data/spec/lib/LittleWeasel/filters/word_filter_spec.rb +151 -0
  108. data/spec/lib/LittleWeasel/filters/word_filter_validatable_spec.rb +94 -0
  109. data/spec/lib/LittleWeasel/filters/word_filters_validatable_spec.rb +48 -0
  110. data/spec/lib/LittleWeasel/integraton_tests/dictionary_integration_spec.rb +201 -0
  111. data/spec/lib/LittleWeasel/metadata/dictionary_creator_servicable_spec.rb +54 -0
  112. data/spec/lib/LittleWeasel/metadata/dictionary_metadata_spec.rb +209 -0
  113. data/spec/lib/LittleWeasel/metadata/invalid_words_metadata_spec.rb +155 -0
  114. data/spec/lib/LittleWeasel/metadata/metadata_observerable_spec.rb +31 -0
  115. data/spec/lib/LittleWeasel/metadata/metadatable_spec.rb +35 -0
  116. data/spec/lib/LittleWeasel/modules/class_name_to_symbol_spec.rb +21 -0
  117. data/spec/lib/LittleWeasel/modules/dictionary_file_loader_spec.rb +125 -0
  118. data/spec/lib/LittleWeasel/modules/dictionary_sourceable_spec.rb +81 -0
  119. data/spec/lib/LittleWeasel/modules/language_spec.rb +112 -0
  120. data/spec/lib/LittleWeasel/modules/locale_spec.rb +95 -0
  121. data/spec/lib/LittleWeasel/modules/region_spec.rb +112 -0
  122. data/spec/lib/LittleWeasel/preprocessors/en_us/capitalize_preprocessor_spec.rb +34 -0
  123. data/spec/lib/LittleWeasel/preprocessors/preprocessed_word_spec.rb +105 -0
  124. data/spec/lib/LittleWeasel/preprocessors/preprocessed_word_validatable_spec.rb +143 -0
  125. data/spec/lib/LittleWeasel/preprocessors/preprocessed_words_spec.rb +77 -0
  126. data/spec/lib/LittleWeasel/preprocessors/preprocessed_words_validatable_spec.rb +58 -0
  127. data/spec/lib/LittleWeasel/preprocessors/word_preprocessor_managable_spec.rb +242 -0
  128. data/spec/lib/LittleWeasel/preprocessors/word_preprocessor_spec.rb +218 -0
  129. data/spec/lib/LittleWeasel/preprocessors/word_preprocessor_validatable_spec.rb +109 -0
  130. data/spec/lib/LittleWeasel/preprocessors/word_preprocessors_validatable_spec.rb +49 -0
  131. data/spec/lib/LittleWeasel/services/dictionary_cache_service_spec.rb +444 -0
  132. data/spec/lib/LittleWeasel/services/dictionary_creator_service_spec.rb +119 -0
  133. data/spec/lib/LittleWeasel/services/dictionary_file_loader_service_spec.rb +71 -0
  134. data/spec/lib/LittleWeasel/services/dictionary_metadata_service_spec.rb +279 -0
  135. data/spec/lib/LittleWeasel/word_results_spec.rb +275 -0
  136. data/spec/lib/LittleWeasel/workflow/workflow_spec.rb +20 -0
  137. data/spec/spec_helper.rb +117 -6
  138. data/spec/support/factory_bot.rb +15 -0
  139. data/spec/support/file_helpers.rb +46 -0
  140. data/spec/support/files/empty-dictionary.txt +0 -0
  141. data/{lib/dictionary → spec/support/files/en-US-big.txt} +262156 -31488
  142. data/spec/support/files/en-US-tagged.txt +26 -0
  143. data/spec/support/files/en-US.txt +26 -0
  144. data/spec/support/files/en.txt +26 -0
  145. data/spec/support/files/es-ES.txt +27 -0
  146. data/spec/support/files/es.txt +27 -0
  147. data/spec/support/general_helpers.rb +68 -0
  148. data/spec/support/shared_contexts.rb +107 -0
  149. data/spec/support/shared_examples.rb +105 -0
  150. metadata +378 -38
  151. data/spec/checker/checker_spec.rb +0 -286
@@ -0,0 +1,26 @@
1
+ a
2
+ better
3
+ cat
4
+ dog
5
+ everyone
6
+ fat
7
+ game
8
+ help
9
+ italic
10
+ jasmine
11
+ kelp
12
+ love
13
+ man
14
+ nope
15
+ octopus
16
+ popeye
17
+ queue
18
+ ruby
19
+ stop
20
+ top
21
+ ultimate
22
+ very
23
+ was
24
+ xylophone
25
+ yes
26
+ zebra
@@ -0,0 +1,26 @@
1
+ apple
2
+ better
3
+ cat
4
+ dog
5
+ everyone
6
+ fat
7
+ game
8
+ help
9
+ italic
10
+ jasmine
11
+ kelp
12
+ love
13
+ man
14
+ nope
15
+ octopus
16
+ popeye
17
+ queue
18
+ ruby
19
+ stop
20
+ top
21
+ ultimate
22
+ very
23
+ was
24
+ xylophone
25
+ yes
26
+ zebra
@@ -0,0 +1,26 @@
1
+ a
2
+ better
3
+ cat
4
+ dog
5
+ everyone
6
+ fat
7
+ game
8
+ help
9
+ italic
10
+ jasmine
11
+ kelp
12
+ love
13
+ man
14
+ nope
15
+ octopus
16
+ popeye
17
+ queue
18
+ ruby
19
+ stop
20
+ top
21
+ ultimate
22
+ very
23
+ was
24
+ xylophone
25
+ yes
26
+ zebra
@@ -0,0 +1,27 @@
1
+ armadillo
2
+ biblioteca
3
+ carcajada
4
+ decidir
5
+ elefante
6
+ falsificar
7
+ gigante
8
+ hechizo
9
+ iniciar
10
+ jajajear
11
+ kaki
12
+ labial
13
+ mamá
14
+ nene
15
+ ñoño
16
+ coco
17
+ papá
18
+ quiquiriquí
19
+ ronronear
20
+ sisear
21
+ tetera
22
+ ulular
23
+ vivir
24
+ wifi
25
+ sexto
26
+ yoyó
27
+ zarzamora
@@ -0,0 +1,27 @@
1
+ armadillo
2
+ biblioteca
3
+ carcajada
4
+ decidir
5
+ elefante
6
+ falsificar
7
+ gigante
8
+ hechizo
9
+ iniciar
10
+ jajajear
11
+ kaki
12
+ labial
13
+ mamá
14
+ nene
15
+ ñoño
16
+ coco
17
+ papá
18
+ quiquiriquí
19
+ ronronear
20
+ sisear
21
+ tetera
22
+ ulular
23
+ vivir
24
+ wifi
25
+ sexto
26
+ yoyó
27
+ zarzamora
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Support
4
+ # Provides miscellaneous help methods for use in specs.
5
+ module GeneralHelpers
6
+ # For some reason, passing create(described_class) raises
7
+ # a "KeyError: Factory not registered: LittleWeasel::Klass"
8
+ # error where Klass == (for example) any Dictionary or
9
+ # subclass. This creates a symbol from the class name that
10
+ # factory_bot will like.
11
+
12
+ # :reek:UtilityFunction - ignored, this is only spec support.
13
+ def sym_for(klass)
14
+ klass.name.demodulize.underscore.to_sym
15
+ end
16
+
17
+ module DictionaryResultsHelpers
18
+ module_function
19
+
20
+ def print_word_results(word, word_results, comments = nil)
21
+ puts "# Comments: #{comments}" unless comments.nil?
22
+ puts "# Results of calling #word_results for '#{word}'..."
23
+ print_results(word: word, results: word_results, indent: 1)
24
+ end
25
+
26
+ def print_block_results(word_block, block_results, comments = nil)
27
+ puts "# Comments: #{comments}" unless comments.nil?
28
+ puts '# Results of calling #word_block with:'
29
+ puts "# \"#{word_block}\"..."
30
+ puts
31
+ puts 'block_results #=>'
32
+ puts " #preprocessed_words_or_original_words #=> #{block_results.preprocessed_words_or_original_words}"
33
+
34
+ puts 'word_results #=>'
35
+ block_results.word_results.each do |word_results|
36
+ print_results(word: word_results.original_word, results: word_results, indent: 1)
37
+ end
38
+ end
39
+
40
+ def print_results(word:, results:, indent: 0)
41
+ indent = ' ' * indent
42
+ puts "#{indent}word_results #=>"
43
+ puts "#{indent * 2}original_word #=> \"#{results.original_word}\""
44
+ puts "#{indent * 2}preprocessed_word #=> #{string_or_nil results.preprocessed_word}"
45
+ puts "#{indent * 2}success? #=> #{results.success?}"
46
+ puts "#{indent * 2}word_valid? #=> #{results.word_valid?}"
47
+ puts "#{indent * 2}word_cached? #=> #{results.word_cached?}"
48
+ puts "#{indent * 2}preprocessed_word? #=> #{results.preprocessed_word?}"
49
+ puts "#{indent * 2}preprocessed_word_or_original_word #=> #{string_or_nil results.preprocessed_word_or_original_word}"
50
+ puts "#{indent * 2}filter_match? #=> #{results.filter_match?}"
51
+ puts "#{indent * 2}filters_matched: #=> #{results.filters_matched}"
52
+ puts "#{indent * 2}preprocessed_words #=>"
53
+ results.preprocessed_words&.preprocessed_words.each_with_index do |preprocessed_word, index|
54
+ puts "#{indent * 3}preprocessed_words[#{index}] #=>"
55
+ puts "#{indent * 4}preprocessed_word #=>"
56
+ puts "#{indent * 5}preprocessor: :#{preprocessed_word.preprocessor}"
57
+ puts "#{indent * 5}preprocessor_order: #{preprocessed_word.preprocessor_order}"
58
+ end
59
+ puts
60
+ end
61
+
62
+ def string_or_nil(value)
63
+ return 'nil' if value.nil?
64
+ "\"#{value}\""
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,107 @@
1
+ RSpec.shared_context 'dictionary cache' do
2
+ def dictionary_cache_for(dictionary_key:, dictionary_file_source: true, load: false)
3
+ dictionary_cache_from(dictionary_keys: [{ dictionary_key: dictionary_key, dictionary_file_source: dictionary_file_source, load: load }])
4
+ end
5
+
6
+ # This method simple returns a snapshot of what the dictionary cache would
7
+ # look like if the given dictionary_key(s) were added as a dictionary reference.
8
+ # This method expects an Array of Hashes having the following format; if
9
+ # load is omitted, 'load: false' is the default:
10
+ #
11
+ # [
12
+ # {
13
+ # dictionary_key: <dictionary_key>
14
+ # dictionary_file_source: nil | true | false | <file name minus extension>,
15
+ # dictionary_memory_source: nil | true | false |,
16
+ # [, load: true | false]
17
+ # }
18
+ # ]
19
+ def dictionary_cache_from(dictionary_keys:)
20
+ raise ArgumentError, 'Argument dictionary_keys is not an Array' unless dictionary_keys.is_a? Array
21
+
22
+ dictionary_cache = {}
23
+
24
+ dictionary_keys.each do |hash|
25
+ raise ArgumentError, "Expected required Hash key :dictionary_key but it was not found" unless hash.key? :dictionary_key
26
+
27
+ create(:dictionary_cache_service,
28
+ dictionary_cache: dictionary_cache,
29
+ dictionary_key: hash[:dictionary_key],
30
+ dictionary_file_source: hash[:dictionary_file_source],
31
+ dictionary_memory_source: hash[:dictionary_memory_source],
32
+ load: hash.fetch(:load, false))
33
+ end
34
+
35
+ dictionary_cache
36
+ end
37
+ end
38
+
39
+ RSpec.shared_context 'dictionary keys' do
40
+ def dictionary_key_for(language:, region: nil, tag: nil)
41
+ create(:dictionary_key, language: language, region: region, tag: tag)
42
+ end
43
+ end
44
+
45
+ RSpec.shared_context 'mock word filters' do
46
+ unless Object.const_defined?('WordFilter01')
47
+ class WordFilter01 < LittleWeasel::Filters::WordFilter
48
+ class << self
49
+ def filter_match?(word)
50
+ true
51
+ end
52
+ end
53
+ end
54
+ end
55
+
56
+ unless Object.const_defined?('WordFilter02')
57
+ class WordFilter02 < LittleWeasel::Filters::WordFilter
58
+ class << self
59
+ def filter_match?(word)
60
+ true
61
+ end
62
+ end
63
+ end
64
+ end
65
+
66
+ unless Object.const_defined?('DollarSignFilter')
67
+ class DollarSignFilter < LittleWeasel::Filters::WordFilter
68
+ class << self
69
+ def filter_match?(word)
70
+ word == '$'
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
76
+
77
+ RSpec.shared_context 'mock word preprocessors' do
78
+ class UpcaseWordPreprocessor < LittleWeasel::Preprocessors::WordPreprocessor
79
+ class << self
80
+ def preprocess(word)
81
+ [true, word.upcase];
82
+ end
83
+ end
84
+ end
85
+
86
+ class DowncaseWordPreprocessor < LittleWeasel::Preprocessors::WordPreprocessor
87
+ class << self
88
+ def preprocess(word)
89
+ [true, word.downcase];
90
+ end
91
+ end
92
+ end
93
+ end
94
+
95
+ RSpec.shared_context 'dictionary sourceable' do
96
+ def memory_source
97
+ LittleWeasel::Modules::DictionarySourceable.memory_source
98
+ end
99
+ end
100
+
101
+ RSpec.configure do |config|
102
+ config.include_context 'dictionary cache', include_shared: true
103
+ config.include_context 'dictionary keys', include_shared: true
104
+ config.include_context 'dictionary sourceable', include_shared: true
105
+ config.include_context 'mock word filters', include_shared: true
106
+ config.include_context 'mock word preprocessors', include_shared: true
107
+ end
@@ -0,0 +1,105 @@
1
+ RSpec.shared_examples 'the dictionary_key is invalid' do
2
+ context 'when the dictionary_key is nil' do
3
+ let(:dictionary_key) {}
4
+
5
+ it 'raises an error' do
6
+ expect { subject }.to raise_error "Argument dictionary_key is not a valid DictionaryKey object: #{dictionary_key.class}"
7
+ end
8
+ end
9
+
10
+ context 'when the dictionary_key is the wrong type' do
11
+ let(:dictionary_key) { :bad_dictionary_key }
12
+
13
+ it 'raises an error' do
14
+ expect { subject }.to raise_error "Argument dictionary_key is not a valid DictionaryKey object: #{dictionary_key.class}"
15
+ end
16
+ end
17
+ end
18
+
19
+ RSpec.shared_examples 'the dictionary_cache is invalid' do
20
+ context 'when the dictionary_cache is nil' do
21
+ let(:dictionary_cache) {}
22
+
23
+ it 'raises an error' do
24
+ expect { subject }.to raise_error "Argument dictionary_cache is not a valid Hash object: #{dictionary_cache.class}"
25
+ end
26
+ end
27
+
28
+ context 'when the dictionary_cache is the wrong type' do
29
+ let(:dictionary_cache) { :bad_dictionary_cache }
30
+
31
+ it 'raises an error' do
32
+ expect { subject }.to raise_error "Argument dictionary_cache is not a valid Hash object: #{dictionary_cache.class}"
33
+ end
34
+ end
35
+ end
36
+
37
+ RSpec.shared_examples 'the dictionary_metadata is invalid' do
38
+ context 'when the dictionary_metadata is nil' do
39
+ let(:dictionary_metadata) {}
40
+
41
+ it 'raises an error' do
42
+ expect { subject }.to raise_error "Argument dictionary_metadata is not a valid Hash object: #{dictionary_metadata.class}"
43
+ end
44
+ end
45
+
46
+ context 'when the dictionary_metadata is the wrong type' do
47
+ let(:dictionary_metadata) { :bad_dictionary_metadata }
48
+
49
+ it 'raises an error' do
50
+ expect { subject }.to raise_error "Argument dictionary_metadata is not a valid Hash object: #{dictionary_metadata.class}"
51
+ end
52
+ end
53
+ end
54
+
55
+ # Word filter shared examples
56
+
57
+ RSpec.shared_examples 'the filter matches and #filter_on? is true' do
58
+ it 'returns true' do
59
+ expect(subject.filter_match? word).to eq true
60
+ end
61
+ end
62
+
63
+ RSpec.shared_examples 'the filter DOES NOT match and #filter_on? is true' do
64
+ it 'returns false' do
65
+ expect(subject.filter_match? word).to eq false
66
+ end
67
+ end
68
+
69
+ RSpec.shared_examples 'the filter matches and #filter_on? is false' do
70
+ it 'returns false' do
71
+ expect(subject.filter_match? word).to eq false
72
+ end
73
+ end
74
+
75
+ RSpec.shared_examples 'the filter DOES NOT match and #filter_on? is false' do
76
+ it 'returns false' do
77
+ expect(subject.filter_match? word).to eq false
78
+ end
79
+ end
80
+
81
+ # Preprocessor shared examples
82
+
83
+ RSpec.shared_examples 'the preprocessor matches and #preprocessor_on? is true' do
84
+ it 'returns true' do
85
+ expect(subject.preprocess? word).to eq true
86
+ end
87
+ end
88
+
89
+ RSpec.shared_examples 'the preprocessor DOES NOT match and #preprocessor_on? is true' do
90
+ it 'returns false' do
91
+ expect(subject.preprocess? word).to eq false
92
+ end
93
+ end
94
+
95
+ RSpec.shared_examples 'the preprocessor matches and #preprocessor_on? is false' do
96
+ it 'returns false' do
97
+ expect(subject.preprocess? word).to eq false
98
+ end
99
+ end
100
+
101
+ RSpec.shared_examples 'the preprocessor DOES NOT match and #preprocessor_on? is false' do
102
+ it 'returns false' do
103
+ expect(subject.preprocess? word).to eq false
104
+ end
105
+ end