LittleWeasel 5.0.5 → 5.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +9 -4
  3. data/CHANGELOG.md +4 -0
  4. data/Gemfile.lock +27 -16
  5. data/LittleWeasel.gemspec +5 -5
  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 +25 -19
@@ -9,15 +9,15 @@ RSpec.describe LittleWeasel::DictionaryKey, type: :class do
9
9
  let(:region) {}
10
10
  let(:tag) {}
11
11
 
12
- #.new
12
+ # .new
13
13
  describe '.new' do
14
14
  context 'when passing valid arguments' do
15
15
  let(:language) { :EN }
16
16
  let(:region) { :us }
17
- let(:tag) { :TAGGED}
17
+ let(:tag) { :TAGGED }
18
18
 
19
19
  it 'instantiates the object' do
20
- expect { subject }.to_not raise_error
20
+ expect { subject }.not_to raise_error
21
21
  end
22
22
 
23
23
  it 'normalizes language and converts it to lowercase' do
@@ -51,18 +51,18 @@ RSpec.describe LittleWeasel::DictionaryKey, type: :class do
51
51
  end
52
52
  end
53
53
 
54
- #.key
54
+ # .key
55
55
  describe '.key' do
56
56
  let(:language) { :xx }
57
57
  let(:region) { :yy }
58
58
  let(:tag) { :zz }
59
59
 
60
60
  it 'returns the locale' do
61
- expect(described_class.key language: language, region: region, tag: tag).to eq 'xx-YY-zz'
61
+ expect(described_class.key(language: language, region: region, tag: tag)).to eq 'xx-YY-zz'
62
62
  end
63
63
  end
64
64
 
65
- #key
65
+ # key
66
66
  describe '#key' do
67
67
  context 'with no tag' do
68
68
  context 'with language' do
@@ -77,7 +77,7 @@ RSpec.describe LittleWeasel::DictionaryKey, type: :class do
77
77
  let(:language) { :EN }
78
78
  let(:region) { :us }
79
79
 
80
- it 'returns the key in the form of a locale String that includes language and region (e.g. "en-US")' do
80
+ it 'returns the key in the form of a locale String that includes language and region (e.g. "en-US")' do
81
81
  expect(subject.key).to eq 'en-US'
82
82
  end
83
83
  end
@@ -98,14 +98,14 @@ RSpec.describe LittleWeasel::DictionaryKey, type: :class do
98
98
  let(:language) { :EN }
99
99
  let(:region) { :us }
100
100
 
101
- it 'returns the key in the form of a locale String that includes language, region and the appended tag (e.g. "en-US-tag")' do
101
+ it 'returns the key in the form of a locale String that includes language, region and the appended tag (e.g. "en-US-tag")' do
102
102
  expect(subject.key).to eq 'en-US-tagged'
103
103
  end
104
104
  end
105
105
  end
106
106
  end
107
107
 
108
- #to_s
108
+ # to_s
109
109
  describe '#to_s' do
110
110
  let(:language) { :en }
111
111
  let(:region) { :us }
@@ -3,12 +3,12 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  RSpec.describe LittleWeasel::DictionaryManager do
6
- include_context 'dictionary keys'
7
-
8
6
  subject { create(:dictionary_manager) }
9
7
 
10
- let(:dictionary_cache_service) { create(:dictionary_cache_service, dictionary_key: dictionary_key, dictionary_cache: dictionary_cache)}
11
- let(:dictionary_metadata_service) { create(:dictionary_metadata_service, dictionary_key: dictionary_key, dictionary_cache: dictionary_cache, dictionary_metadata: dictionary_metadata)}
8
+ include_context 'dictionary keys'
9
+
10
+ let(:dictionary_cache_service) { create(:dictionary_cache_service, dictionary_key: dictionary_key, dictionary_cache: dictionary_cache) }
11
+ let(:dictionary_metadata_service) { create(:dictionary_metadata_service, dictionary_key: dictionary_key, dictionary_cache: dictionary_cache, dictionary_metadata: dictionary_metadata) }
12
12
  let(:dictionary_key) { create(:dictionary_key, language: language, region: region, tag: tag) }
13
13
  let(:dictionary_cache) { subject.dictionary_cache }
14
14
  let(:dictionary_metadata) { subject.dictionary_metadata }
@@ -22,28 +22,28 @@ RSpec.describe LittleWeasel::DictionaryManager do
22
22
  dictionary_cache_service.dictionary_object.dictionary_metadata_object.observers.keys.first
23
23
  end
