LittleWeasel 5.0.5 → 5.0.7

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 (65) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +9 -4
  3. data/CHANGELOG.md +8 -0
  4. data/Gemfile.lock +36 -29
  5. data/LittleWeasel.gemspec +8 -8
  6. data/lib/LittleWeasel/version.rb +1 -1
  7. data/spec/factories/dictionary.rb +27 -27
  8. data/spec/factories/dictionary_cache_service.rb +4 -6
  9. data/spec/factories/dictionary_creator_service.rb +1 -1
  10. data/spec/factories/dictionary_file_loader_service.rb +1 -1
  11. data/spec/factories/dictionary_hash.rb +26 -26
  12. data/spec/factories/dictionary_key.rb +1 -1
  13. data/spec/factories/dictionary_killer_service.rb +1 -1
  14. data/spec/factories/dictionary_manager.rb +1 -1
  15. data/spec/factories/dictionary_metadata.rb +1 -1
  16. data/spec/factories/dictionary_metadata_service.rb +1 -1
  17. data/spec/factories/numeric_filter.rb +1 -1
  18. data/spec/factories/preprocessed_word.rb +1 -1
  19. data/spec/factories/preprocessed_words.rb +1 -1
  20. data/spec/factories/single_character_word_filter.rb +1 -1
  21. data/spec/factories/word_results.rb +1 -1
  22. data/spec/lib/LittleWeasel/block_results_spec.rb +23 -23
  23. data/spec/lib/LittleWeasel/configure_spec.rb +3 -3
  24. data/spec/lib/LittleWeasel/dictionary_key_spec.rb +9 -9
  25. data/spec/lib/LittleWeasel/dictionary_manager_spec.rb +29 -29
  26. data/spec/lib/LittleWeasel/dictionary_spec.rb +30 -29
  27. data/spec/lib/LittleWeasel/filters/en_us/currency_filter_spec.rb +26 -26
  28. data/spec/lib/LittleWeasel/filters/en_us/numeric_filter_spec.rb +17 -17
  29. data/spec/lib/LittleWeasel/filters/en_us/single_character_word_filter_spec.rb +8 -8
  30. data/spec/lib/LittleWeasel/filters/word_filter_managable_spec.rb +19 -19
  31. data/spec/lib/LittleWeasel/filters/word_filter_spec.rb +17 -17
  32. data/spec/lib/LittleWeasel/filters/word_filter_validatable_spec.rb +27 -12
  33. data/spec/lib/LittleWeasel/filters/word_filters_validatable_spec.rb +6 -6
  34. data/spec/lib/LittleWeasel/integraton_tests/dictionary_integration_spec.rb +23 -23
  35. data/spec/lib/LittleWeasel/metadata/dictionary_creator_servicable_spec.rb +7 -6
  36. data/spec/lib/LittleWeasel/metadata/dictionary_metadata_spec.rb +13 -13
  37. data/spec/lib/LittleWeasel/metadata/invalid_words_metadata_spec.rb +17 -17
  38. data/spec/lib/LittleWeasel/metadata/metadata_observerable_spec.rb +1 -1
  39. data/spec/lib/LittleWeasel/modules/dictionary_file_loader_spec.rb +30 -30
  40. data/spec/lib/LittleWeasel/modules/dictionary_sourceable_spec.rb +21 -21
  41. data/spec/lib/LittleWeasel/modules/language_spec.rb +5 -5
  42. data/spec/lib/LittleWeasel/modules/locale_spec.rb +1 -1
  43. data/spec/lib/LittleWeasel/modules/region_spec.rb +5 -5
  44. data/spec/lib/LittleWeasel/preprocessors/en_us/capitalize_preprocessor_spec.rb +8 -6
  45. data/spec/lib/LittleWeasel/preprocessors/preprocessed_word_spec.rb +3 -3
  46. data/spec/lib/LittleWeasel/preprocessors/preprocessed_word_validatable_spec.rb +14 -3
  47. data/spec/lib/LittleWeasel/preprocessors/preprocessed_words_spec.rb +8 -10
  48. data/spec/lib/LittleWeasel/preprocessors/preprocessed_words_validatable_spec.rb +6 -4
  49. data/spec/lib/LittleWeasel/preprocessors/word_preprocessor_managable_spec.rb +27 -28
  50. data/spec/lib/LittleWeasel/preprocessors/word_preprocessor_spec.rb +25 -29
  51. data/spec/lib/LittleWeasel/preprocessors/word_preprocessor_validatable_spec.rb +10 -2
  52. data/spec/lib/LittleWeasel/preprocessors/word_preprocessors_validatable_spec.rb +4 -6
  53. data/spec/lib/LittleWeasel/services/dictionary_cache_service_spec.rb +51 -49
  54. data/spec/lib/LittleWeasel/services/dictionary_creator_service_spec.rb +14 -14
  55. data/spec/lib/LittleWeasel/services/dictionary_file_loader_service_spec.rb +30 -30
  56. data/spec/lib/LittleWeasel/services/dictionary_metadata_service_spec.rb +22 -22
  57. data/spec/lib/LittleWeasel/word_results_spec.rb +29 -32
  58. data/spec/lib/LittleWeasel/workflow/workflow_spec.rb +2 -2
  59. data/spec/spec_helper.rb +56 -56
  60. data/spec/support/factory_bot.rb +1 -2
  61. data/spec/support/file_helpers.rb +2 -2
  62. data/spec/support/general_helpers.rb +2 -1
  63. data/spec/support/shared_contexts.rb +13 -9
  64. data/spec/support/shared_examples.rb +10 -8
  65. metadata +33 -33
