fat_core 1.0.3 → 1.2.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.
@@ -1,68 +1,68 @@
1
1
  require File.dirname(File.absolute_path(__FILE__)) + '/../spec_helper.rb'
2
2
 
3
3
  describe Numeric do
4
- it "should implement signum function" do
4
+ it 'should implement signum function' do
5
5
  # Integers
6
6
  expect(33.signum).to eq 1
7
- expect(-33.signum).to eq -1
7
+ expect(-33.signum).to eq(-1)
8
8
  expect(0.signum).to eq 0
9
9
 
10
10
  # Floats
11
11
  expect(33.45.signum).to eq 1
12
- expect(-33.45.signum).to eq -1
12
+ expect(-33.45.signum).to eq(-1)
13
13
  expect(0.0.signum).to eq 0
14
14
  end
15
15
 
16
- it "should provide a tex_quote method for erb docs" do
16
+ it 'should provide a tex_quote method for erb docs' do
17
17
  expect(195.45.tex_quote).to eq '195.45'
18
18
  end
19
19
 
20
- it "should provide a human-readable inspect for BigDecimal" do
20
+ it 'should provide a human-readable inspect for BigDecimal' do
21
21
  expect(BigDecimal('33.45').inspect).to eq '33.45'
22
22
  end
23
23
 
24
- it "should be able to report if its a whole number" do
24
+ it 'should be able to report if its a whole number' do
25
25
  expect(236.whole?).to be true
26
26
  expect(236.5555.whole?).to be false
27
27
  end
28
28
 
29
- it "should properly round up" do
29
+ it 'should properly round up' do
30
30
  expect(236.5555.commas(2)).to eq '236.56'
31
31
  expect(-236.5555.commas(2)).to eq '-236.56'
32
32
  end
33
33
 
34
- it "should properly round down" do
34
+ it 'should properly round down' do
35
35
  expect(236.5512.commas(2)).to eq '236.55'
36
36
  expect(-236.5512.commas(2)).to eq '-236.55'
37
37
  end
38
38
 
39
- it "should place commas properly" do
40
- expect(123456789.0123.commas(2)).to eq '123,456,789.01'
41
- expect(-123456789.0123.commas(2)).to eq '-123,456,789.01'
39
+ it 'should place commas properly' do
40
+ expect(123_456_789.0123.commas(2)).to eq '123,456,789.01'
41
+ expect(-123_456_789.0123.commas(2)).to eq '-123,456,789.01'
42
42
 
43
43
  # if places is nil, use 4 places for numbers with a fractional
44
44
  # part and 0 places for numbers without
45
- expect(-123456789.0123456.commas).to eq '-123,456,789.0123'
46
- expect(-123456789.0.commas).to eq '-123,456,789'
47
- expect(-123456789.00.commas).to eq '-123,456,789'
45
+ expect(-123_456_789.0123456.commas).to eq '-123,456,789.0123'
46
+ expect(-123_456_789.0.commas).to eq '-123,456,789'
47
+ expect(-123_456_789.00.commas).to eq '-123,456,789'
48
48
  end
49
49
 
50
- it "should be able to convert a non-fractional float to an int" do
50
+ it 'should be able to convert a non-fractional float to an int' do
51
51
  expect(195.45.int_if_whole).to eq 195.45
52
52
  expect(195.0.int_if_whole).to eq 195
53
- expect(195.0.int_if_whole.class).to eq Fixnum
53
+ expect(195.0.int_if_whole.is_a?(Integer)).to be true
54
54
  end
55
55
 
56
- it "should place commas properly with no fraction" do
57
- expect(123456789.commas).to eq '123,456,789'
58
- expect(-123456789.commas).to eq '-123,456,789'
56
+ it 'should place commas properly with no fraction' do
57
+ expect(123_456_789.commas).to eq '123,456,789'
58
+ expect(-123_456_789.commas).to eq '-123,456,789'
59
59
  end
60
60
 
61
- it "should not place commas in a number with exponent" do
62
- expect(123456.789e100.commas).to eq '1.23456789e+105'
61
+ it 'should not place commas in a number with exponent' do
62
+ expect(123_456.789e100.commas).to eq '1.23456789e+105'
63
63
  end
64
64
 
65
- it "should be able to convert itself into an H:M:S string" do
65
+ it 'should be able to convert itself into an H:M:S string' do
66
66
  expect(60.secs_to_hms).to eq('00:01:00')
67
67
  expect(120.secs_to_hms).to eq('00:02:00')
68
68
  expect(6584.secs_to_hms).to eq('01:49:44')
