active_object 1.1.1 → 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,85 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Object do
4
-
5
- describe "#blank?" do
6
- it "to be true" do
7
- expect("".blank?).to eq(true)
8
- expect(" ".blank?).to eq(true)
9
- expect([].blank?).to eq(true)
10
- expect({}.blank?).to eq(true)
11
- expect(false.blank?).to eq(true)
12
- end
13
-
14
- it "to be false" do
15
- expect("x".blank?).to eq(false)
16
- expect("foo bar".blank?).to eq(false)
17
- expect("19".blank?).to eq(false)
18
- expect(true.blank?).to eq(false)
19
- end
20
- end
21
-
22
- describe "#numeric?" do
23
- it "to be true" do
24
- expect(5.numeric?).to eq(true)
25
- expect(0.numeric?).to eq(true)
26
- expect(-37.3.numeric?).to eq(true)
27
- expect(51.45.numeric?).to eq(true)
28
- expect("+256.375".numeric?).to eq(true)
29
- expect("-37.3".numeric?).to eq(true)
30
- end
31
-
32
- it "to be false" do
33
- expect("".numeric?).to eq(false)
34
- expect(" ".numeric?).to eq(false)
35
- expect("2.3.3".numeric?).to eq(false)
36
- expect("$9.86".numeric?).to eq(false)
37
- expect("x".numeric?).to eq(false)
38
- expect("foo".numeric?).to eq(false)
39
- end
40
- end
41
-
42
- describe "#palindrome?" do
43
- it "to be true" do
44
- expect("racecar".palindrome?).to eq(true)
45
- expect(12321.palindrome?).to eq(true)
46
- end
47
-
48
- it "to be false" do
49
- expect("example".palindrome?).to eq(false)
50
- expect(12345.palindrome?).to eq(false)
51
- end
52
- end
53
-
54
- describe "#present?" do
55
- it "to be true" do
56
- expect("x".present?).to eq(true)
57
- expect("foo bar".present?).to eq(true)
58
- expect("19".present?).to eq(true)
59
- expect(true.present?).to eq(true)
60
- end
61
-
62
- it "to be false" do
63
- expect("".present?).to eq(false)
64
- expect([].present?).to eq(false)
65
- expect({}.present?).to eq(false)
66
- expect(false.present?).to eq(false)
67
- end
68
- end
69
-
70
- describe "#try(!)" do
71
- it "to be nil" do
72
- expect("example".try(:fake_method)).to eq(nil)
73
- end
74
-
75
- it "to be upcase" do
76
- expect("example".try(:upcase)).to eq("EXAMPLE")
77
- expect("example".try!(:upcase)).to eq("EXAMPLE")
78
- end
79
-
80
- it "to raise error" do
81
- expect { "example".try!(:fake_method) }.to raise_error(NoMethodError)
82
- end
83
- end
84
-
85
- end
@@ -1,26 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Range do
4
-
5
- describe "#include_with_range?" do
6
- it "to be true" do
7
- expect((1..5).include_with_range?(1..5)).to eq(true)
8
- expect((1..5).include_with_range?(2..3)).to eq(true)
9
- end
10
-
11
- it "to be false" do
12
- expect((1..5).include_with_range?(2..6)).to eq(false)
13
- end
14
- end
15
-
16
- describe "#overlaps?" do
17
- it "to be true" do
18
- expect((1..5).overlaps?(4..6)).to eq(true)
19
- end
20
-
21
- it "to be false" do
22
- expect((1..5).overlaps?(7..9)).to eq(false)
23
- end
24
- end
25
-
26
- end
@@ -1,471 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe String do
4
-
5
- describe "#any?" do
6
- it "to be true" do
7
- expect("example string".any?("example")).to eq(true)
8
- expect("example string".any?("foo", "string")).to eq(true)
9
- end
10
-
11
- it "to be false" do
12
- expect("example string".any?("foo")).to eq(false)
13
- expect("example string".any?("foo", "bar")).to eq(false)
14
- end
15
- end
16
-
17
- describe "#at" do
18
- it "to be e" do
19
- expect("example".at(0)).to eq("e")
20
- expect("example".at(-1)).to eq("e")
21
- end
22
-
23
- it "to be m" do
24
- expect("example".at(3)).to eq("m")
25
- end
26
-
27
- it "to be xam" do
28
- expect("example".at(1..3)).to eq("xam")
29
- end
30
-
31
- it "to be ''" do
32
- expect("example".at(7..-1)).to eq("")
33
- end
34
-
35
- it "to be pl" do
36
- expect("example".at("pl")).to eq("pl")
37
- expect("example".at(/pl/)).to eq("pl")
38
- end
39
-
40
- it "to be nil" do
41
- expect("example".at("xp")).to eq(nil)
42
- expect("example".at(/xp/)).to eq(nil)
43
- end
44
- end
45
-
46
- describe "#camelize(!)" do
47
- it "to be ExampleString" do
48
- expect("example_string".camelize).to eq("ExampleString")
49
- expect("example_string".camelcase).to eq("ExampleString")
50
- expect("example_string".camelize!).to eq("ExampleString")
51
- expect("example_string".camelcase!).to eq("ExampleString")
52
- end
53
-
54
- it "to be exampleString" do
55
- expect("example_string".camelize(:lower)).to eq("exampleString")
56
- expect("example_string".camelcase(:lower)).to eq("exampleString")
57
- expect("example_string".camelize!(:lower)).to eq("exampleString")
58
- expect("example_string".camelcase!(:lower)).to eq("exampleString")
59
- end
60
- end
61
-
62
- describe "#classify" do
63
- it "to be ExampleString" do
64
- expect("example_string".classify).to eq("ExampleString")
65
- expect("example_string".classify!).to eq("ExampleString")
66
- end
67
-
68
- it "to be ExampleString::Test" do
69
- expect("example_string/test".classify).to eq("ExampleString::Test")
70
- expect("example_string/test".classify!).to eq("ExampleString::Test")
71
- end
72
-
73
- it "to be Test" do
74
- expect("example_string.test".classify).to eq("Test")
75
- expect("example_string.test".classify!).to eq("Test")
76
- end
77
- end
78
-
79
- describe "#demodulize" do
80
- it "to be String" do
81
- expect("Example::String".demodulize).to eq("String")
82
- expect("Example::String".demodulize!).to eq("String")
83
- expect("String".demodulize).to eq("String")
84
- expect("String".demodulize!).to eq("String")
85
- end
86
- end
87
-
88
- describe "#dasherize" do
89
- it "to be example-string" do
90
- expect("example_string".dasherize).to eq("example-string")
91
- expect("example_string".dasherize!).to eq("example-string")
92
- end
93
- end
94
-
95
- describe "#domain" do
96
- it "to be ''" do
97
- expect("".domain).to eq("")
98
- end
99
-
100
- it "to be ' '" do
101
- expect(" ".domain).to eq(" ")
102
- end
103
-
104
- it "to be example string" do
105
- expect("example string".domain).to eq("example string")
106
- end
107
-
108
- it "to be www.example.com" do
109
- expect("http://www.example.com".domain).to eq("www.example.com")
110
- expect("http://www.example.com/fake-page".domain).to eq("www.example.com")
111
- end
112
- end
113
-
114
- describe "#downcase?" do
115
- it "to be true" do
116
- expect("downcase".downcase?).to eq(true)
117
- expect("downcase string".downcase?).to eq(true)
118
- end
119
-
120
- it "to be false" do
121
- expect("Mixedcase".downcase?).to eq(false)
122
- expect("UPCASE".downcase?).to eq(false)
123
- expect("Mixedcase string".downcase?).to eq(false)
124
- end
125
- end
126
-
127
- describe "#ellipsize" do
128
- it "to be 0123...WXYZ" do
129
- expect("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".ellipsize(30)).to eq("0123...WXYZ")
130
- end
131
-
132
- it "to be 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" do
133
- expect("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".ellipsize(50)).to eq("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ")
134
- end
135
-
136
- it "to be 012...XYZ" do
137
- expect("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".ellipsize(30, offset: 3)).to eq("012...XYZ")
138
- end
139
-
140
- it "to be 0123+++WXYZ" do
141
- expect("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".ellipsize(30, separator: "+++")).to eq("0123+++WXYZ")
142
- end
143
- end
144
-
145
- describe "#exclude?" do
146
- it "to be true" do
147
- expect("example_string".exclude?("xxx")).to eq(true)
148
- end
149
-
150
- it "to be false" do
151
- expect("example_string".exclude?("exa")).to eq(false)
152
- end
153
- end
154
-
155
- describe "#first" do
156
- it "to be e" do
157
- expect("example".first).to eq("e")
158
- end
159
-
160
- it "to be ''" do
161
- expect("example".first(0)).to eq("")
162
- end
163
-
164
- it "to be exa" do
165
- expect("example".first(3)).to eq("exa")
166
- end
167
- end
168
-
169
- describe "#from" do
170
- it "to be example" do
171
- expect("example".from(0)).to eq("example")
172
- end
173
-
174
- it "to be mple" do
175
- expect("example".from(3)).to eq("mple")
176
- end
177
- end
178
-
179
- describe "#humanize(!)" do
180
- it "to be Example string test" do
181
- expect("example_string_test".humanize).to eq("Example string test")
182
- expect("example_string_test".humanize!).to eq("Example string test")
183
- expect("exampleStringTest".humanize).to eq("Example string test")
184
- expect("exampleStringTest".humanize!).to eq("Example string test")
185
- expect("ExampleStringTest".humanize).to eq("Example string test")
186
- expect("ExampleStringTest".humanize!).to eq("Example string test")
187
- end
188
-
189
- it "to be example string test" do
190
- expect("example_string_test".humanize(capitalize: false)).to eq("example string test")
191
- expect("example_string_test".humanize!(capitalize: false)).to eq("example string test")
192
- expect("exampleStringTest".humanize(capitalize: false)).to eq("example string test")
193
- expect("exampleStringTest".humanize!(capitalize: false)).to eq("example string test")
194
- expect("ExampleStringTest".humanize(capitalize: false)).to eq("example string test")
195
- expect("ExampleStringTest".humanize!(capitalize: false)).to eq("example string test")
196
- end
197
- end
198
-
199
- describe "#indent(!)" do
200
- it "to be ' example'" do
201
- expect("example".indent(2)).to eq(" example")
202
- expect("example".indent!(2)).to eq(" example")
203
- end
204
-
205
- it "to be '\t\texample'" do
206
- expect("example".indent(2, "\t")).to eq("\t\texample")
207
- expect("example".indent!(2, "\t")).to eq("\t\texample")
208
- end
209
- end
210
-
211
- describe "#last" do
212
- it "to be e" do
213
- expect("example".last).to eq("e")
214
- end
215
-
216
- it "to be ''" do
217
- expect("example".last(0)).to eq("")
218
- end
219
-
220
- it "to be ple" do
221
- expect("example".last(3)).to eq("ple")
222
- end
223
- end
224
-
225
- describe "#mixedcase?" do
226
- it "to be true" do
227
- expect("Mixedcase".mixedcase?).to eq(true)
228
- expect("Mixedcase STRING type".mixedcase?).to eq(true)
229
- end
230
-
231
- it "to be false" do
232
- expect("downcase".mixedcase?).to eq(false)
233
- expect("UPCASE".mixedcase?).to eq(false)
234
- end
235
- end
236
-
237
- describe "#ordinal" do
238
- it "to be st" do
239
- expect("1".ordinal).to eq("st")
240
- end
241
-
242
- it "to be nd" do
243
- expect("2".ordinal).to eq("nd")
244
- end
245
-
246
- it "to be rd" do
247
- expect("3".ordinal).to eq("rd")
248
- end
249
-
250
- it "to be th" do
251
- expect("11".ordinal).to eq("th")
252
- end
253
- end
254
-
255
- describe "#ordinalize" do
256
- it "to be st" do
257
- expect("1".ordinalize).to eq("1st")
258
- end
259
-
260
- it "to be nd" do
261
- expect("2".ordinalize).to eq("2nd")
262
- end
263
-
264
- it "to be rd" do
265
- expect("3".ordinalize).to eq("3rd")
266
- end
267
-
268
- it "to be th" do
269
- expect("11".ordinalize).to eq("11th")
270
- end
271
- end
272
-
273
- describe "#parameterize(!)" do
274
- it "to be example-string" do
275
- expect("example_string".parameterize).to eq("example-string")
276
- expect("example_string".parameterize!).to eq("example-string")
277
- end
278
-
279
- it "to be example_string" do
280
- expect("example_string".parameterize("?")).to eq("example?string")
281
- expect("example_string".parameterize!("?")).to eq("example?string")
282
- end
283
- end
284
-
285
- describe "#pollute" do
286
- it "to be t^--^--^e^--^--^s^--^--^t^--^--^" do
287
- expect("test".pollute).to eq("t^--^--^e^--^--^s^--^--^t^--^--^")
288
- end
289
-
290
- it "to be t-e-s-t-" do
291
- expect("test".pollute("-")).to eq("t-e-s-t-")
292
- end
293
- end
294
-
295
- describe "#remove(!)" do
296
- it "to be 'this that '" do
297
- expect("this thing that thing".remove("thing")).to eq("this that ")
298
- expect("this thing that thing".remove!("thing")).to eq("this that ")
299
- expect("this thing that them".remove("thing", "them")).to eq("this that ")
300
- expect("this thing that them".remove!("thing", "them")).to eq("this that ")
301
- end
302
- end
303
-
304
- describe "#remove_tags(!)" do
305
- it "to be example" do
306
- expect("example".remove_tags).to eq("example")
307
- expect("example".remove_tags!).to eq("example")
308
- end
309
-
310
- it "to be click" do
311
- expect("<a href='http://example.com'>click</a>".remove_tags).to eq("click")
312
- expect("<a href='http://example.com'>click</a>".remove_tags!).to eq("click")
313
- end
314
-
315
- it "to be this is bold and emphatic" do
316
- expect("this is <b>bold</b> and <em>emphatic</em>".remove_tags).to eq("this is bold and emphatic")
317
- expect("this is <b>bold</b> and <em>emphatic</em>".remove_tags!).to eq("this is bold and emphatic")
318
- end
319
- end
320
-
321
- describe "#shift(!)" do
322
- it "to be 'this that thing'" do
323
- expect("this thing that thing".shift("thing")).to eq("this that thing")
324
- expect("this thing that thing".shift!("thing")).to eq("this that thing")
325
- end
326
-
327
- it "to be ' thing thing'" do
328
- expect("this thing that thing".shift("this", "that")).to eq(" thing thing")
329
- expect("this thing that thing".shift!("this", "that")).to eq(" thing thing")
330
- end
331
- end
332
-
333
- describe "#slugify(!)" do
334
- it "to be example" do
335
- expect("example".slugify).to eq("example")
336
- expect("example".slugify!).to eq("example")
337
- end
338
-
339
- it "to be example-string" do
340
- expect("example string".slugify).to eq("example-string")
341
- expect("example string".slugify!).to eq("example-string")
342
- end
343
-
344
- it "to be example-string-test" do
345
- expect("Example string @@@ test!".slugify).to eq("example-string-test")
346
- expect("Example string @@@ test!".slugify!).to eq("example-string-test")
347
- end
348
-
349
- it "to be a-real-doozie" do
350
- expect(" A REal Doozi\"e? \' ".slugify).to eq("a-real-doozie")
351
- expect(" A REal Doozi\"e? \' ".slugify!).to eq("a-real-doozie")
352
- end
353
- end
354
-
355
- describe "#squish(!)" do
356
- it "to be example test" do
357
- expect("example test".squish).to eq("example test")
358
- expect("example \n \t test".squish!).to eq("example test")
359
- expect(" example \n \t test ".squish).to eq("example test")
360
- expect(" example test ".squish!).to eq("example test")
361
- end
362
- end
363
-
364
- describe "#titleize(!)" do
365
- it "to be Example String Test" do
366
- expect("example string test".titleize).to eq("Example String Test")
367
- expect("example string test".titlecase).to eq("Example String Test")
368
- expect("example string test".titleize!).to eq("Example String Test")
369
- expect("example string test".titlecase!).to eq("Example String Test")
370
- expect("Example string Test".titleize).to eq("Example String Test")
371
- expect("Example string Test".titleize!).to eq("Example String Test")
372
- expect("ExampleStringTest".titleize).to eq("Example String Test")
373
- expect("ExampleStringTest".titleize!).to eq("Example String Test")
374
- expect("Example_string_test".titleize).to eq("Example String Test")
375
- expect("Example_string_test".titleize!).to eq("Example String Test")
376
- end
377
- end
378
-
379
- describe "#to" do
380
- it "to be e" do
381
- expect("example".to(0)).to eq("e")
382
- end
383
-
384
- it "to be exampl" do
385
- expect("example".to(-2)).to eq("exampl")
386
- end
387
-
388
- it "to be exam" do
389
- expect("example".to(3)).to eq("exam")
390
- end
391
- end
392
-
393
- describe "#truncate" do
394
- it "to be ..." do
395
- expect("example string".truncate(3)).to eq("...")
396
- end
397
-
398
- it "to be exa..." do
399
- expect("example string".truncate(6)).to eq("exa...")
400
- end
401
-
402
- it "to be example..." do
403
- expect("example string".truncate(12, separator: " ")).to eq("example...")
404
- end
405
-
406
- it "to be exa... (more)" do
407
- expect("example string".truncate(13, omission: "... (more)")).to eq("exa... (more)")
408
- end
409
-
410
- it "to be example string" do
411
- expect("example string".truncate(15)).to eq("example string")
412
- end
413
- end
414
-
415
- describe "#truncate_words" do
416
- it "to be example..." do
417
- expect("example string test".truncate_words(1)).to eq("example...")
418
- end
419
-
420
- it "to be Once<br>upon<br>a<br>time<br>in..." do
421
- expect('Once<br>upon<br>a<br>time<br>in<br>a<br>world'.truncate_words(5, separator: '<br>')).to eq("Once<br>upon<br>a<br>time<br>in...")
422
- end
423
-
424
- it "to be And they found that many... (continued)" do
425
- expect('And they found that many people were sleeping better.'.truncate_words(5, omission: '... (continued)')).to eq("And they found that many... (continued)")
426
- end
427
- end
428
-
429
- describe "#underscore(!)" do
430
- it "to be example_string" do
431
- expect("ExampleString".underscore).to eq("example_string")
432
- expect("ExampleString".underscore!).to eq("example_string")
433
- expect("exampleString".underscore).to eq("example_string")
434
- expect("exampleString".underscore!).to eq("example_string")
435
- expect("example_string".underscore).to eq("example_string")
436
- expect("example_string".underscore!).to eq("example_string")
437
- expect("example_String".underscore).to eq("example_string")
438
- expect("example_String".underscore!).to eq("example_string")
439
- expect("EXAMPLE_String".underscore!).to eq("example_string")
440
- end
441
-
442
- it "to be example_string/test" do
443
- expect("ExampleString::Test".underscore).to eq("example_string/test")
444
- expect("ExampleString::Test".underscore!).to eq("example_string/test")
445
- end
446
- end
447
-
448
- describe "#unpollute" do
449
- it "to be test" do
450
- expect("test".unpollute).to eq("test")
451
- end
452
-
453
- it "to be test" do
454
- expect("t-e-s-t-".unpollute("-")).to eq("test")
455
- end
456
- end
457
-
458
- describe "#upcase?" do
459
- it "to be true" do
460
- expect("UPCASE".upcase?).to eq(true)
461
- expect("UPCASE STRING".upcase?).to eq(true)
462
- end
463
-
464
- it "to be false" do
465
- expect("downcase".upcase?).to eq(false)
466
- expect("Mixedcase".upcase?).to eq(false)
467
- expect("Mixedcase string".upcase?).to eq(false)
468
- end
469
- end
470
-
471
- end