@@ -3,12 +3,12 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  RSpec.describe LittleWeasel::Services::DictionaryCacheService do
6
+ subject { create(:dictionary_cache_service, dictionary_cache: dictionary_cache) }
7
+
6
8
  include_context 'dictionary cache'
7
9
  include_context 'dictionary keys'
8
10
  include_context 'dictionary sourceable'
9
11
 
10
- subject { create(:dictionary_cache_service, dictionary_cache: dictionary_cache) }
11
-
12
12
  let(:en_us_dictionary_key) { dictionary_key_for(language: :en, region: :us) }
13
13
  let(:en_gb_dictionary_key) { dictionary_key_for(language: :en, region: :gb) }
14
14
  let(:es_es_dictionary_key) { dictionary_key_for(language: :es, region: :es) }
@@ -27,7 +27,7 @@ RSpec.describe LittleWeasel::Services::DictionaryCacheService do
27
27
  end
28
28
 
29
29
  describe 'class methods' do
30
- #.init
30
+ # .init
31
31
  describe '.init' do
32
32
  subject! { create(:dictionary_cache_service, dictionary_file_source: true, dictionary_cache: dictionary_cache) }
33
33
 
@@ -42,17 +42,18 @@ RSpec.describe LittleWeasel::Services::DictionaryCacheService do
42
42
  describe 'maintains dictionary_cache object integrity' do
43
43
  it_behaves_like 'the dictionary_cache object reference has not changed' do
44
44
  before { subject }
45
+
45
46
  let(:actual_dictionary_cache) { described_class.init(dictionary_cache: dictionary_cache) }
46
47
  let(:expected_dictionary_cache) { dictionary_cache }
47
48
  end
48
49
  end
49
50
  end
50
51
 
51
- #.init?
52
+ # .init?
52
53
  describe '.init?' do
53
54
  context 'when passing an initialized dictionary cache Hash' do
54
55
  it 'returns true' do
55
- expect(described_class.init? dictionary_cache: initialized_dictionary_cache).to eq true
56
+ expect(described_class.init?(dictionary_cache: initialized_dictionary_cache)).to be true
56
57
  end
57
58
  end
58
59
 
@@ -62,12 +63,12 @@ RSpec.describe LittleWeasel::Services::DictionaryCacheService do
62
63
  end
63
64
 
64
65
  it 'returns false' do
65
- expect(described_class.init? dictionary_cache: dictionary_cache).to eq false
66
+ expect(described_class.init?(dictionary_cache: dictionary_cache)).to be false
66
67
  end