24
24
 
25
- before(:each) do
25
+ before do
26
26
  subject.init
27
27
  end
28
28
 
29
- #.new
29
+ # .new
30
30
  describe '.new' do
31
31
  it 'does not raise an error' do
32
32
  expect { subject }.not_to raise_error
33
33
  end
34
34
  end
35
35
 
36
- #dictionary_exist?
36
+ # dictionary_exist?
37
37
  describe '#dictionary_exist?' do
38
38
  let!(:expected_dictionary_object) do
39
39
  subject.create_dictionary_from_memory(dictionary_key: dictionary_key,
40
- dictionary_words: %w(My dictionary words) )
40
+ dictionary_words: %w[My dictionary words])
41
41
  end
42
42
 
43
43
  context 'when the dictionary exists' do
44
44
  it 'returns true' do
45
- expect(subject.dictionary_exist? dictionary_key: dictionary_key)
46
- .to eq true
45
+ expect(subject.dictionary_exist?(dictionary_key: dictionary_key))
46
+ .to be true
47
47
  end
48
48
  end
49
49
 
@@ -51,22 +51,22 @@ RSpec.describe LittleWeasel::DictionaryManager do
51
51
  let(:en_gb_dictionary_key) { dictionary_key_for(language: :en, region: :gb) }
52
52
 
53
53
  it 'returns false' do
54
- expect(subject.dictionary_exist? dictionary_key: en_gb_dictionary_key)
55
- .to eq false
54
+ expect(subject.dictionary_exist?(dictionary_key: en_gb_dictionary_key))
55
+ .to be false
56
56
  end
57
57
  end
58
58
  end
59
59
 
60
- #dictionary_for
60
+ # dictionary_for
61
61
  describe '#dictionary_for' do
62
62
  let!(:expected_dictionary_object) do
63
63
  subject.create_dictionary_from_memory(dictionary_key: dictionary_key,
64
- dictionary_words: %w(My dictionary words) )
64
+ dictionary_words: %w[My dictionary words])
65
65
  end
66
66
 
67
67
  context 'when the dictionary exists' do
68
68
  it 'returns the dictionary object' do
69
- expect(subject.dictionary_for dictionary_key: dictionary_key)
69
+ expect(subject.dictionary_for(dictionary_key: dictionary_key))
70
70
  .to be expected_dictionary_object
71
71
  end
72
72
  end
@@ -81,11 +81,11 @@ RSpec.describe LittleWeasel::DictionaryManager do
81
81
  end
82
82
  end
83
83
 
84
- #create_dictionary_from_file
84
+ # create_dictionary_from_file
85
85
  describe '#create_dictionary_from_file' do
86
86
  context 'when the dictionary DOES NOT exist' do
87
87
  it 'creates a dictionary and returns a dictionary object' do
88
- expect(subject.create_dictionary_from_file(dictionary_key: dictionary_key, file: file)).to be_kind_of LittleWeasel::Dictionary
88
+ expect(subject.create_dictionary_from_file(dictionary_key: dictionary_key, file: file)).to be_a LittleWeasel::Dictionary
89
89
  end
90
90
  end
91
91
 
@@ -101,15 +101,15 @@ RSpec.describe LittleWeasel::DictionaryManager do
101
101
  end
102
102
  end
103
103
 
104
- #create_dictionary_from_memory
104
+ # create_dictionary_from_memory
105
105
  describe '#create_dictionary_from_memory' do
106
106
  let(:dictionary_words) { dictionary_words_for(dictionary_file_path: file) }
107
107
 
108
108
  context 'when the dictionary reference does not exist and the dictionary is not cached' do
109
109
  it 'adds a dictionary reference caches the dictionary and returns a dictionary object' do
110
- expect(subject.create_dictionary_from_memory(dictionary_key: dictionary_key, dictionary_words: dictionary_words)).to be_kind_of LittleWeasel::Dictionary
111
- expect(dictionary_cache_service.dictionary_reference?).to eq true
112
- expect(dictionary_cache_service.dictionary_object?).to eq true
110
+ expect(subject.create_dictionary_from_memory(dictionary_key: dictionary_key, dictionary_words: dictionary_words)).to be_a LittleWeasel::Dictionary
111
+ expect(dictionary_cache_service.dictionary_reference?).to be true
112
+ expect(dictionary_cache_service.dictionary_object?).to be true
113
113
  end
114
114
  end
115
115
 
@@ -125,7 +125,7 @@ RSpec.describe LittleWeasel::DictionaryManager do
125
125
  end