@@ -35,7 +35,7 @@ describe Period do
35
35
 
36
36
  it 'should raise a ArgumentError if initialized otherwise' do
37
37
  expect {
38
- Period.new(2013-01-01, 2013-12-31)
38
+ Period.new(2013 - 1 - 1, 2013 - 12 - 31)
39
39
  }.to raise_error ArgumentError
40
40
  end
41
41
  end
@@ -289,14 +289,13 @@ describe Period do
289
289
  end
290
290
 
291
291
  it 'should be able to convert itself to fractional months' do
292
- expect(Period.new('2013-01-01', '2013-01-01').months).to eq(1/30.436875)
293
- expect(Period.new('2013-01-01', '2013-12-31').months(30)).
294
- to eq(365 / 30.0)
292
+ expect(Period.new('2013-01-01', '2013-01-01').months).to eq(1 / 30.436875)
293
+ expect(Period.new('2013-01-01', '2013-12-31').months(30)).to eq(365 / 30.0)
295
294
  expect(Period.new('2013-01-01', '2013-06-30').months.round(0)).to eq(6.0)
296
295
  end
297
296
 
298
297
  it 'should be able to convert itself to fractional years' do
299
- expect(Period.new('2013-01-01', '2013-01-01').years).to eq(1/365.2425)
298
+ expect(Period.new('2013-01-01', '2013-01-01').years).to eq(1 / 365.2425)
300
299
  expect(Period.new('2013-01-01', '2013-12-31').years(365)).to eq(1.0)
301
300
  expect(Period.new('2013-01-01', '2013-06-30').years.round(1)).to eq(0.5)
302
301
  end
@@ -416,7 +415,7 @@ describe Period do
416
415
 
417
416
  it 'should be able to chunk into biweeks' do
418
417
  chunks = Period.new('2009-12-29', '2013-01-10').chunks(size: :biweek)
419
- expect(chunks.size).to be >=(26*3)
418
+ expect(chunks.size).to be >= (26 * 3)
420
419
  expect(chunks[0].first.iso).to eq('2010-01-04')
421
420
  expect(chunks[0].last.iso).to eq('2010-01-17')
422
421
  expect(chunks[1].first.iso).to eq('2010-01-18')
@@ -454,9 +453,9 @@ describe Period do
454
453
  end
455
454
 
456
455
  it 'should raise error for invalid chunk name' do
457
- expect do
456
+ expect {
458
457
  Period.new('2012-12-28', '2012-12-31').chunks(size: :wally)
459
- end.to raise_error(ArgumentError)
458
+ }.to raise_error(ArgumentError)
460
459
  end
461
460
 
462
461
  it 'should not include a partial final chunk by default' do
@@ -466,7 +465,7 @@ describe Period do
466
465
 
467
466
  it 'should include a partial final chunk if partial_last' do
468
467
  chunks = Period.new('2012-01-01', '2012-03-30')
469
- .chunks(size: :month, partial_last: true)
468
+ .chunks(size: :month, partial_last: true)
470
469
  expect(chunks.size).to eq(3)
471
470
  expect(chunks.last.first).to eq(Date.parse('2012-03-01'))
472
471
  expect(chunks.last.last).to eq(Date.parse('2012-03-30'))
@@ -474,7 +473,7 @@ describe Period do
474
473
 
475
474
  it 'should include a final chunk beyond end_date if round_up' do
476
475
  chunks = Period.new('2012-01-01', '2012-03-30')
477
- .chunks(size: :month, round_up_last: true)
476
+ .chunks(size: :month, round_up_last: true)
478
477
  expect(chunks.size).to eq(3)
479
478
  expect(chunks.last.first).to eq(Date.parse('2012-03-01'))
480
479
  expect(chunks.last.last).to eq(Date.parse('2012-03-31'))
@@ -489,7 +488,7 @@ describe Period do
489
488
 
490
489
  it 'should include a partial initial chunk by if partial_first' do
491
490
  chunks = Period.new('2012-01-13', '2012-03-31')
492
- .chunks(size: :month, partial_first: true)
491
+ .chunks(size: :month, partial_first: true)
493
492
  expect(chunks.size).to eq(3)
494
493
  expect(chunks[0].first).to eq(Date.parse('2012-01-13'))
495
494
  expect(chunks[0].last).to eq(Date.parse('2012-01-31'))
@@ -497,7 +496,7 @@ describe Period do
497
496
 
498
497
  it 'should include a final chunk beyond end_date if round_up' do
499
498
  chunks = Period.new('2012-01-01', '2012-03-30')