67
68
  end
68
69
  end
69
70
 
70
- #.count
71
+ # .count
71
72
  describe '.count' do
72
73
  context 'when there are no dictionary references' do
73
74
  subject { create(:dictionary_cache_service) }
@@ -87,7 +88,7 @@ RSpec.describe LittleWeasel::Services::DictionaryCacheService do
87
88
  end
88
89
  end
89
90
 
90
- #init
91
+ # init
91
92
  describe '#init' do
92
93
  subject! { create(:dictionary_cache_service, dictionary_file_source: true, dictionary_cache: dictionary_cache) }
93
94
 
@@ -107,13 +108,13 @@ RSpec.describe LittleWeasel::Services::DictionaryCacheService do
107
108
  end
108
109
  end
109
110
 
110
- #dictionary_reference?
111
+ # dictionary_reference?
111
112
  describe '#dictionary_reference?' do
112
113
  subject { create(:dictionary_cache_service, dictionary_key: dictionary_key, dictionary_file_source: true, dictionary_cache: dictionary_cache) }
113
114
 
114
115
  context 'when the dictionary reference exists' do
115
116
  it 'returns true' do
116
- expect(subject.dictionary_reference?).to eq true
117
+ expect(subject.dictionary_reference?).to be true
117
118
  end
118
119
  end
119
120
 
@@ -128,7 +129,7 @@ RSpec.describe LittleWeasel::Services::DictionaryCacheService do
128
129
  end
129
130
 
130
131
  it 'returns false' do
131
- expect(subject.dictionary_reference?).to eq false
132
+ expect(subject.dictionary_reference?).to be false
132
133
  end
133
134
  end
134
135
 
@@ -140,7 +141,7 @@ RSpec.describe LittleWeasel::Services::DictionaryCacheService do
140
141
  end
141
142
  end
142
143
 
143
- #add_dictionary_source dictionary_source: memory_source
144
+ # add_dictionary_source dictionary_source: memory_source
144
145
  describe '#add_dictionary_source dictionary_source: memory_source' do
145
146
  subject! do
146
147
  create(:dictionary_cache_service, dictionary_cache: dictionary_cache, dictionary_key: dictionary_key)
@@ -160,33 +161,33 @@ RSpec.describe LittleWeasel::Services::DictionaryCacheService do
160
161
  let(:dictionary_cache_service) do
161
162
  create(:dictionary_cache_service, dictionary_key: en_gb_dictionary_key, dictionary_cache: subject.dictionary_cache)
162
163
  end
164
+ let(:dictionary_source) { dictionary_cache_service.dictionary_source }
163
165
 
164
166
  before do
165
167
  dictionary_cache_service.add_dictionary_source dictionary_source: memory_source
166
168
  end
167
169
 
168
- let(:dictionary_source) { dictionary_cache_service.dictionary_source }
169
-
170
170
  it 'creates a new dictionary reference' do
171
- expect(dictionary_cache_service.dictionary_reference?).to eq true
171
+ expect(dictionary_cache_service.dictionary_reference?).to be true
172
172
  end
173
173
 
174
174
  it 'creates a unique memory source' do
175
- expect(LittleWeasel::Modules::DictionarySourceable.memory_source? dictionary_source).to be_truthy
176
- expect(dictionary_source == subject.dictionary_source).to_not eq true
175
+ expect(LittleWeasel::Modules::DictionarySourceable).to be_memory_source(dictionary_source)
176
+ expect(dictionary_source == subject.dictionary_source).not_to be true
177
177
  end
178
178
  end
179
179
 
180
180
  describe 'maintains dictionary_cache object integrity' do
181
181
  it_behaves_like 'the dictionary_cache object reference has not changed' do
182
182
  subject { create(:dictionary_cache_service, dictionary_key: dictionary_key, dictionary_cache: dictionary_cache) }
183
+
183
184
  let(:actual_dictionary_cache) { subject.add_dictionary_source(dictionary_source: memory_source).dictionary_cache }
184
185
  let(:expected_dictionary_cache) { dictionary_cache }