126
126
  end
127
127
 
128
- #kill
128
+ # kill
129
129
  describe '#kill_dictionary' do
130
130
  context 'dictionaries created from files' do
131
131
  before do
@@ -135,9 +135,9 @@ RSpec.describe LittleWeasel::DictionaryManager do
135
135
  it 'removes the dictionary, file source reference and metadata from the dictionary cache' do
136
136
  metadata_key # Capture this before we unload the dictionary
137
137
  subject.kill_dictionary(dictionary_key: dictionary_key)
138
- expect(dictionary_cache_service.dictionary_exist?).to eq false
139
- expect(dictionary_cache_service.dictionary_reference?).to eq false
140
- expect(dictionary_metadata_service.dictionary_metadata?(metadata_key: metadata_key)).to eq false
138
+ expect(dictionary_cache_service.dictionary_exist?).to be false
139
+ expect(dictionary_cache_service.dictionary_reference?).to be false
140
+ expect(dictionary_metadata_service.dictionary_metadata?(metadata_key: metadata_key)).to be false
141
141
  end
142
142
 
143
143
  it 'returns the dictionary manager instance' do
@@ -147,15 +147,15 @@ RSpec.describe LittleWeasel::DictionaryManager do
147
147
 
148
148
  context 'dictionaries created from memory' do
149
149
  before do
150
- subject.create_dictionary_from_memory(dictionary_key: dictionary_key, dictionary_words: %w(Abel Cain Deborah Elijah))
150
+ subject.create_dictionary_from_memory(dictionary_key: dictionary_key, dictionary_words: %w[Abel Cain Deborah Elijah])
151
151
  end
152
152
 
153
153
  it 'removes the dictionary, memory source reference and metadata from the dictionary cache' do
154
154
  metadata_key # Capture this before we unload the dictionary
155
155
  subject.kill_dictionary(dictionary_key: dictionary_key)
156
- expect(dictionary_cache_service.dictionary_exist?).to eq false
157
- expect(dictionary_cache_service.dictionary_reference?).to eq false
158
- expect(dictionary_metadata_service.dictionary_metadata?(metadata_key: metadata_key)).to eq false
156
+ expect(dictionary_cache_service.dictionary_exist?).to be false
157
+ expect(dictionary_cache_service.dictionary_reference?).to be false
158
+ expect(dictionary_metadata_service.dictionary_metadata?(metadata_key: metadata_key)).to be false
159
159
  end
160
160
 
161
161
  it 'returns the dictionary manager instance' do
@@ -3,16 +3,17 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  RSpec.describe LittleWeasel::Dictionary do
6
+ subject { create(:dictionary, dictionary_key: dictionary_key, dictionary_cache: dictionary_cache, dictionary_words: dictionary_words, word_filters: word_filters) }
7
+
6
8
  include_context 'dictionary keys'
7
9
  include_context 'mock word filters'
8
10
 
9
11
  DictionaryResultsHelpers = Support::GeneralHelpers::DictionaryResultsHelpers
10
12
 
11
-
12
- subject { create(:dictionary, dictionary_key: dictionary_key, dictionary_cache: dictionary_cache, dictionary_words: dictionary_words, word_filters: word_filters) }
13
-
14
- before(:each) { LittleWeasel.configure { |config| config.reset } }
15
- before { dictionary_cache_service }
13
+ before do
14
+ LittleWeasel.configure(&:reset)
15
+ dictionary_cache_service
16
+ end
16
17
 
17
18
  let(:dictionary_cache_service) { create(:dictionary_cache_service, dictionary_key: dictionary_key, dictionary_cache: dictionary_cache, dictionary_file_source: dictionary_key.key) }
18
19
  let(:dictionary_key) { dictionary_key_for(language: :en, region: :us, tag: :big) }
@@ -29,11 +30,11 @@ RSpec.describe LittleWeasel::Dictionary do
29
30
  [word_results.present?, word_results&.word_valid]
30
31
  end
31
32
 
32
- #.new
33
+ # .new
33
34
  describe '.new' do
34
35
  context 'with a valid dictionary words Array' do
35
36
  it 'instantiates without error' do
36
- expect { subject }.to_not raise_error
37
+ expect { subject }.not_to raise_error
37
38
  end
38
39
  end
39
40
 
@@ -82,23 +83,23 @@ RSpec.describe LittleWeasel::Dictionary do
82
83
  end
83
84
  end
84
85
 
85
- #.to_hash
86
+ # .to_hash
86
87
  describe '.to_hash' do