500
- .chunks(size: :month, round_up_last: true)
499
+ .chunks(size: :month, round_up_last: true)
501
500
  expect(chunks.size).to eq(3)
502
501
  expect(chunks.last.first).to eq(Date.parse('2012-03-01'))
503
502
  expect(chunks.last.last).to eq(Date.parse('2012-03-31'))
@@ -1,8 +1,8 @@
1
1
  require File.dirname(File.absolute_path(__FILE__)) + '/../spec_helper.rb'
2
2
 
3
3
  describe Range do
4
- describe "set operations" do
5
- it "should know if it is a subset of another range" do
4
+ describe 'set operations' do
5
+ it 'should know if it is a subset of another range' do
6
6
  expect((4..8)).to be_subset_of((2..9))
7
7
  expect((4..8)).to be_subset_of((4..8))
8
8
  expect((4..8)).not_to be_subset_of((2..7))
@@ -10,7 +10,7 @@ describe Range do
10
10
  expect((4..8)).not_to be_subset_of((11..20))
11
11
  end
12
12
 
13
- it "should know if it is a proper subset of another range" do
13
+ it 'should know if it is a proper subset of another range' do
14
14
  expect((4..8)).to be_proper_subset_of((2..9))
15
15
  expect((4..8)).not_to be_proper_subset_of((4..8))
16
16
  expect((4..8)).not_to be_proper_subset_of((2..7))
@@ -18,7 +18,7 @@ describe Range do
18
18
  expect((4..8)).not_to be_proper_subset_of((11..20))
19
19
  end
20
20
 
21
- it "should know if it is a superset of another range" do
21
+ it 'should know if it is a superset of another range' do
22
22
  expect((4..8)).to be_superset_of((5..7))
23
23
  expect((4..8)).to be_superset_of((6..8))
24
24
  expect((4..8)).to be_superset_of((4..7))
@@ -32,7 +32,7 @@ describe Range do
32
32
  expect((4..8)).not_to be_superset_of((9..20))
33
33
  end
34
34
 
35
- it "should know if it is a proper superset of another range" do
35
+ it 'should know if it is a proper superset of another range' do
36
36
  expect((4..8)).to be_proper_superset_of((5..7))
37
37
  expect((4..8)).not_to be_proper_superset_of((6..8))
38
38
  expect((4..8)).not_to be_proper_superset_of((4..7))
@@ -46,17 +46,17 @@ describe Range do
46
46
  expect((4..8)).not_to be_proper_superset_of((9..20))
47
47
  end
48
48
 
49
- it "should know its intersection with another range" do
49
+ it 'should know its intersection with another range' do
50
50
  expect(((0..10) & (5..20))).to eq((5..10))
51
51
  expect(((0..10) & (5..20))).to eq((5..20) & (0..10))
52
52
  expect(((0..10) & (10..20))).to eq((10..10))
53
- end
53
+ end
54
54
 
55
- it "intersection should return nil if there is no overlap" do
55
+ it 'intersection should return nil if there is no overlap' do
56
56
  expect(((0..10) & (15..20))).to be_nil
57
57
  end
58
58
 
59
- it "should know its union with another range" do
59
+ it 'should know its union with another range' do
60
60
  expect(((0..10) + (5..20))).to eq((0..20))
61
61
  expect(((0..10) + (5..20))).to eq((5..20) + (0..10))
62
62
  expect(((0..10) + (10..20))).to eq((0..20))
@@ -65,12 +65,12 @@ describe Range do
65
65
  expect(((0..5) + (6..20))).to eq((0..20))
66
66
  end
67
67
 
68
- it "union should return nil if there is no overlap" do
68
+ it 'union should return nil if there is no overlap' do
69
69
  expect(((0..10) & (15..20))).to be_nil
70
70
  expect(((15..20) & (0..10))).to be_nil
71
71
  end
72
72
 
73
- it "should know the difference with another range" do
73
+ it 'should know the difference with another range' do
74
74
  # Other is same as self
75
75
  expect(((4..10) - (4..10)).size).to eq(0)
76
76
  expect(((4..10) - (4..10))).to be_empty
@@ -101,13 +101,13 @@ describe Range do
101
101
  end
102
102
  end
103
103
 
104
- describe "joining" do
105
- it "should be able to join contiguous ranges" do
106
- expect((0..3).join(4..8)).to eq (0..8)
107
- expect((4..8).join(0..3)).to eq (0..8)
104
+ describe 'joining' do
105
+ it 'should be able to join contiguous ranges' do
106
+ expect((0..3).join(4..8)).to eq((0..8))
107
+ expect((4..8).join(0..3)).to eq((0..8))
108
108
  end