185
186
  end
186
187
  end
187
188
  end
188
189
 
189
- #add_dictionary_source
190
+ # add_dictionary_source
190
191
  describe '#add_dictionary_source' do
191
192
  context 'when a dictionary reference for the key already exists' do
192
193
  before do
@@ -209,34 +210,34 @@ RSpec.describe LittleWeasel::Services::DictionaryCacheService do
209
210
  end
210
211
 
211
212
  let(:en_gb_file) do
212
- "#{ dictionary_path_for(file_name: en_gb_dictionary_key.key) }"
213
+ dictionary_path_for(file_name: en_gb_dictionary_key.key).to_s
213
214
  end
214
215
 
215
216
  it 'creates a new dictionary reference' do
216
217
  dictionary_cache_service = create(:dictionary_cache_service, dictionary_key: en_gb_dictionary_key, dictionary_cache: subject.dictionary_cache)
217
218
  dictionary_cache_service.add_dictionary_source dictionary_source: en_gb_file
218
- expect(dictionary_cache_service.dictionary_reference?).to eq true
219
+ expect(dictionary_cache_service.dictionary_reference?).to be true
219
220
  end
220
221
 
221
222
  context 'when the file source already exists' do
222
223
  it 'reuses the existing file source' do
223
224
  dictionary_cache_service = create(:dictionary_cache_service, dictionary_key: en_gb_dictionary_key, dictionary_cache: subject.dictionary_cache)
224
- # Note: We're using the same file as en-US dictionary key, so
225
+ # NOTE: We're using the same file as en-US dictionary key, so
225
226
  # the file source is NOT unique and will be reused.
226
227
  dictionary_cache_service.add_dictionary_source dictionary_source: file
227
- expect(LittleWeasel::Modules::DictionarySourceable.file_source? dictionary_cache_service.dictionary_source).to be_truthy
228
- expect(dictionary_cache_service.dictionary_source == subject.dictionary_source).to eq true
228
+ expect(LittleWeasel::Modules::DictionarySourceable).to be_file_source(dictionary_cache_service.dictionary_source)
229
+ expect(dictionary_cache_service.dictionary_source == subject.dictionary_source).to be true
229
230
  end
230
231
  end
231
232
 
232
233
  context 'when the file source DOES NOT already exists' do
233
234
  it 'creates a unique file source' do
234
235
  dictionary_cache_service = create(:dictionary_cache_service, dictionary_key: en_gb_dictionary_key, dictionary_cache: subject.dictionary_cache)
235
- # Note: We're using file that is DIFFERENT from the file being used by the
236
+ # NOTE: We're using file that is DIFFERENT from the file being used by the
236
237
  # en-US dictionary key, the file source created will be unique.
237
238
  dictionary_cache_service.add_dictionary_source dictionary_source: en_gb_file
238
- expect(LittleWeasel::Modules::DictionarySourceable.file_source? dictionary_cache_service.dictionary_source).to be_truthy
239
- expect(dictionary_cache_service.dictionary_source == subject.dictionary_source).to eq false
239
+ expect(LittleWeasel::Modules::DictionarySourceable).to be_file_source(dictionary_cache_service.dictionary_source)
240
+ expect(dictionary_cache_service.dictionary_source == subject.dictionary_source).to be false
240
241
  end
241
242
  end
242
243
  end
@@ -244,13 +245,14 @@ RSpec.describe LittleWeasel::Services::DictionaryCacheService do
244
245
  describe 'maintains dictionary_cache object integrity' do
245
246
  it_behaves_like 'the dictionary_cache object reference has not changed' do
246
247
  subject { create(:dictionary_cache_service, dictionary_key: dictionary_key, dictionary_cache: dictionary_cache) }
248
+
247
249
  let(:actual_dictionary_cache) { subject.add_dictionary_source(dictionary_source: file).dictionary_cache }
248
250
  let(:expected_dictionary_cache) { dictionary_cache }
249
251
  end
250
252
  end
251
253
  end
252
254
 
