word_count_analyzer 0.0.14 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -6
- data/lib/word_count_analyzer/analyzer.rb +6 -5
- data/lib/word_count_analyzer/contraction.rb +1 -1
- data/lib/word_count_analyzer/counter.rb +15 -16
- data/lib/word_count_analyzer/date.rb +79 -106
- data/lib/word_count_analyzer/ellipsis.rb +10 -15
- data/lib/word_count_analyzer/hyperlink.rb +14 -25
- data/lib/word_count_analyzer/hyphenated_word.rb +1 -1
- data/lib/word_count_analyzer/number.rb +1 -1
- data/lib/word_count_analyzer/slash.rb +8 -7
- data/lib/word_count_analyzer/version.rb +1 -1
- data/spec/word_count_analyzer/counter_spec.rb +123 -160
- data/spec/word_count_analyzer/date_spec.rb +85 -85
- data/spec/word_count_analyzer/ellipsis_spec.rb +33 -33
- data/spec/word_count_analyzer/hyperlink_spec.rb +23 -23
- data/spec/word_count_analyzer/performance_spec.rb +46 -0
- data/word_count_analyzer.gemspec +1 -0
- metadata +18 -2
@@ -1,263 +1,263 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
RSpec.describe WordCountAnalyzer::Date do
|
4
|
-
context '#includes_date?' do
|
4
|
+
context '#includes_date?(string)' do
|
5
5
|
it 'returns true if the string includes a date #001' do
|
6
6
|
string = 'Today is Monday, April 4th, 2011, aka 04/04/2011.'
|
7
|
-
ws = WordCountAnalyzer::Date.new
|
8
|
-
expect(ws.includes_date?).to eq(true)
|
7
|
+
ws = WordCountAnalyzer::Date.new
|
8
|
+
expect(ws.includes_date?(string)).to eq(true)
|
9
9
|
end
|
10
10
|
|
11
11
|
it 'returns true if the string includes a date #002' do
|
12
12
|
string = 'Today is Monday April 4th 2011.'
|
13
|
-
ws = WordCountAnalyzer::Date.new
|
14
|
-
expect(ws.includes_date?).to eq(true)
|
13
|
+
ws = WordCountAnalyzer::Date.new
|
14
|
+
expect(ws.includes_date?(string)).to eq(true)
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'returns true if the string includes a date #003' do
|
18
18
|
string = 'Today is April 4th, 2011.'
|
19
|
-
ws = WordCountAnalyzer::Date.new
|
20
|
-
expect(ws.includes_date?).to eq(true)
|
19
|
+
ws = WordCountAnalyzer::Date.new
|
20
|
+
expect(ws.includes_date?(string)).to eq(true)
|
21
21
|
end
|
22
22
|
|
23
23
|
it 'returns true if the string includes a date #004' do
|
24
24
|
string = 'Today is Mon., Apr. 4, 2011.'
|
25
|
-
ws = WordCountAnalyzer::Date.new
|
26
|
-
expect(ws.includes_date?).to eq(true)
|
25
|
+
ws = WordCountAnalyzer::Date.new
|
26
|
+
expect(ws.includes_date?(string)).to eq(true)
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'returns true if the string includes a date #005' do
|
30
30
|
string = 'Today is 04/04/2011.'
|
31
|
-
ws = WordCountAnalyzer::Date.new
|
32
|
-
expect(ws.includes_date?).to eq(true)
|
31
|
+
ws = WordCountAnalyzer::Date.new
|
32
|
+
expect(ws.includes_date?(string)).to eq(true)
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'returns true if the string includes a date #006' do
|
36
36
|
string = 'Today is 04.04.2011.'
|
37
|
-
ws = WordCountAnalyzer::Date.new
|
38
|
-
expect(ws.includes_date?).to eq(true)
|
37
|
+
ws = WordCountAnalyzer::Date.new
|
38
|
+
expect(ws.includes_date?(string)).to eq(true)
|
39
39
|
end
|
40
40
|
|
41
41
|
it 'returns true if the string includes a date #007' do
|
42
42
|
string = 'Today is 2011.04.04.'
|
43
|
-
ws = WordCountAnalyzer::Date.new
|
44
|
-
expect(ws.includes_date?).to eq(true)
|
43
|
+
ws = WordCountAnalyzer::Date.new
|
44
|
+
expect(ws.includes_date?(string)).to eq(true)
|
45
45
|
end
|
46
46
|
|
47
47
|
it 'returns true if the string includes a date #008' do
|
48
48
|
string = 'Today is 2011/04/04.'
|
49
|
-
ws = WordCountAnalyzer::Date.new
|
50
|
-
expect(ws.includes_date?).to eq(true)
|
49
|
+
ws = WordCountAnalyzer::Date.new
|
50
|
+
expect(ws.includes_date?(string)).to eq(true)
|
51
51
|
end
|
52
52
|
|
53
53
|
it 'returns true if the string includes a date #009' do
|
54
54
|
string = 'Today is 2011-04-04.'
|
55
|
-
ws = WordCountAnalyzer::Date.new
|
56
|
-
expect(ws.includes_date?).to eq(true)
|
55
|
+
ws = WordCountAnalyzer::Date.new
|
56
|
+
expect(ws.includes_date?(string)).to eq(true)
|
57
57
|
end
|
58
58
|
|
59
59
|
it 'returns true if the string includes a date #010' do
|
60
60
|
string = 'Today is 04-04-2011.'
|
61
|
-
ws = WordCountAnalyzer::Date.new
|
62
|
-
expect(ws.includes_date?).to eq(true)
|
61
|
+
ws = WordCountAnalyzer::Date.new
|
62
|
+
expect(ws.includes_date?(string)).to eq(true)
|
63
63
|
end
|
64
64
|
|
65
65
|
it 'returns true if the string includes a date #011' do
|
66
66
|
string = 'Today is 2003 November 9.'
|
67
|
-
ws = WordCountAnalyzer::Date.new
|
68
|
-
expect(ws.includes_date?).to eq(true)
|
67
|
+
ws = WordCountAnalyzer::Date.new
|
68
|
+
expect(ws.includes_date?(string)).to eq(true)
|
69
69
|
end
|
70
70
|
|
71
71
|
it 'returns true if the string includes a date #012' do
|
72
72
|
string = 'Today is 2003Nov9.'
|
73
|
-
ws = WordCountAnalyzer::Date.new
|
74
|
-
expect(ws.includes_date?).to eq(true)
|
73
|
+
ws = WordCountAnalyzer::Date.new
|
74
|
+
expect(ws.includes_date?(string)).to eq(true)
|
75
75
|
end
|
76
76
|
|
77
77
|
it 'returns true if the string includes a date #013' do
|
78
78
|
string = 'Today is 2003Nov09.'
|
79
|
-
ws = WordCountAnalyzer::Date.new
|
80
|
-
expect(ws.includes_date?).to eq(true)
|
79
|
+
ws = WordCountAnalyzer::Date.new
|
80
|
+
expect(ws.includes_date?(string)).to eq(true)
|
81
81
|
end
|
82
82
|
|
83
83
|
it 'returns true if the string includes a date #014' do
|
84
84
|
string = 'Today is 2003-Nov-9.'
|
85
|
-
ws = WordCountAnalyzer::Date.new
|
86
|
-
expect(ws.includes_date?).to eq(true)
|
85
|
+
ws = WordCountAnalyzer::Date.new
|
86
|
+
expect(ws.includes_date?(string)).to eq(true)
|
87
87
|
end
|
88
88
|
|
89
89
|
it 'returns true if the string includes a date #015' do
|
90
90
|
string = 'Today is 2003-Nov-09.'
|
91
|
-
ws = WordCountAnalyzer::Date.new
|
92
|
-
expect(ws.includes_date?).to eq(true)
|
91
|
+
ws = WordCountAnalyzer::Date.new
|
92
|
+
expect(ws.includes_date?(string)).to eq(true)
|
93
93
|
end
|
94
94
|
|
95
95
|
it 'returns true if the string includes a date #016' do
|
96
96
|
string = 'Today is 2003-Nov-9, Sunday.'
|
97
|
-
ws = WordCountAnalyzer::Date.new
|
98
|
-
expect(ws.includes_date?).to eq(true)
|
97
|
+
ws = WordCountAnalyzer::Date.new
|
98
|
+
expect(ws.includes_date?(string)).to eq(true)
|
99
99
|
end
|
100
100
|
|
101
101
|
it 'returns true if the string includes a date #017' do
|
102
102
|
string = 'Today is 2003. november 9.'
|
103
|
-
ws = WordCountAnalyzer::Date.new
|
104
|
-
expect(ws.includes_date?).to eq(true)
|
103
|
+
ws = WordCountAnalyzer::Date.new
|
104
|
+
expect(ws.includes_date?(string)).to eq(true)
|
105
105
|
end
|
106
106
|
|
107
107
|
it 'returns true if the string includes a date #018' do
|
108
108
|
string = 'Today is 2003.11.9.'
|
109
|
-
ws = WordCountAnalyzer::Date.new
|
110
|
-
expect(ws.includes_date?).to eq(true)
|
109
|
+
ws = WordCountAnalyzer::Date.new
|
110
|
+
expect(ws.includes_date?(string)).to eq(true)
|
111
111
|
end
|
112
112
|
|
113
113
|
it 'returns true if the string includes a date #019' do
|
114
114
|
string = 'Today is Monday, Apr. 4, 2011.'
|
115
|
-
ws = WordCountAnalyzer::Date.new
|
116
|
-
expect(ws.includes_date?).to eq(true)
|
115
|
+
ws = WordCountAnalyzer::Date.new
|
116
|
+
expect(ws.includes_date?(string)).to eq(true)
|
117
117
|
end
|
118
118
|
|
119
119
|
it 'returns true if the string includes a date #020' do
|
120
120
|
string = 'Today is 2003/11/09.'
|
121
|
-
ws = WordCountAnalyzer::Date.new
|
122
|
-
expect(ws.includes_date?).to eq(true)
|
121
|
+
ws = WordCountAnalyzer::Date.new
|
122
|
+
expect(ws.includes_date?(string)).to eq(true)
|
123
123
|
end
|
124
124
|
|
125
125
|
it 'returns true if the string includes a date #021' do
|
126
126
|
string = 'Today is 20030109.'
|
127
|
-
ws = WordCountAnalyzer::Date.new
|
128
|
-
expect(ws.includes_date?).to eq(true)
|
127
|
+
ws = WordCountAnalyzer::Date.new
|
128
|
+
expect(ws.includes_date?(string)).to eq(true)
|
129
129
|
end
|
130
130
|
|
131
131
|
it 'returns true if the string includes a date #022' do
|
132
132
|
string = 'Today is 01092003.'
|
133
|
-
ws = WordCountAnalyzer::Date.new
|
134
|
-
expect(ws.includes_date?).to eq(true)
|
133
|
+
ws = WordCountAnalyzer::Date.new
|
134
|
+
expect(ws.includes_date?(string)).to eq(true)
|
135
135
|
end
|
136
136
|
|
137
137
|
it 'returns true if the string includes a date #023' do
|
138
138
|
string = 'Today is Sunday, November 9, 2014.'
|
139
|
-
ws = WordCountAnalyzer::Date.new
|
140
|
-
expect(ws.includes_date?).to eq(true)
|
139
|
+
ws = WordCountAnalyzer::Date.new
|
140
|
+
expect(ws.includes_date?(string)).to eq(true)
|
141
141
|
end
|
142
142
|
|
143
143
|
it 'returns true if the string includes a date #024' do
|
144
144
|
string = 'Today is November 9, 2014.'
|
145
|
-
ws = WordCountAnalyzer::Date.new
|
146
|
-
expect(ws.includes_date?).to eq(true)
|
145
|
+
ws = WordCountAnalyzer::Date.new
|
146
|
+
expect(ws.includes_date?(string)).to eq(true)
|
147
147
|
end
|
148
148
|
|
149
149
|
it 'returns true if the string includes a date #025' do
|
150
150
|
string = 'Today is Nov. 9, 2014.'
|
151
|
-
ws = WordCountAnalyzer::Date.new
|
152
|
-
expect(ws.includes_date?).to eq(true)
|
151
|
+
ws = WordCountAnalyzer::Date.new
|
152
|
+
expect(ws.includes_date?(string)).to eq(true)
|
153
153
|
end
|
154
154
|
|
155
155
|
it 'returns true if the string includes a date #026' do
|
156
156
|
string = 'Today is july 1st.'
|
157
|
-
ws = WordCountAnalyzer::Date.new
|
158
|
-
expect(ws.includes_date?).to eq(true)
|
157
|
+
ws = WordCountAnalyzer::Date.new
|
158
|
+
expect(ws.includes_date?(string)).to eq(true)
|
159
159
|
end
|
160
160
|
|
161
161
|
it 'returns true if the string includes a date #027' do
|
162
162
|
string = 'Today is jul. 1st.'
|
163
|
-
ws = WordCountAnalyzer::Date.new
|
164
|
-
expect(ws.includes_date?).to eq(true)
|
163
|
+
ws = WordCountAnalyzer::Date.new
|
164
|
+
expect(ws.includes_date?(string)).to eq(true)
|
165
165
|
end
|
166
166
|
|
167
167
|
it 'returns true if the string includes a date #028' do
|
168
168
|
string = 'Today is 8 November 2014.'
|
169
|
-
ws = WordCountAnalyzer::Date.new
|
170
|
-
expect(ws.includes_date?).to eq(true)
|
169
|
+
ws = WordCountAnalyzer::Date.new
|
170
|
+
expect(ws.includes_date?(string)).to eq(true)
|
171
171
|
end
|
172
172
|
|
173
173
|
it 'returns true if the string includes a date #029' do
|
174
174
|
string = 'Today is 8. November 2014.'
|
175
|
-
ws = WordCountAnalyzer::Date.new
|
176
|
-
expect(ws.includes_date?).to eq(true)
|
175
|
+
ws = WordCountAnalyzer::Date.new
|
176
|
+
expect(ws.includes_date?(string)).to eq(true)
|
177
177
|
end
|
178
178
|
|
179
179
|
it 'returns true if the string includes a date #030' do
|
180
180
|
string = 'Today is 08-Nov-2014.'
|
181
|
-
ws = WordCountAnalyzer::Date.new
|
182
|
-
expect(ws.includes_date?).to eq(true)
|
181
|
+
ws = WordCountAnalyzer::Date.new
|
182
|
+
expect(ws.includes_date?(string)).to eq(true)
|
183
183
|
end
|
184
184
|
|
185
185
|
it 'returns true if the string includes a date #031' do
|
186
186
|
string = 'Today is 08Nov14.'
|
187
|
-
ws = WordCountAnalyzer::Date.new
|
188
|
-
expect(ws.includes_date?).to eq(true)
|
187
|
+
ws = WordCountAnalyzer::Date.new
|
188
|
+
expect(ws.includes_date?(string)).to eq(true)
|
189
189
|
end
|
190
190
|
|
191
191
|
it 'returns true if the string includes a date #032' do
|
192
192
|
string = 'Today is 8th November 2014.'
|
193
|
-
ws = WordCountAnalyzer::Date.new
|
194
|
-
expect(ws.includes_date?).to eq(true)
|
193
|
+
ws = WordCountAnalyzer::Date.new
|
194
|
+
expect(ws.includes_date?(string)).to eq(true)
|
195
195
|
end
|
196
196
|
|
197
197
|
it 'returns true if the string includes a date #033' do
|
198
198
|
string = 'Today is the 8th of November 2014.'
|
199
|
-
ws = WordCountAnalyzer::Date.new
|
200
|
-
expect(ws.includes_date?).to eq(true)
|
199
|
+
ws = WordCountAnalyzer::Date.new
|
200
|
+
expect(ws.includes_date?(string)).to eq(true)
|
201
201
|
end
|
202
202
|
|
203
203
|
it 'returns true if the string includes a date #034' do
|
204
204
|
string = 'Today is 08/Nov/2014.'
|
205
|
-
ws = WordCountAnalyzer::Date.new
|
206
|
-
expect(ws.includes_date?).to eq(true)
|
205
|
+
ws = WordCountAnalyzer::Date.new
|
206
|
+
expect(ws.includes_date?(string)).to eq(true)
|
207
207
|
end
|
208
208
|
|
209
209
|
it 'returns true if the string includes a date #035' do
|
210
210
|
string = 'Today is Sunday, 8 November 2014.'
|
211
|
-
ws = WordCountAnalyzer::Date.new
|
212
|
-
expect(ws.includes_date?).to eq(true)
|
211
|
+
ws = WordCountAnalyzer::Date.new
|
212
|
+
expect(ws.includes_date?(string)).to eq(true)
|
213
213
|
end
|
214
214
|
|
215
215
|
it 'returns true if the string includes a date #036' do
|
216
216
|
string = 'Today is 8 November 2014.'
|
217
|
-
ws = WordCountAnalyzer::Date.new
|
218
|
-
expect(ws.includes_date?).to eq(true)
|
217
|
+
ws = WordCountAnalyzer::Date.new
|
218
|
+
expect(ws.includes_date?(string)).to eq(true)
|
219
219
|
end
|
220
220
|
|
221
221
|
it 'returns false if the string does not include a date #037' do
|
222
222
|
string = 'Hello world. There is no date here - $50,000. The sun is hot.'
|
223
|
-
ws = WordCountAnalyzer::Date.new
|
224
|
-
expect(ws.includes_date?).to eq(false)
|
223
|
+
ws = WordCountAnalyzer::Date.new
|
224
|
+
expect(ws.includes_date?(string)).to eq(false)
|
225
225
|
end
|
226
226
|
end
|
227
227
|
|
228
228
|
context '#occurences' do
|
229
229
|
it 'counts the date occurences in a string #001' do
|
230
230
|
string = 'Today is Sunday, 8 November 2014.'
|
231
|
-
ws = WordCountAnalyzer::Date.new
|
232
|
-
expect(ws.occurences).to eq(1)
|
231
|
+
ws = WordCountAnalyzer::Date.new
|
232
|
+
expect(ws.occurences(string)).to eq(1)
|
233
233
|
end
|
234
234
|
|
235
235
|
it 'counts the date occurences in a string #002' do
|
236
236
|
string = 'Today is Sunday, 8 November 2014. Yesterday was 07/Nov/2014.'
|
237
|
-
ws = WordCountAnalyzer::Date.new
|
238
|
-
expect(ws.occurences).to eq(2)
|
237
|
+
ws = WordCountAnalyzer::Date.new
|
238
|
+
expect(ws.occurences(string)).to eq(2)
|
239
239
|
end
|
240
240
|
end
|
241
241
|
|
242
242
|
context '#replace' do
|
243
243
|
it 'replaces the date occurences in a string #001' do
|
244
244
|
string = 'Today is Tues. March 3rd, 2011.'
|
245
|
-
ws = WordCountAnalyzer::Date.new
|
246
|
-
expect(ws.replace).to eq('Today is wsdateword ')
|
245
|
+
ws = WordCountAnalyzer::Date.new
|
246
|
+
expect(ws.replace(string)).to eq('Today is wsdateword ')
|
247
247
|
end
|
248
248
|
|
249
249
|
it 'replaces the date occurences in a string #002' do
|
250
250
|
string = 'The scavenger hunt ends on Dec. 31st, 2011.'
|
251
|
-
ws = WordCountAnalyzer::Date.new
|
252
|
-
expect(ws.replace).to eq('The scavenger hunt ends on wsdateword ')
|
251
|
+
ws = WordCountAnalyzer::Date.new
|
252
|
+
expect(ws.replace(string)).to eq('The scavenger hunt ends on wsdateword ')
|
253
253
|
end
|
254
254
|
end
|
255
255
|
|
256
256
|
context '#replace_number_only_date' do
|
257
257
|
it 'replaces only the number date occurences in a string' do
|
258
258
|
string = 'Today is Tues. March 3rd, 2011. 4/28/2013'
|
259
|
-
ws = WordCountAnalyzer::Date.new
|
260
|
-
expect(ws.replace_number_only_date).to eq("Today is Tues. March 3rd, 2011. wsdateword ")
|
259
|
+
ws = WordCountAnalyzer::Date.new
|
260
|
+
expect(ws.replace_number_only_date(string)).to eq("Today is Tues. March 3rd, 2011. wsdateword ")
|
261
261
|
end
|
262
262
|
end
|
263
263
|
end
|
@@ -1,105 +1,105 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
RSpec.describe WordCountAnalyzer::Ellipsis do
|
4
|
-
context '#includes_ellipsis?' do
|
4
|
+
context '#includes_ellipsis?(string)' do
|
5
5
|
it 'returns true if the string includes an ellipsis #001' do
|
6
6
|
string = 'Using an ellipsis … causes different counts.'
|
7
|
-
ws = WordCountAnalyzer::Ellipsis.new
|
8
|
-
expect(ws.includes_ellipsis?).to eq(true)
|
7
|
+
ws = WordCountAnalyzer::Ellipsis.new
|
8
|
+
expect(ws.includes_ellipsis?(string)).to eq(true)
|
9
9
|
end
|
10
10
|
|
11
11
|
it 'returns true if the string includes an ellipsis #002' do
|
12
12
|
string = 'Using an ellipsis causes different counts…depending on the style that you use.'
|
13
|
-
ws = WordCountAnalyzer::Ellipsis.new
|
14
|
-
expect(ws.includes_ellipsis?).to eq(true)
|
13
|
+
ws = WordCountAnalyzer::Ellipsis.new
|
14
|
+
expect(ws.includes_ellipsis?(string)).to eq(true)
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'returns true if the string includes an ellipsis #003' do
|
18
18
|
string = 'Using an ellipsis causes different counts depending on the style . . . that you use.'
|
19
|
-
ws = WordCountAnalyzer::Ellipsis.new
|
20
|
-
expect(ws.includes_ellipsis?).to eq(true)
|
19
|
+
ws = WordCountAnalyzer::Ellipsis.new
|
20
|
+
expect(ws.includes_ellipsis?(string)).to eq(true)
|
21
21
|
end
|
22
22
|
|
23
23
|
it 'returns true if the string includes an ellipsis #004' do
|
24
24
|
string = 'Using an ellipsis causes different counts depending on the style . . . . that you use.'
|
25
|
-
ws = WordCountAnalyzer::Ellipsis.new
|
26
|
-
expect(ws.includes_ellipsis?).to eq(true)
|
25
|
+
ws = WordCountAnalyzer::Ellipsis.new
|
26
|
+
expect(ws.includes_ellipsis?(string)).to eq(true)
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'returns true if the string includes an ellipsis #005' do
|
30
30
|
string = 'Using an ellipsis causes different counts depending on the style.... that you use.'
|
31
|
-
ws = WordCountAnalyzer::Ellipsis.new
|
32
|
-
expect(ws.includes_ellipsis?).to eq(true)
|
31
|
+
ws = WordCountAnalyzer::Ellipsis.new
|
32
|
+
expect(ws.includes_ellipsis?(string)).to eq(true)
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'returns true if the string includes an ellipsis #006' do
|
36
36
|
string = 'hello world ...'
|
37
|
-
ws = WordCountAnalyzer::Ellipsis.new
|
38
|
-
expect(ws.includes_ellipsis?).to eq(true)
|
37
|
+
ws = WordCountAnalyzer::Ellipsis.new
|
38
|
+
expect(ws.includes_ellipsis?(string)).to eq(true)
|
39
39
|
end
|
40
40
|
|
41
41
|
it 'returns true if the string includes an ellipsis #007' do
|
42
42
|
string = '...'
|
43
|
-
ws = WordCountAnalyzer::Ellipsis.new
|
44
|
-
expect(ws.includes_ellipsis?).to eq(true)
|
43
|
+
ws = WordCountAnalyzer::Ellipsis.new
|
44
|
+
expect(ws.includes_ellipsis?(string)).to eq(true)
|
45
45
|
end
|
46
46
|
|
47
47
|
it 'returns true if the string includes an ellipsis #008' do
|
48
48
|
string = '....'
|
49
|
-
ws = WordCountAnalyzer::Ellipsis.new
|
50
|
-
expect(ws.includes_ellipsis?).to eq(true)
|
49
|
+
ws = WordCountAnalyzer::Ellipsis.new
|
50
|
+
expect(ws.includes_ellipsis?(string)).to eq(true)
|
51
51
|
end
|
52
52
|
|
53
53
|
it 'returns true if the string includes an ellipsis #009' do
|
54
54
|
string = ' . . . '
|
55
|
-
ws = WordCountAnalyzer::Ellipsis.new
|
56
|
-
expect(ws.includes_ellipsis?).to eq(true)
|
55
|
+
ws = WordCountAnalyzer::Ellipsis.new
|
56
|
+
expect(ws.includes_ellipsis?(string)).to eq(true)
|
57
57
|
end
|
58
58
|
|
59
59
|
it 'returns true if the string includes an ellipsis #010' do
|
60
60
|
string = ' . . . . '
|
61
|
-
ws = WordCountAnalyzer::Ellipsis.new
|
62
|
-
expect(ws.includes_ellipsis?).to eq(true)
|
61
|
+
ws = WordCountAnalyzer::Ellipsis.new
|
62
|
+
expect(ws.includes_ellipsis?(string)).to eq(true)
|
63
63
|
end
|
64
64
|
|
65
65
|
it 'returns true if the string includes an ellipsis #011' do
|
66
66
|
string = '…'
|
67
|
-
ws = WordCountAnalyzer::Ellipsis.new
|
68
|
-
expect(ws.includes_ellipsis?).to eq(true)
|
67
|
+
ws = WordCountAnalyzer::Ellipsis.new
|
68
|
+
expect(ws.includes_ellipsis?(string)).to eq(true)
|
69
69
|
end
|
70
70
|
|
71
71
|
it "returns false if the string doesn't include an ellipsis #012" do
|
72
72
|
string = 'Hello world.'
|
73
|
-
ws = WordCountAnalyzer::Ellipsis.new
|
74
|
-
expect(ws.includes_ellipsis?).to eq(false)
|
73
|
+
ws = WordCountAnalyzer::Ellipsis.new
|
74
|
+
expect(ws.includes_ellipsis?(string)).to eq(false)
|
75
75
|
end
|
76
76
|
|
77
77
|
it "returns false if the string includes a dotted_line #0013" do
|
78
78
|
string = '.....'
|
79
|
-
ws = WordCountAnalyzer::Ellipsis.new
|
80
|
-
expect(ws.includes_ellipsis?).to eq(false)
|
79
|
+
ws = WordCountAnalyzer::Ellipsis.new
|
80
|
+
expect(ws.includes_ellipsis?(string)).to eq(false)
|
81
81
|
end
|
82
82
|
|
83
83
|
it "returns false if the string includes a dotted_line #0014" do
|
84
84
|
string = "Here is one …………………………………………………………………… and another ......"
|
85
|
-
ws = WordCountAnalyzer::Ellipsis.new
|
86
|
-
expect(ws.includes_ellipsis?).to eq(false)
|
85
|
+
ws = WordCountAnalyzer::Ellipsis.new
|
86
|
+
expect(ws.includes_ellipsis?(string)).to eq(false)
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
90
|
context '#replace' do
|
91
91
|
it 'returns a string with the ellipsis replaced #001' do
|
92
92
|
string = 'Using an ellipsis … causes different counts…depending on the style . . . that you use. I never meant that.... She left the store. The practice was not abandoned. . . .'
|
93
|
-
ws = WordCountAnalyzer::Ellipsis.new
|
94
|
-
expect(ws.replace).to eq("Using an ellipsis wseword causes different counts wseword depending on the style wseword that you use. I never meant that wseword She left the store. The practice was not abandoned wseword ")
|
93
|
+
ws = WordCountAnalyzer::Ellipsis.new
|
94
|
+
expect(ws.replace(string)).to eq("Using an ellipsis wseword causes different counts wseword depending on the style wseword that you use. I never meant that wseword She left the store. The practice was not abandoned wseword ")
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
98
98
|
context '#occurences' do
|
99
99
|
it 'returns a string with the ellipsis replaced #001' do
|
100
100
|
string = 'Using an ellipsis … causes different counts…depending on the style . . . that you use. I never meant that.... She left the store. The practice was not abandoned. . . .'
|
101
|
-
ws = WordCountAnalyzer::Ellipsis.new
|
102
|
-
expect(ws.occurences).to eq(5)
|
101
|
+
ws = WordCountAnalyzer::Ellipsis.new
|
102
|
+
expect(ws.occurences(string)).to eq(5)
|
103
103
|
end
|
104
104
|
end
|
105
105
|
end
|