109
109
 
110
- it "should return nil on join of non-contiguous ranges" do
110
+ it 'should return nil on join of non-contiguous ranges' do
111
111
  expect((0..3).join(5..8)).to be_nil
112
112
  expect((0...3).join(4..8)).to be_nil
113
113
 
@@ -115,22 +115,22 @@ describe Range do
115
115
  expect((4..8).join(0...3)).to be_nil
116
116
  end
117
117
 
118
- it "should work with Floats, allowing single-point overlap" do
119
- expect((0.0..3.0).join(3.0..8.2)).to eq (0.0..8.2)
120
- expect((3.0..8.2).join(0.0..3.0)).to eq (0.0..8.2)
118
+ it 'should work with Floats, allowing single-point overlap' do
119
+ expect((0.0..3.0).join(3.0..8.2)).to eq((0.0..8.2))
120
+ expect((3.0..8.2).join(0.0..3.0)).to eq((0.0..8.2))
121
121
  end
122
122
  end
123
123
 
124
- describe "spanning" do
125
- it "should be able to determine whether it is spanned by a set of ranges" do
124
+ describe 'spanning' do
125
+ it 'should be able to determine whether it is spanned by a set of ranges' do
126
126
  expect((0..10)).to be_spanned_by([(0..3), (4..6), (7..10)])
127
127
  end
128
128
 
129
- it "should be determine that overlapping ranges do not span" do
129
+ it 'should be determine that overlapping ranges do not span' do
130
130
  expect((0..10)).to_not be_spanned_by([(0..3), (3..6), (7..10)])
131
131
  end
132
132
 
133
- it "should allow spanning ranges to be any Enumerable" do
133
+ it 'should allow spanning ranges to be any Enumerable' do
134
134
  require 'set'
135
135
  set = [(0..3), (4..6), (7..10)].to_set
136
136
  expect((0..10)).to be_spanned_by(set)
@@ -138,15 +138,15 @@ describe Range do
138
138
  expect((0..10)).to_not be_spanned_by(set)
139
139
  end
140
140
 
141
- it "should allow the spanning set to be wider than itself" do
141
+ it 'should allow the spanning set to be wider than itself' do
142
142
  set = [(0..3), (4..6), (7..10)].to_set
143
143
  expect((2..8)).to be_spanned_by(set)
144
144
  expect((5..6)).to be_spanned_by(set)
145
145
  end
146
146
  end
147
147
 
148
- describe "overlapping a single range" do
149
- it "should know if another range overlaps it" do
148
+ describe 'overlapping a single range' do
149
+ it 'should know if another range overlaps it' do
150
150
  expect((0..10).overlaps?(-3..5)).to be_truthy
151
151
  expect((0..10).overlaps?(3..5)).to be_truthy
152
152
  expect((0..10).overlaps?(8..15)).to be_truthy
@@ -163,114 +163,114 @@ describe Range do
163
163
  expect((-11..-1).overlaps?(0..10)).to be_falsy
164
164
  end
165
165
 
166
- it "should be able to determine whether a set contains covered overlaps" do
166
+ it 'should be able to determine whether a set contains covered overlaps' do
167
167
  expect((0..10)).to have_overlaps_within([(0..3), (2..6), (7..10)])
168
168
  end
169
169
 
170
- it "should not care about overlaps outside range" do
170
+ it 'should not care about overlaps outside range' do
171
171
  expect((11..15)).to_not have_overlaps_within([(0..3), (2..6), (7..10)])
172
172
  end
173
173
 
174
- it "should not count contiguous ranges as overlapping" do
174
+ it 'should not count contiguous ranges as overlapping' do
175
175
  expect((0..10)).to_not have_overlaps_within([(0..3), (4..6), (7..10)])
176
176
  end
177
177
 
178
- it "should not count non-contiguous ranges as overlapping" do
178
+ it 'should not count non-contiguous ranges as overlapping' do
179
179
  expect((0..10)).to_not have_overlaps_within([(0..3), (4..6), (8..10)])
180
180
  end
181
181
 
182
- it "should not count an empty set as overlapping" do
182
+ it 'should not count an empty set as overlapping' do
183
183
  expect((0..10)).to_not have_overlaps_within([])
184
184
  end
185
185
  end
186
186
 
187
- describe "coverage gaps" do
188
- it "should return an empty array if ranges completely cover" do
187
+ describe 'coverage gaps' do
188
+ it 'should return an empty array if ranges completely cover' do
189
189
  expect((0..10).gaps([(-1..3), (4..8), (9..11)])).to be_empty