253
- #dictionary_file
255
+ # dictionary_file
254
256
  describe '#dictionary_file' do
255
257
  context 'when a file source is used' do
256
258
  subject! { create(:dictionary_cache_service, dictionary_key: dictionary_key).add_dictionary_source(dictionary_source: file) }
@@ -266,12 +268,12 @@ RSpec.describe LittleWeasel::Services::DictionaryCacheService do
266
268
  let(:dictionary_words) { dictionary_words_for(dictionary_file_path: file) }
267
269
 
268
270
  it 'returns the dictionary file' do
269
- expect(LittleWeasel::Modules::DictionarySourceable.memory_source? subject.dictionary_file).to be_truthy
271
+ expect(LittleWeasel::Modules::DictionarySourceable).to be_memory_source(subject.dictionary_file)
270
272
  end
271
273
  end
272
274
  end
273
275
 
274
- #dictionary_id
276
+ # dictionary_id
275
277
  describe '#dictionary_id' do
276
278
  context 'when a dictionary id exists for the given dictionary key' do
277
279
  before do
@@ -279,7 +281,7 @@ RSpec.describe LittleWeasel::Services::DictionaryCacheService do
279
281
  end
280
282
 
281
283
  it 'returns the key' do
282
- expect(subject.dictionary_id).to_not be_nil
284
+ expect(subject.dictionary_id).not_to be_nil
283
285
  end
284
286
  end
285
287
 
@@ -290,13 +292,13 @@ RSpec.describe LittleWeasel::Services::DictionaryCacheService do
290
292
  end
291
293
  end
292
294
 
293
- #dictionary_id!
295
+ # dictionary_id!
294
296
  describe '#dictionary_id!' do
295
297
  context 'when a dictionary id associated with the dictionary key exists' do
296
298
  subject { create(:dictionary_cache_service, dictionary_cache: dictionary_cache, dictionary_key: dictionary_key, dictionary_file_source: true) }
297
299
 
298
300
  it 'returns the dictionary id' do
299
- expect { subject.dictionary_id! }.to_not raise_error
301
+ expect { subject.dictionary_id! }.not_to raise_error
300
302
  end
301
303
  end
302
304
 
@@ -309,13 +311,13 @@ RSpec.describe LittleWeasel::Services::DictionaryCacheService do
309
311
  end
310
312
  end
311
313
 
312
- #dictionary_exist?
314
+ # dictionary_exist?
313
315
  describe '#dictionary_exist?' do
314
316
  context 'when the dictionary reference does not exist' do
315
317
  subject { create(:dictionary_cache_service, dictionary_cache: dictionary_cache) }
316
318
 
317
319
  it 'returns false' do
318
- expect(subject.dictionary_exist?).to eq false
320
+ expect(subject.dictionary_exist?).to be false
319
321
  end
320
322
  end
321
323
 
@@ -323,7 +325,7 @@ RSpec.describe LittleWeasel::Services::DictionaryCacheService do
323
325
  subject { create(:dictionary_cache_service, dictionary_cache: dictionary_cache, dictionary_file_source: true, load: true) }
324
326
 
325
327
  it 'returns true' do
326
- expect(subject.dictionary_exist?).to eq true
328
+ expect(subject.dictionary_exist?).to be true
327
329
  end
328
330
  end
329
331
 
@@ -331,37 +333,37 @@ RSpec.describe LittleWeasel::Services::DictionaryCacheService do
331
333
  subject { create(:dictionary_cache_service, dictionary_cache: dictionary_cache, dictionary_file_source: true) }
332
334
 
333
335
  it 'returns false' do
334
- expect(subject.dictionary_exist?).to eq false
336
+ expect(subject.dictionary_exist?).to be false
335
337
  end
336
338
  end
337
339
  end
338
340
 
339
- #dictionary_object
341
+ # dictionary_object
340
342
  describe '#dictionary_object' do
341
343
  context 'when the dictionary object is already cached/loaded' do
342
344
  subject { create(:dictionary_cache_service, dictionary_file_source: true, load: true) }
343
345
 
344
346
  it 'returns the dictionary object' do