87
88
  let(:expected_hash) do
88
89
  {
89
- 'this' => true,
90
- 'is' => true,
91
- 'a' => true,
92
- 'test' => true
90
+ 'this' => true, # rubocop:disable Style/StringHashKeys
91
+ 'is' => true, # rubocop:disable Style/StringHashKeys
92
+ 'a' => true, # rubocop:disable Style/StringHashKeys
93
+ 'test' => true # rubocop:disable Style/StringHashKeys
93
94
  }
94
95
  end
95
96
 
96
97
  it 'returns a Hash of dictionary words' do
97
- expect(described_class.to_hash(dictionary_words: %w(this is a test))).to eq expected_hash
98
+ expect(described_class.to_hash(dictionary_words: %w[this is a test])).to eq expected_hash
98
99
  end
99
100
  end
100
101
 
101
- #detached?
102
+ # detached?
102
103
  describe '#detached?' do
103
104
  before do
104
105
  subject
@@ -109,8 +110,8 @@ RSpec.describe LittleWeasel::Dictionary do
109
110
  context 'when the dictionary object is in the dictionary cache' do
110
111
  it 'returns false' do
111
112
  dictionary_cache_service
112
- expect(dictionary_cache_service.dictionary_object?).to eq true
113
- expect(subject.detached?).to eq false
113
+ expect(dictionary_cache_service.dictionary_object?).to be true
114
+ expect(subject.detached?).to be false
114
115
  end
115
116
  end
116
117
 
@@ -122,20 +123,20 @@ RSpec.describe LittleWeasel::Dictionary do
122
123
  end
123
124
 
124
125
  it 'returns true' do
125
- expect(dictionary_cache_service.dictionary_object?).to eq false
126
- expect(subject.detached?).to eq true
126
+ expect(dictionary_cache_service.dictionary_object?).to be false
127
+ expect(subject.detached?).to be true
127
128
  end
128
129
  end
129
130
  end
130
131
 
131
- #key
132
+ # key
132
133
  describe '#key' do
133
134
  it 'returns the expected key' do
134
135
  expect(subject.key).to eq dictionary_key.key
135
136
  end
136
137
  end
137
138
 
138
- #count
139
+ # count
139
140
  describe '#count' do
140
141
  before do
141
142
  subject.word_results('badword')
@@ -146,7 +147,7 @@ RSpec.describe LittleWeasel::Dictionary do
146
147
  end
147
148
  end
148
149
 
149
- #count_all_words
150
+ # count_all_words
150
151
  describe '#count_all_words' do
151
152
  before do
152
153
  subject.word_results('badword')
@@ -157,7 +158,7 @@ RSpec.describe LittleWeasel::Dictionary do
157
158
  end
158
159
  end
159
160
 
160
- #count_invalid_words
161
+ # count_invalid_words
161
162
  describe '#count_invalid_words' do
162
163
  before do
163
164
  subject.word_results('badword')
@@ -168,7 +169,7 @@ RSpec.describe LittleWeasel::Dictionary do
168
169
  end
169
170
  end
170
171
 
171
- #word_results
172
+ # word_results
172
173
  describe '#word_results' do
173
174
  context 'when argument word is INVALID' do
174
175
  context 'when not a String' do
@@ -183,19 +184,19 @@ RSpec.describe LittleWeasel::Dictionary do
183
184
  context 'when searching for words in the dictionary' do
184
185
  context 'when the word is found' do
185
186
  it 'returns true' do
186
- expect(subject.word_results('dog').success?).to eq true
187
+ expect(subject.word_results('dog').success?).to be true
187
188
  end
188
189
  end
189
190
 
190
191
  context 'when the word is not found' do
191
192
  it 'returns false' do
192
- expect(subject.word_results('badword').success?).to eq false
193
+ expect(subject.word_results('badword').success?).to be false
193
194
  end
194
195
  end
195
196
  end
196
197
  end
197
198
 
198
- #block_results
199
+ # block_results
199
200
  describe '#block_results' do
200
201
  context 'when nil is passed' do
201
202
  it 'raises an error' do
@@ -250,7 +251,7 @@ RSpec.describe LittleWeasel::Dictionary do
250
251
  context 'when a word is not found' do
251
252
  context 'when the max_invalid_words_bytesize threashold has not been exceeded' do
252
253
  it 'adds the word to the cache' do
253
- expect { subject.word_results('badword') }.to change { subject.count_all_words }.by(1)
254
+ expect { subject.word_results('badword') }.to change(subject, :count_all_words).by(1)
254
255
  end