190
190
  end
191
191
 
192
- it "should return array for itself if ranges are empty" do
192
+ it 'should return array for itself if ranges are empty' do
193
193
  expect((0..10).gaps([])).to eq([(0..10)])
194
194
  end
195
195
 
196
- it "should return an array of gaps" do
196
+ it 'should return an array of gaps' do
197
197
  gaps = (0..10).gaps([(0..3), (5..6), (9..10)])
198
198
  expect(gaps[0]).to eq((4..4))
199
199
  expect(gaps[1]).to eq((7..8))
200
200
  end
201
201
 
202
- it "should allow ranges to extend before and after self" do
202
+ it 'should allow ranges to extend before and after self' do
203
203
  gaps = (0..10).gaps([(-3..3), (4..6), (7..13)])
204
204
  expect(gaps).to be_empty
205
205
  end
206
206
 
207
- it "should not include parts before or after in gaps" do
207
+ it 'should not include parts before or after in gaps' do
208
208
  gaps = (0..10).gaps([(-10..-8), (-3..3), (7..13), (30..40)])
209
209
  expect(gaps.size).to eq(1)
210
210
  expect(gaps[0]).to eq((4..6))
211
211
  end
212
212
 
213
- it "should return gaps at beginning and end" do
213
+ it 'should return gaps at beginning and end' do
214
214
  gaps = (0..10).gaps([(2..3), (4..6), (7..8)])
215
215
  expect(gaps[0]).to eq((0..1))
216
216
  expect(gaps[1]).to eq((9..10))
217
217
  end
218
218
 
219
- it "should work even if ranges are out of order" do
219
+ it 'should work even if ranges are out of order' do
220
220
  gaps = (0..10).gaps([(2..3), (30..40), (7..8), (-10..-8), (4..6)])
221
221
  expect(gaps[0]).to eq((0..1))
222
222
  expect(gaps[1]).to eq((9..10))
223
223
  end
224
224
 
225
- it "should notice single point coverage" do
225
+ it 'should notice single point coverage' do
226
226
  gaps = (0..10).gaps([(4..4), (5..5), (6..6)])
227
227
  expect(gaps[0]).to eq((0..3))
228
228
  expect(gaps[1]).to eq((7..10))
229
229
  end
230
230
 
231
- it "should work for a single-point range" do
231
+ it 'should work for a single-point range' do
232
232
  gaps = (3..3).gaps([(0..2), (4..4), (5..5), (6..6)])
233
233
  expect(gaps[0]).to eq((3..3))
234
234
  end
235
235
 
236
- it "should work even if ranges overlap" do
236
+ it 'should work even if ranges overlap' do
237
237
  gaps = (0..10).gaps([(-2..3), (2..8), (4..10)])
238
238
  expect(gaps).to be_empty
239
239
  end
240
240
  end
241
241
 
242
- describe "coverage overlaps" do
243
- it "should return an empty array if ranges are empty" do
242
+ describe 'coverage overlaps' do
243
+ it 'should return an empty array if ranges are empty' do
244
244
  expect((0..10).overlaps([])).to be_empty
245
245
  end
246
246
 
247
- it "should return an empty array if ranges is same as self" do
247
+ it 'should return an empty array if ranges is same as self' do
248
248
  expect((0..10).overlaps([(0..10)])).to be_empty
249
249
  end
250
250
 
251
- it "should return an empty array if ranges is wider than self" do
251
+ it 'should return an empty array if ranges is wider than self' do
252
252
  expect((0..10).overlaps([(-5..15)])).to be_empty
253
253
  end
254
254
 
255
- it "should return an empty array if ranges is narrower than self" do
255
+ it 'should return an empty array if ranges is narrower than self' do
256
256
  expect((0..10).overlaps([(5..8)])).to be_empty
257
257
  end
258
258
 
259
- it "should return an array of overlaps" do
259
+ it 'should return an array of overlaps' do
260
260
  overlaps = (0..10).overlaps([(0..3), (2..6), (4..10)])
261
261
  expect(overlaps.size).to eq(2)
262
262
  expect(overlaps[0]).to eq((2..3))
263
263
  expect(overlaps[1]).to eq((4..6))
264
264
  end
265
265
 
266
- it "should not return any overlaps before self" do
266
+ it 'should not return any overlaps before self' do
267
267
  overlaps = (0..10).overlaps([(-5..-3), (-4..-1), (0..3), (2..6), (4..10)])
268
268
  expect(overlaps.size).to eq(2)
269
269
  expect(overlaps[0]).to eq((2..3))