345
- expect(subject.dictionary_object).to be_kind_of LittleWeasel::Dictionary
347
+ expect(subject.dictionary_object).to be_a LittleWeasel::Dictionary
346
348
  end
347
349
  end
348
350
 
349
351
  context 'when the dictionary object is NOT already cached/loaded' do
350
352
  context 'when the dictionary reference exists' do
351
353
  it 'returns an object that is not present?' do
352
- expect(create(:dictionary_cache_service, dictionary_file_source: true).dictionary_object).to_not be_present
354
+ expect(create(:dictionary_cache_service, dictionary_file_source: true).dictionary_object).not_to be_present
353
355
  end
354
356
  end
355
357
 
356
358
  context 'when the dictionary reference DOES NOT exist' do
357
359
  it 'returns an object that is not present?' do
358
- expect(create(:dictionary_cache_service).dictionary_object).to_not be_present
360
+ expect(create(:dictionary_cache_service).dictionary_object).not_to be_present
359
361
  end
360
362
  end
361
363
  end
362
364
  end
363
365
 
364
- #dictionary_object!
366
+ # dictionary_object!
365
367
  describe '#dictionary_object!' do
366
368
  describe 'when the dictionary is NOT in the cache' do
367
369
  it 'raises an error' do
@@ -373,14 +375,14 @@ RSpec.describe LittleWeasel::Services::DictionaryCacheService do
373
375
  subject { create(:dictionary_cache_service, dictionary_file_source: true, load: true) }
374
376
 
375
377
  it 'returns the dictionary cache for the dictionary' do
376
- expect(subject.dictionary_reference?).to eq true
377
- expect(subject.dictionary_exist?).to eq true
378
- expect(subject.dictionary_object!).to be_kind_of LittleWeasel::Dictionary
378
+ expect(subject.dictionary_reference?).to be true
379
+ expect(subject.dictionary_exist?).to be true
380
+ expect(subject.dictionary_object!).to be_a LittleWeasel::Dictionary
379
381
  end
380
382
  end
381
383
  end
382
384
 
383
- #dictionary_object=
385
+ # dictionary_object=
384
386
  describe '#dictionary_object=' do
385
387
  context 'when the dictionary object passed is invalid' do
386
388
  subject { create(:dictionary_cache_service) }
@@ -399,12 +401,12 @@ RSpec.describe LittleWeasel::Services::DictionaryCacheService do
399
401
  end
400
402
 
401
403
  context 'when there is NO dictionary reference' do
404
+ subject { create(:dictionary_cache_service, dictionary_cache: dictionary_cache, dictionary_key: dictionary_key) }
405
+
402
406
  before do
403
407
  allow(dictionary_object).to receive(:is_a?).and_return(true)
404
408
  end
405
409
 
406
- subject { create(:dictionary_cache_service, dictionary_cache: dictionary_cache, dictionary_key: dictionary_key) }
407
-
408
410
  let(:dictionary_object) { Object.new }
409
411
 
410
412
  it 'raises an error' do
@@ -418,7 +420,7 @@ RSpec.describe LittleWeasel::Services::DictionaryCacheService do
418
420
  let(:dictionary) { create(:dictionary, dictionary_cache: dictionary_cache, dictionary_key: dictionary_key) }
419
421
 
420
422
  it 'raises an error' do
421
- expect { subject.dictionary_object = dictionary }.to raise_error "The dictionary is already loaded/cached for key '#{key}'; use #unload or #kill first."
423
+ expect { subject.dictionary_object = dictionary }.to raise_error "The dictionary is already loaded/cached for key '#{key}'; use #unload or #kill first."
422
424
  end
423
425
  end
424
426
 
@@ -436,7 +438,7 @@ RSpec.describe LittleWeasel::Services::DictionaryCacheService do
436
438
  let(:dictionary) { create(:dictionary, dictionary_key: dictionary_key, dictionary_cache: dictionary_cache) }
437
439
 
438
440
  it 'updates the dictionary object' do