255
256
  end
256
257
 
@@ -265,7 +266,7 @@ RSpec.describe LittleWeasel::Dictionary do
265
266
  subject.word_results('IWillBeCached02')
266
267
  subject.word_results('IWontBeCached01')
267
268
  subject.word_results('IWontBeCached02')
268
- end.to change { subject.count_all_words }.by(2)
269
+ end.to change(subject, :count_all_words).by(2)
269
270
  end
270
271
  end
271
272
  end
@@ -282,7 +283,7 @@ RSpec.describe LittleWeasel::Dictionary do
282
283
  subject.word_results('IWillBeCached02')
283
284
  subject.word_results('IWontBeCached01')
284
285
  subject.word_results('IWontBeCached02')
285
- end.to change { subject.count_all_words }.by(0)
286
+ end.not_to(change(subject, :count_all_words))
286
287
  end
287
288
  end
288
289
  end
@@ -5,48 +5,48 @@ require 'spec_helper'
5
5
  RSpec.describe LittleWeasel::Filters::EnUs::CurrencyFilter do
6
6
  subject { described_class.new }
7
7
 
8
- #filter_match?
8
+ # filter_match?
9
9
  describe 'filter_match?' do
10
+ let(:word) { 1 }
11
+
10
12
  context 'when word is currency' do
11
13
  it 'returns true' do
12
- expect(subject.filter_match?('-$1.00')).to eq true
13
- expect(subject.filter_match?('-$1')).to eq true
14
- expect(subject.filter_match?('$0')).to eq true
15
- expect(subject.filter_match?('$1')).to eq true
16
- expect(subject.filter_match?('$100')).to eq true
17
- expect(subject.filter_match?('$100.10')).to eq true
18
- expect(subject.filter_match?('$123456')).to eq true
19
- expect(subject.filter_match?('+$110.09')).to eq true
20
- expect(subject.filter_match?('-$1,000.09')).to eq true
21
- expect(subject.filter_match?('$1000000.00')).to eq true
22
- expect(subject.filter_match?('$1100000.10')).to eq true
23
- expect(subject.filter_match?('$120000.01')).to eq true
24
- expect(subject.filter_match?('$1,000,000.01')).to eq true
14
+ expect(subject.filter_match?('-$1.00')).to be true
15
+ expect(subject.filter_match?('-$1')).to be true
16
+ expect(subject.filter_match?('$0')).to be true
17
+ expect(subject.filter_match?('$1')).to be true
18
+ expect(subject.filter_match?('$100')).to be true
19
+ expect(subject.filter_match?('$100.10')).to be true
20
+ expect(subject.filter_match?('$123456')).to be true
21
+ expect(subject.filter_match?('+$110.09')).to be true
22
+ expect(subject.filter_match?('-$1,000.09')).to be true
23
+ expect(subject.filter_match?('$1000000.00')).to be true
24
+ expect(subject.filter_match?('$1100000.10')).to be true
25
+ expect(subject.filter_match?('$120000.01')).to be true
26
+ expect(subject.filter_match?('$1,000,000.01')).to be true
25
27
  end
26
28
  end
27
29
 
28
30
  context 'when word has decimals, but not 2 decimal places' do
29
31
  it 'returns false' do
30
- expect(subject.filter_match?('-$1.1')).to eq false
31
- expect(subject.filter_match?('$0.1')).to eq false
32
- expect(subject.filter_match?('$100.9')).to eq false
33
- expect(subject.filter_match?('+$100.2')).to eq false
34
- expect(subject.filter_match?('$1000000.0')).to eq false
35
- expect(subject.filter_match?('$1000000.1')).to eq false
36
- expect(subject.filter_match?('$1000000.5')).to eq false
32
+ expect(subject.filter_match?('-$1.1')).to be false
33
+ expect(subject.filter_match?('$0.1')).to be false
34
+ expect(subject.filter_match?('$100.9')).to be false
35
+ expect(subject.filter_match?('+$100.2')).to be false
36
+ expect(subject.filter_match?('$1000000.0')).to be false
37
+ expect(subject.filter_match?('$1000000.1')).to be false
38
+ expect(subject.filter_match?('$1000000.5')).to be false
37
39
  end
38
40
  end
39
41
 
40
42
  context 'when word is NOT currency' do
41
43
  it 'returns false' do