270
270
  expect(overlaps[1]).to eq((4..6))
271
271
  end
272
272
 
273
- it "should not return any overlaps after self" do
273
+ it 'should not return any overlaps after self' do
274
274
  overlaps = (0..10).overlaps([(0..3), (2..6), (4..15), (11..20)])
275
275
  expect(overlaps.size).to eq(2)
276
276
  expect(overlaps[0]).to eq((2..3))
@@ -55,33 +55,33 @@ the people, for the people, shall not perish from the earth."
55
55
  ##123456789012345678901234567890123456789012345678901234567890123456789|
56
56
  end
57
57
 
58
- describe "class methods" do
59
- it "should be able to generate a random string" do
58
+ describe 'class methods' do
59
+ it 'should be able to generate a random string' do
60
60
  ss = String.random(100)
61
61
  expect(ss.class).to eq String
62
62
  expect(ss.size).to eq 100
63
63
  end
64
64
  end
65
65
 
66
- describe "instance methods" do
67
- it "should be able to clean up white space in a string" do
66
+ describe 'instance methods' do
67
+ it 'should be able to clean up white space in a string' do
68
68
  expect(' string here '.clean).to eq 'string here'
69
69
  end
70
70
 
71
- it "should be able to convert a digital date to iso form" do
72
- expect("20140521".digdate2iso).to eq '2014-05-21'
71
+ it 'should be able to convert a digital date to iso form' do
72
+ expect('20140521'.digdate2iso).to eq '2014-05-21'
73
73
  end
74
74
 
75
- it "should wrap a short string" do
76
- expect("hello, world".wrap).to eq "hello, world"
75
+ it 'should wrap a short string' do
76
+ expect('hello, world'.wrap).to eq 'hello, world'
77
77
  end
78
78
 
79
- it "should wrap a long string" do
80
- @getty.wrap.split("\n").each {|l| expect(l.length).to be <= 70}
79
+ it 'should wrap a long string' do
80
+ @getty.wrap.split("\n").each { |l| expect(l.length).to be <= 70 }
81
81
  end
82
82
 
83
- it "should wrap a long string with a hangining indent" do
84
- @getty.wrap(70, 10).split("\n").each {|l| expect(l.length).to be <= 70}
83
+ it 'should wrap a long string with a hangining indent' do
84
+ @getty.wrap(70, 10).split("\n").each { |l| expect(l.length).to be <= 70 }
85
85
  @getty.wrap(70, 10).split("\n")[1..-1].each do |l|
86
86
  expect(l).to match(/^ /)
87
87
  end