439
- expect { subject.dictionary_object = dictionary }.to_not raise_error
441
+ expect { subject.dictionary_object = dictionary }.not_to raise_error
440
442
  expect(subject.dictionary_object).to eq dictionary
441
443
  end
442
444
  end
@@ -3,12 +3,12 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  RSpec.describe LittleWeasel::Services::DictionaryCreatorService do
6
+ subject { create(:dictionary_creator_service, dictionary_key: dictionary_key, dictionary_cache: dictionary_cache, dictionary_metadata: dictionary_metadata, word_filters: word_filters, word_preprocessors: word_preprocessors) }
7
+
6
8
  include_context 'dictionary keys'
7
9
  include_context 'mock word filters'
8
10
  include_context 'mock word preprocessors'
9
11
 
10
- subject { create(:dictionary_creator_service, dictionary_key: dictionary_key, dictionary_cache: dictionary_cache, dictionary_metadata: dictionary_metadata, word_filters: word_filters, word_preprocessors: word_preprocessors) }
11
-
12
12
  let(:language) { :en }
13
13
  let(:region) { :us }
14
14
  let(:tag) {}
@@ -32,10 +32,10 @@ RSpec.describe LittleWeasel::Services::DictionaryCreatorService do
32
32
  end
33
33
 
34
34
  it 'creates a dictionary with the word filters passed' do
35
- expect(dictionary).to be_kind_of LittleWeasel::Dictionary
36
- expect(dictionary.word_results('$').success?).to eq true
37
- expect(dictionary.word_results('1000').success?).to eq true
38
- expect(dictionary.word_results('A').success?).to eq true
35
+ expect(dictionary).to be_a LittleWeasel::Dictionary
36
+ expect(dictionary.word_results('$').success?).to be true
37
+ expect(dictionary.word_results('1000').success?).to be true
38
+ expect(dictionary.word_results('A').success?).to be true
39
39
  end
40
40
  end
41
41
  end
@@ -45,7 +45,7 @@ RSpec.describe LittleWeasel::Services::DictionaryCreatorService do
45
45
  let(:word_filters) { [] }
46
46
 
47
47
  it 'creates a dictionary that uses no word filters' do
48
- expect(dictionary).to be_kind_of LittleWeasel::Dictionary
48
+ expect(dictionary).to be_a LittleWeasel::Dictionary
49
49
  expect(dictionary.word_filters).to be_blank
50
50
  end
51
51
  end
@@ -54,7 +54,7 @@ RSpec.describe LittleWeasel::Services::DictionaryCreatorService do
54
54
  let(:word_filters) {}
55
55
 
56
56
  it 'creates a dictionary that uses no word filters' do
57
- expect(dictionary).to be_kind_of LittleWeasel::Dictionary
57
+ expect(dictionary).to be_a LittleWeasel::Dictionary
58
58
  expect(dictionary.word_filters).to be_blank
59
59
  end
60
60
  end
@@ -66,14 +66,14 @@ RSpec.describe LittleWeasel::Services::DictionaryCreatorService do
66
66
 
67
67
  context 'when argument word_preprocessors contains word preprocessors' do
68
68
  it 'creates a dictionary with the word preprocessors passed' do
69
- expect(dictionary).to be_kind_of LittleWeasel::Dictionary
69
+ expect(dictionary).to be_a LittleWeasel::Dictionary
70
70
  preprocessed_words = dictionary.word_results(word).preprocessed_words
71
71
  expect(preprocessed_words.original_word).to eq word
72
72
  expect(preprocessed_words.preprocessed_words.count).to eq 1
73
73
  expect(preprocessed_words.preprocessed_words[0].original_word).to eq word
74
74
  expect(preprocessed_words.preprocessed_words[0].preprocessed_word).to eq word.upcase
75
75
  expect(preprocessed_words.preprocessed_words[0].preprocessor).to eq word_preprocessors[0].to_sym
76
- expect(preprocessed_words.preprocessed_words[0].preprocessed).to eq true
76
+ expect(preprocessed_words.preprocessed_words[0].preprocessed).to be true
77
77
  expect(preprocessed_words.preprocessed_words[0].preprocessor_order).to eq word_preprocessors[0].order