42
- expect(subject.filter_match? 'a').to eq false
43
- expect(subject.filter_match? :a).to eq false
44
- expect(subject.filter_match? Object.new).to eq false
44
+ expect(subject.filter_match?('a')).to be false
45
+ expect(subject.filter_match?(:a)).to be false
46
+ expect(subject.filter_match?(Object.new)).to be false
45
47
  end
46
48
  end
47
49
 
48
- let(:word) { 1 }
49
-
50
50
  context 'when #filter_match? returns true' do
51
51
  before { allow(subject.class).to receive(:filter_match?).and_return(true) }
52
52
 
@@ -5,34 +5,34 @@ require 'spec_helper'
5
5
  RSpec.describe LittleWeasel::Filters::EnUs::NumericFilter do
6
6
  subject { described_class.new }
7
7
 
8
- #filter_match?
8
+ # filter_match?
9
9
  describe 'filter_match?' do
10
+ let(:word) { 1 }
11
+
10
12
  context 'when word is a number' do
11
13
  it 'returns true' do
12
- expect(subject.filter_match?('-1.00')).to eq true
13
- expect(subject.filter_match?('-1')).to eq true
14
- expect(subject.filter_match?('0')).to eq true
15
- expect(subject.filter_match?('1')).to eq true
16
- expect(subject.filter_match?('100')).to eq true
17
- expect(subject.filter_match?('100.10')).to eq true
18
- expect(subject.filter_match?(1234_56)).to eq true
19
- expect(subject.filter_match?('+100.0')).to eq true
20
- expect(subject.filter_match?(1_000_000.00)).to eq true
21
- expect(subject.filter_match?(1_000_000.10)).to eq true
22
- expect(subject.filter_match?(1_000_000.01)).to eq true
14
+ expect(subject.filter_match?('-1.00')).to be true
15
+ expect(subject.filter_match?('-1')).to be true
16
+ expect(subject.filter_match?('0')).to be true
17
+ expect(subject.filter_match?('1')).to be true
18
+ expect(subject.filter_match?('100')).to be true
19
+ expect(subject.filter_match?('100.10')).to be true
20
+ expect(subject.filter_match?(123_456)).to be true
21
+ expect(subject.filter_match?('+100.0')).to be true
22
+ expect(subject.filter_match?(1_000_000.00)).to be true
23
+ expect(subject.filter_match?(1_000_000.10)).to be true
24
+ expect(subject.filter_match?(1_000_000.01)).to be true
23
25
  end
24
26
  end
25
27
 
26
28
  context 'when word is NOT a number' do
27
29
  it 'returns false' do
28
- expect(subject.filter_match? 'a').to eq false
29
- expect(subject.filter_match? :a).to eq false
30
- expect(subject.filter_match? Object.new).to eq false
30
+ expect(subject.filter_match?('a')).to be false
31
+ expect(subject.filter_match?(:a)).to be false
32
+ expect(subject.filter_match?(Object.new)).to be false
31
33
  end
32
34
  end
33
35
 
34
- let(:word) { 1 }
35
-
36
36
  context 'when #filter_match? returns true' do
37
37
  before { allow(subject.class).to receive(:filter_match?).and_return(true) }
38
38
 
@@ -5,26 +5,26 @@ require 'spec_helper'
5
5
  RSpec.describe LittleWeasel::Filters::EnUs::SingleCharacterWordFilter do
6
6
  subject { described_class.new }
7
7
 
8
- #filter_match?
8
+ # filter_match?
9
9
  describe '#filter_match?' do
10
+ let(:word) { 'x' }
11
+
10
12
  context 'when word single character word' do
11
13
  it 'returns true' do
12
- %w(a A I).each do |number|
13
- expect(subject.filter_match? number).to eq true
14
+ %w[a A I].each do |number|
15
+ expect(subject.filter_match?(number)).to be true
14
16
  end
15
17
  end
16
18
  end
17
19
 
18
20
  context 'when word is NOT a single character word' do
19
21
  it 'returns false' do
20
- expect(subject.filter_match? 'X').to eq false
21
- expect(subject.filter_match? :a).to eq false
22
- expect(subject.filter_match? Object.new).to eq false
22
+ expect(subject.filter_match?('X')).to be false
23
+ expect(subject.filter_match?(:a)).to be false
24
+ expect(subject.filter_match?(Object.new)).to be false
23
25
  end
24
26
  end
25
27
 
26
- let(:word) { 'x' }
27
-
28
28
  context 'when #filter_match? returns true' do
29
29
  before { allow(subject.class).to receive(:filter_match?).and_return(true) }
30
30