@@ -93,14 +93,14 @@ the people, for the people, shall not perish from the earth."
93
93
  expect(@getty.wrap(70, 10).split("\n")[23]).to match(/^#{twenty_fourth_line}/)
94
94
  end
95
95
 
96
- it "should be able to quote special TeX characters" do
97
- expect("$10,000".tex_quote).to eq("\\$10,000")
98
- expect("would~~have".tex_quote).to eq("would\\textasciitilde{}\\textasciitilde{}have")
99
- expect("<hello>".tex_quote).to eq("\\textless{}hello\\textgreater{}")
100
- expect("{hello}".tex_quote).to eq("\\{hello\\}")
96
+ it 'should be able to quote special TeX characters' do
97
+ expect('$10,000'.tex_quote).to eq('\\$10,000')
98
+ expect('would~~have'.tex_quote).to eq('would\\textasciitilde{}\\textasciitilde{}have')
99
+ expect('<hello>'.tex_quote).to eq('\\textless{}hello\\textgreater{}')
100
+ expect('{hello}'.tex_quote).to eq('\\{hello\\}')
101
101
  end
102
102
 
103
- it "should be able to determine is it's a valid number" do
103
+ it 'should be able to determine is it\'s a valid number' do
104
104
  expect('88'.number?).to be true
105
105
  expect('-88'.number?).to be true
106
106
  expect('8.008'.number?).to be true
@@ -111,7 +111,7 @@ the people, for the people, shall not perish from the earth."
111
111
  expect('hello world'.number?).to be false
112
112
  end
113
113
 
114
- it "should be able to convert a string to a regular expression" do
114
+ it 'should be able to convert a string to a regular expression' do
115
115
  re = "/hello((\s+)(world))?/".to_regexp
116
116
  expect(re.class).to eq Regexp
117
117
  expect(re.casefold?).to be true
@@ -129,101 +129,98 @@ the people, for the people, shall not perish from the earth."
129
129
  expect(re.multiline?).to be false
130
130
  end
131
131
 
132
- it "should be able to convert itself to a sym" do
133
- expect("joke".as_sym).to eq :joke
134
- expect("hello world".as_sym).to eq :hello_world
132
+ it 'should be able to convert itself to a sym' do
133
+ expect('joke'.as_sym).to eq :joke
134
+ expect('hello world'.as_sym).to eq :hello_world
135
135
  expect("hello world it's me".as_sym).to eq :hello_world_its_me
136
- expect("Street1".as_sym).to eq :street1
136
+ expect('Street1'.as_sym).to eq :street1
137
137
  end
138
138
 
139
- it "should do nothing in response to as_string" do
140
- expect("joke".as_string).to eq "joke"
141
- expect("hello world".as_string).to eq "hello world"
139
+ it 'should do nothing in response to as_string' do
140
+ expect('joke'.as_string).to eq 'joke'
141
+ expect('hello world'.as_string).to eq 'hello world'
142
142
  expect("hello world it's me".as_string)
143
143
  .to eq "hello world it's me"
144
144
  end
145
145
 
146
- it "should be able to fuzzy match with another string" do
147
- expect("Hello, world".fuzzy_match('or')).to be_truthy
148
- expect("Hello, world".fuzzy_match('ox')).to be_falsy
146
+ it 'should be able to fuzzy match with another string' do
147
+ expect('Hello, world'.fuzzy_match('or')).to be_truthy
148
+ expect('Hello, world'.fuzzy_match('ox')).to be_falsy
149
149
  end
150
150
 
151
- it "should be able to match with another string containing re" do
152
- expect("Hello, world".matches_with('/or/')).to be_truthy
153
- expect("Hello, world".matches_with('/ox/')).to be_falsy
151
+ it 'should be able to match with another string containing re' do
152
+ expect('Hello, world'.matches_with('/or/')).to be_truthy
153
+ expect('Hello, world'.matches_with('/ox/')).to be_falsy
154
154
  end
155
155
 
156
- it "should be able to match with another string containing string" do
157
- expect("Hello, world".matches_with('or')).to be_truthy
158
- expect("Hello, world".matches_with('ox')).to be_falsy
156
+ it 'should be able to match with another string containing string' do
157
+ expect('Hello, world'.matches_with('or')).to be_truthy
158
+ expect('Hello, world'.matches_with('ox')).to be_falsy
159
159
  end
160
160
 
161
- it "should be able to fuzzy match space-separated parts" do
162
- expect("Hello world".fuzzy_match('hel or')).to be_truthy
163
- expect("Hello, world".fuzzy_match('hel ox')).to be_falsy
161
+ it 'should be able to fuzzy match space-separated parts' do
162
+ expect('Hello world'.fuzzy_match('hel or')).to be_truthy
163
+ expect('Hello, world'.fuzzy_match('hel ox')).to be_falsy
164
164
  end
165
165
 
166
- it "should be able to fuzzy match colon-separated parts" do
167
- expect("Hello:world".fuzzy_match('hel:or')).to be_truthy
168
- expect("Hello:world".fuzzy_match('hel:ox')).to be_falsy
166
+ it 'should be able to fuzzy match colon-separated parts' do
167
+ expect('Hello:world'.fuzzy_match('hel:or')).to be_truthy
168
+ expect('Hello:world'.fuzzy_match('hel:ox')).to be_falsy
169
169
  end
170
170
 
171
- it "should be able to fuzzy match colon-separated parts" do
172
- expect("Hello:world".fuzzy_match('hel:or')).to be_truthy
173
- expect("Hello:world".fuzzy_match('hel:ox')).to be_falsy
171
+ it 'should be able to fuzzy match colon-separated parts' do
172
+ expect('Hello:world'.fuzzy_match('hel:or')).to be_truthy
173
+ expect('Hello:world'.fuzzy_match('hel:ox')).to be_falsy
174
174
  end
175
175
 
176
- it "should return the matched text" do
177
- expect("Hello:world".fuzzy_match('hel')).to eq('Hel')
178
- expect("Hello:world".fuzzy_match('hel:or')).to eq('Hello:wor')
179
- expect("Hello:world".matches_with('/^h.*r/')).to eq('Hello:wor')
176
+ it 'should return the matched text' do
177
+ expect('Hello:world'.fuzzy_match('hel')).to eq('Hel')
178
+ expect('Hello:world'.fuzzy_match('hel:or')).to eq('Hello:wor')
179
+ expect('Hello:world'.matches_with('/^h.*r/')).to eq('Hello:wor')
180
180
  end
181
181
 
182
- it "should ignore periods, commas, and apostrophes when matching" do
182
+ it 'should ignore periods, commas, and apostrophes when matching' do
183
183
  expect("St. Luke's".fuzzy_match('st lukes')).to eq('St Lukes')
184
- expect("St Lukes".fuzzy_match('st. luke\'s')).to eq('St Lukes')
185
- expect("St Lukes, Inc.".fuzzy_match('st luke inc')).to eq('St Lukes Inc')
186
- expect("E*TRADE".fuzzy_match('etrade')).to eq('ETRADE')
184
+ expect('St Lukes'.fuzzy_match('st. luke\'s')).to eq('St Lukes')
185
+ expect('St Lukes, Inc.'.fuzzy_match('st luke inc')).to eq('St Lukes Inc')
186
+ expect('E*TRADE'.fuzzy_match('etrade')).to eq('ETRADE')
187
187
  end
188
188
 
189
- it "should be able to properly capitalize a string as a title" do
189
+ it 'should be able to properly capitalize a string as a title' do
190
190
  # Capitalize little words only at beginning and end
191
- expect("the cat in the hat".entitle).to eq('The Cat in the Hat')
192
- expect("dr".entitle).to eq('Dr')
193
- expect("cr".entitle).to eq('Cr')
191
+ expect('the cat in the hat'.entitle).to eq('The Cat in the Hat')
192
+ expect('dr'.entitle).to eq('Dr')
193
+ expect('cr'.entitle).to eq('Cr')
194
194
  # Capitalize all consonants size if >= 3
195
- expect("tr".entitle).to eq('Tr')
196
- expect("trd".entitle).to eq('TRD')
195
+ expect('tr'.entitle).to eq('Tr')
196
+ expect('trd'.entitle).to eq('TRD')
197
197
  # Don't capitalize c/o
198
- expect("IBM c/o watson".entitle).to eq('Ibm c/o Watson')
198
+ expect('IBM c/o watson'.entitle).to eq('Ibm c/o Watson')
199
199
  # Capitlaize p.o.
200
- expect("p.o. box 123".entitle).to eq('P.O. Box 123')
200
+ expect('p.o. box 123'.entitle).to eq('P.O. Box 123')
201
201
  # Don't capitalize ordinals
202
- expect("22nd of september".entitle).to eq('22nd of September')
202
+ expect('22nd of september'.entitle).to eq('22nd of September')
203
203
  # Capitalize common abbrevs
204
- expect("US BANK".entitle).to eq('US Bank')
205
- expect("NW territory".entitle).to eq('NW Territory')
204
+ expect('US BANK'.entitle).to eq('US Bank')
205
+ expect('NW territory'.entitle).to eq('NW Territory')
206
206
  # Leave word starting with numbers alone
207
- expect("apartment 33-B".entitle).to eq('Apartment 33-B')
207
+ expect('apartment 33-B'.entitle).to eq('Apartment 33-B')
208
208
  # Assume all consanants is an acronym
209
- expect("the cbs network".entitle).to eq('The CBS Network')
209
+ expect('the cbs network'.entitle).to eq('The CBS Network')
210
210
  # Capitalize both parts of a hyphenated word
211
- expect("the hitler-stalin pact".entitle).
212
- to eq('The Hitler-Stalin Pact')
211
+ expect('the hitler-stalin pact'.entitle).to eq('The Hitler-Stalin Pact')
213
212
  end
214
213
 
215
- it "should be able to compute its Levenshtein distance from another string" do
214
+ it 'should be able to compute its Levenshtein distance from another string' do
216
215
  expect('Something'.distance('Smoething')).to eq 1
217
216
  expect('Something'.distance('Smoething', block_size: 0)).to eq 2
218
217
  expect('Something'.distance('meSothing', block_size: 1)).to eq 4
219
218
  expect('Something'.distance('meSothing', block_size: 2)).to eq 2
220
219
  expect('SomethingElse'.distance('Encyclopedia')).to eq 10
221
- expect('SomethingElseUnrelated'.
222
- distance('EncyclopediaBritanica',
223
- max_distance: 40)).to eq 21
224
- expect('SomethingElseUnrelated'.
225
- distance('EncyclopediaBritanica',
226
- max_distance: 15)).to eq 15
220
+ expect('SomethingElseUnrelated'.distance('EncyclopediaBritanica', max_distance: 40))
221
+ .to eq 21
222
+ expect('SomethingElseUnrelated'.distance('EncyclopediaBritanica',
223
+ max_distance: 15)).to eq 15
227
224
  end
228
225
  end
229
226
  end