78
78
  end
79
79
  end
@@ -84,7 +84,7 @@ RSpec.describe LittleWeasel::Services::DictionaryCreatorService do
84
84
  let(:word_preprocessors) { [] }
85
85
 
86
86
  it 'creates a dictionary that uses no word preprocessors' do
87
- expect(dictionary).to be_kind_of LittleWeasel::Dictionary
87
+ expect(dictionary).to be_a LittleWeasel::Dictionary
88
88
  expect(dictionary.word_preprocessors).to be_blank
89
89
  end
90
90
  end
@@ -93,21 +93,21 @@ RSpec.describe LittleWeasel::Services::DictionaryCreatorService do
93
93
  let(:word_preprocessors) {}
94
94
 
95
95
  it 'creates a dictionary that uses no word preprocessors' do
96
- expect(dictionary).to be_kind_of LittleWeasel::Dictionary
96
+ expect(dictionary).to be_a LittleWeasel::Dictionary
97
97
  expect(dictionary.word_preprocessors).to be_blank
98
98
  end
99
99
  end
100
100
  end
101
101
  end
102
102
 
103
- #from_file_source
103
+ # from_file_source
104
104
  describe '#from_file_source' do
105
105
  let(:dictionary) { subject.from_file_source file: file }
106
106
 
107
107
  it_behaves_like 'it should'
108
108
  end
109
109
 
110
- #from_memory_source
110
+ # from_memory_source
111
111
  describe '#from_memory_source' do
112
112
  let(:dictionary) { subject.from_memory_source dictionary_words: dictionary_words }
113
113
  let(:dictionary_words) do
@@ -3,11 +3,11 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  RSpec.describe LittleWeasel::Services::DictionaryFileLoaderService do
6
- include_context 'dictionary cache'
7
-
8
6
  subject! { create(:dictionary_file_loader_service, dictionary_key: dictionary_key, dictionary_cache: dictionary_cache) }
9
7
 
10
- before(:each) do
8
+ include_context 'dictionary cache'
9
+
10
+ before do
11
11
  LittleWeasel::Services::DictionaryCacheService.init dictionary_cache: dictionary_cache
12
12
  end
13
13
 
@@ -15,7 +15,7 @@ RSpec.describe LittleWeasel::Services::DictionaryFileLoaderService do
15
15
  let(:key) { dictionary_key.key }
16
16
  let(:dictionary_cache) { {} }
17
17
 
18
- #execute
18
+ # execute
19
19
  describe '#execute' do
20
20
  context 'when the dictionary is already loaded/cached' do
21
21
  before do
@@ -34,32 +34,32 @@ RSpec.describe LittleWeasel::Services::DictionaryFileLoaderService do
34
34
 
35
35
  let(:expected_key) { create(:dictionary_key, language: :en, region: :us).key }
36
36
  let(:expected_results) do
37
- ['apple',
38
- 'better',
39
- 'cat',
40
- 'dog',
41
- 'everyone',
42
- 'fat',
43
- 'game',
44
- 'help',
45
- 'italic',
46
- 'jasmine',
47
- 'kelp',
48
- 'love',
49
- 'man',
50
- 'nope',
51
- 'octopus',
52
- 'popeye',
53
- 'queue',
54
- 'ruby',
55
- 'stop',
56
- 'top',
57
- 'ultimate',
58
- 'very',
59
- 'was',
60
- 'xylophone',
61
- 'yes',
62
- 'zebra']
37
+ %w[apple
38
+ better
39
+ cat
40
+ dog
41
+ everyone
42
+ fat
43
+ game
44
+ help
45
+ italic
46
+ jasmine
47
+ kelp
48
+ love
49
+ man
50
+ nope
51
+ octopus
52
+ popeye
53
+ queue
54
+ ruby
55
+ stop
56
+ top
57
+ ultimate
58
+ very
59
+ was
60
+ xylophone
61
+ yes
62
+ zebra]
63
63
  end
64
64
 
65
65
  it 'returns an Array of dictionary words loaded from the file' do