string_foundation 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +9 -0
  3. data/CODE_OF_CONDUCT.md +75 -0
  4. data/Gemfile +38 -0
  5. data/Gemfile.lock +58 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +324 -0
  8. data/Rakefile +13 -0
  9. data/bin/console +15 -0
  10. data/bin/setup +11 -0
  11. data/circle.yml +14 -0
  12. data/coverage/assets/0.10.0/application.css +799 -0
  13. data/coverage/assets/0.10.0/application.js +1707 -0
  14. data/coverage/assets/0.10.0/colorbox/border.png +0 -0
  15. data/coverage/assets/0.10.0/colorbox/controls.png +0 -0
  16. data/coverage/assets/0.10.0/colorbox/loading.gif +0 -0
  17. data/coverage/assets/0.10.0/colorbox/loading_background.png +0 -0
  18. data/coverage/assets/0.10.0/favicon_green.png +0 -0
  19. data/coverage/assets/0.10.0/favicon_red.png +0 -0
  20. data/coverage/assets/0.10.0/favicon_yellow.png +0 -0
  21. data/coverage/assets/0.10.0/loading.gif +0 -0
  22. data/coverage/assets/0.10.0/magnify.png +0 -0
  23. data/coverage/assets/0.10.0/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  24. data/coverage/assets/0.10.0/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  25. data/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  26. data/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  27. data/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  28. data/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  29. data/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  30. data/coverage/assets/0.10.0/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  31. data/coverage/assets/0.10.0/smoothness/images/ui-icons_222222_256x240.png +0 -0
  32. data/coverage/assets/0.10.0/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
  33. data/coverage/assets/0.10.0/smoothness/images/ui-icons_454545_256x240.png +0 -0
  34. data/coverage/assets/0.10.0/smoothness/images/ui-icons_888888_256x240.png +0 -0
  35. data/coverage/assets/0.10.0/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
  36. data/coverage/index.html +12508 -0
  37. data/lib/string_foundation/case.rb +102 -0
  38. data/lib/string_foundation/convert.rb +51 -0
  39. data/lib/string_foundation/convertible.rb +40 -0
  40. data/lib/string_foundation/like.rb +24 -0
  41. data/lib/string_foundation/version.rb +7 -0
  42. data/lib/string_foundation/with.rb +26 -0
  43. data/lib/string_foundation.rb +6 -0
  44. data/pkg/string_foundation-1.0.0.gem +0 -0
  45. data/spec/spec_helper.rb +40 -0
  46. data/spec/string_foundation/case_spec.rb +901 -0
  47. data/spec/string_foundation/convert_spec.rb +234 -0
  48. data/spec/string_foundation/convertaile_spec.rb +286 -0
  49. data/spec/string_foundation/like_spec.rb +218 -0
  50. data/spec/string_foundation/version_spec.rb +14 -0
  51. data/spec/string_foundation/with_spec.rb +99 -0
  52. data/spec/support/enhanced_matchers_extension.rb +11 -0
  53. data/string_foundation.gemspec +22 -0
  54. data/string_foundation.png +0 -0
  55. metadata +106 -0
@@ -0,0 +1,901 @@
1
+ # ==============================================================================
2
+ # SPEC - STRING FOUNDATION - CASE
3
+ # ==============================================================================
4
+ # frozen_string_literal: true
5
+ describe '[ Case Methods ]' do
6
+ # Define shared contexts.
7
+ # ----------------------------------------------------------------------------
8
+ shared_context 'one word' do let(:string) { 'string' } end
9
+ shared_context 'lowerCamelCase' do let(:string) { 'weAreBrushdown' } end
10
+ shared_context 'UpperCamelCase' do let(:string) { 'WeAreBrushdown' } end
11
+ shared_context 'lower_snake_case' do let(:string) { 'we_are_brushdown' } end
12
+ shared_context 'Upper_Snake_Case' do let(:string) { 'We_Are_Brushdown' } end
13
+ shared_context 'lower-kebab-case' do let(:string) { 'we-are-brushdown' } end
14
+ shared_context 'Upper-Kebab-Case' do let(:string) { 'We-Are-Brushdown' } end
15
+ shared_context 'lower space case' do let(:string) { 'we are brushdown' } end
16
+ shared_context 'Upper Space Case' do let(:string) { 'We Are Brushdown' } end
17
+ shared_context 'lower.dot.case' do let(:string) { 'we.are.brushdown' } end
18
+ shared_context 'Upper.Dot.Case' do let(:string) { 'We.Are.Brushdown' } end
19
+ # ----------------------------------------------------------------------------
20
+
21
+ # ----------------------------------------------------------------------------
22
+ # Convert to lowerCamelCase
23
+ # ----------------------------------------------------------------------------
24
+ describe 'CONVERT TO lowerCamelCase' do
25
+ subject { string.to_lcamel }
26
+
27
+ # Define shared examples.
28
+ # --------------------------------------------------------------------------
29
+ shared_examples 'be converted to lowerCamelCase' do
30
+ it { is_expected.to eq 'weAreBrushdown' }
31
+ end
32
+ # --------------------------------------------------------------------------
33
+
34
+ context 'When a string has one word,' do
35
+ include_context 'one word'
36
+
37
+ it { is_expected.to eq 'string' }
38
+ end
39
+
40
+ context 'When a string lowerCamelCase,' do
41
+ include_context 'lowerCamelCase'
42
+
43
+ it_behaves_like 'be converted to lowerCamelCase'
44
+ end
45
+
46
+ context 'When a string UpperCamelCase,' do
47
+ include_context 'UpperCamelCase'
48
+
49
+ it_behaves_like 'be converted to lowerCamelCase'
50
+ end
51
+
52
+ context 'When a string lower_snake_case,' do
53
+ include_context 'lower_snake_case'
54
+
55
+ it_behaves_like 'be converted to lowerCamelCase'
56
+ end
57
+
58
+ context 'When a string Upper_Snake_Case,' do
59
+ include_context 'Upper_Snake_Case'
60
+
61
+ it_behaves_like 'be converted to lowerCamelCase'
62
+ end
63
+
64
+ context 'When a string lower-kebab-case,' do
65
+ include_context 'lower-kebab-case'
66
+
67
+ it_behaves_like 'be converted to lowerCamelCase'
68
+ end
69
+
70
+ context 'When a string Upper-Kebab-Case,' do
71
+ include_context 'Upper-Kebab-Case'
72
+
73
+ it_behaves_like 'be converted to lowerCamelCase'
74
+ end
75
+
76
+ context 'When a string lower space case,' do
77
+ include_context 'lower space case'
78
+
79
+ it_behaves_like 'be converted to lowerCamelCase'
80
+ end
81
+
82
+ context 'When a string Upper Space Case,' do
83
+ include_context 'Upper Space Case'
84
+
85
+ it_behaves_like 'be converted to lowerCamelCase'
86
+ end
87
+ context 'When a string lower.dot.case,' do
88
+ include_context 'lower.dot.case'
89
+
90
+ it_behaves_like 'be converted to lowerCamelCase'
91
+ end
92
+
93
+ context 'When a string Upper.Dot.Case,' do
94
+ include_context 'Upper.Dot.Case'
95
+
96
+ it_behaves_like 'be converted to lowerCamelCase'
97
+ end
98
+ end
99
+
100
+
101
+ # ----------------------------------------------------------------------------
102
+ # Convert to UpperCamelCase
103
+ # ----------------------------------------------------------------------------
104
+ describe 'CONVERT TO UpperCamelCase' do
105
+ subject { string.to_ucamel }
106
+
107
+ # Define shared examples.
108
+ # --------------------------------------------------------------------------
109
+ shared_examples 'be converted to UpperCamelCase' do
110
+ it { is_expected.to eq 'WeAreBrushdown' }
111
+ end
112
+ # --------------------------------------------------------------------------
113
+
114
+ context 'When a string has one word,' do
115
+ include_context 'one word'
116
+
117
+ it { is_expected.to eq 'String' }
118
+ end
119
+
120
+ context 'When a string lowerCamelCase,' do
121
+ include_context 'lowerCamelCase'
122
+
123
+ it_behaves_like 'be converted to UpperCamelCase'
124
+ end
125
+
126
+ context 'When a string UpperCamelCase,' do
127
+ include_context 'UpperCamelCase'
128
+
129
+ it_behaves_like 'be converted to UpperCamelCase'
130
+ end
131
+
132
+ context 'When a string lower_snake_case,' do
133
+ include_context 'lower_snake_case'
134
+
135
+ it_behaves_like 'be converted to UpperCamelCase'
136
+ end
137
+
138
+ context 'When a string Upper_Snake_Case,' do
139
+ include_context 'Upper_Snake_Case'
140
+
141
+ it_behaves_like 'be converted to UpperCamelCase'
142
+ end
143
+
144
+ context 'When a string lower-kebab-case,' do
145
+ include_context 'lower-kebab-case'
146
+
147
+ it_behaves_like 'be converted to UpperCamelCase'
148
+ end
149
+
150
+ context 'When a string Upper-Kebab-Case,' do
151
+ include_context 'Upper-Kebab-Case'
152
+
153
+ it_behaves_like 'be converted to UpperCamelCase'
154
+ end
155
+
156
+ context 'When a string lower space case,' do
157
+ include_context 'lower space case'
158
+
159
+ it_behaves_like 'be converted to UpperCamelCase'
160
+ end
161
+
162
+ context 'When a string Upper Space Case,' do
163
+ include_context 'Upper Space Case'
164
+
165
+ it_behaves_like 'be converted to UpperCamelCase'
166
+ end
167
+ context 'When a string lower.dot.case,' do
168
+ include_context 'lower.dot.case'
169
+
170
+ it_behaves_like 'be converted to UpperCamelCase'
171
+ end
172
+
173
+ context 'When a string Upper.Dot.Case,' do
174
+ include_context 'Upper.Dot.Case'
175
+
176
+ it_behaves_like 'be converted to UpperCamelCase'
177
+ end
178
+ end
179
+
180
+
181
+ # ----------------------------------------------------------------------------
182
+ # Convert to lower_snake_case
183
+ # ----------------------------------------------------------------------------
184
+ describe 'CONVERT TO lower_snake_case' do
185
+ subject { string.to_lsnake }
186
+
187
+ # Define shared examples.
188
+ # --------------------------------------------------------------------------
189
+ shared_examples 'be converted to lower_snake_case' do
190
+ it { is_expected.to eq 'we_are_brushdown' }
191
+ end
192
+ # --------------------------------------------------------------------------
193
+
194
+ context 'When a string has one word,' do
195
+ include_context 'one word'
196
+
197
+ it { is_expected.to eq 'string' }
198
+ end
199
+
200
+ context 'When a string lowerCamelCase,' do
201
+ include_context 'lowerCamelCase'
202
+
203
+ it_behaves_like 'be converted to lower_snake_case'
204
+ end
205
+
206
+ context 'When a string UpperCamelCase,' do
207
+ include_context 'UpperCamelCase'
208
+
209
+ it_behaves_like 'be converted to lower_snake_case'
210
+ end
211
+
212
+ context 'When a string lower_snake_case,' do
213
+ include_context 'lower_snake_case'
214
+
215
+ it_behaves_like 'be converted to lower_snake_case'
216
+ end
217
+
218
+ context 'When a string Upper_Snake_Case,' do
219
+ include_context 'Upper_Snake_Case'
220
+
221
+ it_behaves_like 'be converted to lower_snake_case'
222
+ end
223
+
224
+ context 'When a string lower-kebab-case,' do
225
+ include_context 'lower-kebab-case'
226
+
227
+ it_behaves_like 'be converted to lower_snake_case'
228
+ end
229
+
230
+ context 'When a string Upper-Kebab-Case,' do
231
+ include_context 'Upper-Kebab-Case'
232
+
233
+ it_behaves_like 'be converted to lower_snake_case'
234
+ end
235
+
236
+ context 'When a string lower space case,' do
237
+ include_context 'lower space case'
238
+
239
+ it_behaves_like 'be converted to lower_snake_case'
240
+ end
241
+
242
+ context 'When a string Upper Space Case,' do
243
+ include_context 'Upper Space Case'
244
+
245
+ it_behaves_like 'be converted to lower_snake_case'
246
+ end
247
+ context 'When a string lower.dot.case,' do
248
+ include_context 'lower.dot.case'
249
+
250
+ it_behaves_like 'be converted to lower_snake_case'
251
+ end
252
+
253
+ context 'When a string Upper.Dot.Case,' do
254
+ include_context 'Upper.Dot.Case'
255
+
256
+ it_behaves_like 'be converted to lower_snake_case'
257
+ end
258
+ end
259
+
260
+
261
+ # ----------------------------------------------------------------------------
262
+ # Convert to Upper_Snake_Case
263
+ # ----------------------------------------------------------------------------
264
+ describe 'CONVERT TO Upper_Snake_Case' do
265
+ subject { string.to_usnake }
266
+
267
+ # Define shared examples.
268
+ # --------------------------------------------------------------------------
269
+ shared_examples 'be converted to Upper_Snake_Case' do
270
+ it { is_expected.to eq 'We_Are_Brushdown' }
271
+ end
272
+ # --------------------------------------------------------------------------
273
+
274
+ context 'When a string has one word,' do
275
+ include_context 'one word'
276
+
277
+ it { is_expected.to eq 'String' }
278
+ end
279
+
280
+ context 'When a string lowerCamelCase,' do
281
+ include_context 'lowerCamelCase'
282
+
283
+ it_behaves_like 'be converted to Upper_Snake_Case'
284
+ end
285
+
286
+ context 'When a string UpperCamelCase,' do
287
+ include_context 'UpperCamelCase'
288
+
289
+ it_behaves_like 'be converted to Upper_Snake_Case'
290
+ end
291
+
292
+ context 'When a string lower_snake_case,' do
293
+ include_context 'lower_snake_case'
294
+
295
+ it_behaves_like 'be converted to Upper_Snake_Case'
296
+ end
297
+
298
+ context 'When a string Upper_Snake_Case,' do
299
+ include_context 'Upper_Snake_Case'
300
+
301
+ it_behaves_like 'be converted to Upper_Snake_Case'
302
+ end
303
+
304
+ context 'When a string lower-kebab-case,' do
305
+ include_context 'lower-kebab-case'
306
+
307
+ it_behaves_like 'be converted to Upper_Snake_Case'
308
+ end
309
+
310
+ context 'When a string Upper-Kebab-Case,' do
311
+ include_context 'Upper-Kebab-Case'
312
+
313
+ it_behaves_like 'be converted to Upper_Snake_Case'
314
+ end
315
+
316
+ context 'When a string lower space case,' do
317
+ include_context 'lower space case'
318
+
319
+ it_behaves_like 'be converted to Upper_Snake_Case'
320
+ end
321
+
322
+ context 'When a string Upper Space Case,' do
323
+ include_context 'Upper Space Case'
324
+
325
+ it_behaves_like 'be converted to Upper_Snake_Case'
326
+ end
327
+ context 'When a string lower.dot.case,' do
328
+ include_context 'lower.dot.case'
329
+
330
+ it_behaves_like 'be converted to Upper_Snake_Case'
331
+ end
332
+
333
+ context 'When a string Upper.Dot.Case,' do
334
+ include_context 'Upper.Dot.Case'
335
+
336
+ it_behaves_like 'be converted to Upper_Snake_Case'
337
+ end
338
+ end
339
+
340
+
341
+ # ----------------------------------------------------------------------------
342
+ # Convert to lower-kebab-case
343
+ # ----------------------------------------------------------------------------
344
+ describe 'CONVERT TO lower-kebab-case' do
345
+ subject { string.to_lkebab }
346
+
347
+ # Define shared examples.
348
+ # --------------------------------------------------------------------------
349
+ shared_examples 'be converted to lower-kebab-case' do
350
+ it { is_expected.to eq 'we-are-brushdown' }
351
+ end
352
+ # --------------------------------------------------------------------------
353
+
354
+ context 'When a string has one word,' do
355
+ include_context 'one word'
356
+
357
+ it { is_expected.to eq 'string' }
358
+ end
359
+
360
+ context 'When a string lowerCamelCase,' do
361
+ include_context 'lowerCamelCase'
362
+
363
+ it_behaves_like 'be converted to lower-kebab-case'
364
+ end
365
+
366
+ context 'When a string UpperCamelCase,' do
367
+ include_context 'UpperCamelCase'
368
+
369
+ it_behaves_like 'be converted to lower-kebab-case'
370
+ end
371
+
372
+ context 'When a string lower_snake_case,' do
373
+ include_context 'lower_snake_case'
374
+
375
+ it_behaves_like 'be converted to lower-kebab-case'
376
+ end
377
+
378
+ context 'When a string Upper_Snake_Case,' do
379
+ include_context 'Upper_Snake_Case'
380
+
381
+ it_behaves_like 'be converted to lower-kebab-case'
382
+ end
383
+
384
+ context 'When a string lower-kebab-case,' do
385
+ include_context 'lower-kebab-case'
386
+
387
+ it_behaves_like 'be converted to lower-kebab-case'
388
+ end
389
+
390
+ context 'When a string Upper-Kebab-Case,' do
391
+ include_context 'Upper-Kebab-Case'
392
+
393
+ it_behaves_like 'be converted to lower-kebab-case'
394
+ end
395
+
396
+ context 'When a string lower space case,' do
397
+ include_context 'lower space case'
398
+
399
+ it_behaves_like 'be converted to lower-kebab-case'
400
+ end
401
+
402
+ context 'When a string Upper Space Case,' do
403
+ include_context 'Upper Space Case'
404
+
405
+ it_behaves_like 'be converted to lower-kebab-case'
406
+ end
407
+ context 'When a string lower.dot.case,' do
408
+ include_context 'lower.dot.case'
409
+
410
+ it_behaves_like 'be converted to lower-kebab-case'
411
+ end
412
+
413
+ context 'When a string Upper.Dot.Case,' do
414
+ include_context 'Upper.Dot.Case'
415
+
416
+ it_behaves_like 'be converted to lower-kebab-case'
417
+ end
418
+ end
419
+
420
+
421
+ # ----------------------------------------------------------------------------
422
+ # Convert to Upper-Kebab-Case
423
+ # ----------------------------------------------------------------------------
424
+ describe 'CONVERT TO Upper-Kebab-Case' do
425
+ subject { string.to_ukebab }
426
+
427
+ # Define shared examples.
428
+ # --------------------------------------------------------------------------
429
+ shared_examples 'be converted to Upper-Kebab-Case' do
430
+ it { is_expected.to eq 'We-Are-Brushdown' }
431
+ end
432
+ # --------------------------------------------------------------------------
433
+
434
+ context 'When a string has one word,' do
435
+ include_context 'one word'
436
+
437
+ it { is_expected.to eq 'String' }
438
+ end
439
+
440
+ context 'When a string lowerCamelCase,' do
441
+ include_context 'lowerCamelCase'
442
+
443
+ it_behaves_like 'be converted to Upper-Kebab-Case'
444
+ end
445
+
446
+ context 'When a string UpperCamelCase,' do
447
+ include_context 'UpperCamelCase'
448
+
449
+ it_behaves_like 'be converted to Upper-Kebab-Case'
450
+ end
451
+
452
+ context 'When a string lower_snake_case,' do
453
+ include_context 'lower_snake_case'
454
+
455
+ it_behaves_like 'be converted to Upper-Kebab-Case'
456
+ end
457
+
458
+ context 'When a string Upper_Snake_Case,' do
459
+ include_context 'Upper_Snake_Case'
460
+
461
+ it_behaves_like 'be converted to Upper-Kebab-Case'
462
+ end
463
+
464
+ context 'When a string lower-kebab-case,' do
465
+ include_context 'lower-kebab-case'
466
+
467
+ it_behaves_like 'be converted to Upper-Kebab-Case'
468
+ end
469
+
470
+ context 'When a string Upper-Kebab-Case,' do
471
+ include_context 'Upper-Kebab-Case'
472
+
473
+ it_behaves_like 'be converted to Upper-Kebab-Case'
474
+ end
475
+
476
+ context 'When a string lower space case,' do
477
+ include_context 'lower space case'
478
+
479
+ it_behaves_like 'be converted to Upper-Kebab-Case'
480
+ end
481
+
482
+ context 'When a string Upper Space Case,' do
483
+ include_context 'Upper Space Case'
484
+
485
+ it_behaves_like 'be converted to Upper-Kebab-Case'
486
+ end
487
+ context 'When a string lower.dot.case,' do
488
+ include_context 'lower.dot.case'
489
+
490
+ it_behaves_like 'be converted to Upper-Kebab-Case'
491
+ end
492
+
493
+ context 'When a string Upper.Dot.Case,' do
494
+ include_context 'Upper.Dot.Case'
495
+
496
+ it_behaves_like 'be converted to Upper-Kebab-Case'
497
+ end
498
+ end
499
+
500
+
501
+ # ----------------------------------------------------------------------------
502
+ # Convert to lower space case
503
+ # ----------------------------------------------------------------------------
504
+ describe 'CONVERT TO lower space case' do
505
+ subject { string.to_lspace }
506
+
507
+ # Define shared examples.
508
+ # --------------------------------------------------------------------------
509
+ shared_examples 'be converted to lower space case' do
510
+ it { is_expected.to eq 'we are brushdown' }
511
+ end
512
+ # --------------------------------------------------------------------------
513
+
514
+ context 'When a string has one word,' do
515
+ include_context 'one word'
516
+
517
+ it { is_expected.to eq 'string' }
518
+ end
519
+
520
+ context 'When a string lowerCamelCase,' do
521
+ include_context 'lowerCamelCase'
522
+
523
+ it_behaves_like 'be converted to lower space case'
524
+ end
525
+
526
+ context 'When a string UpperCamelCase,' do
527
+ include_context 'UpperCamelCase'
528
+
529
+ it_behaves_like 'be converted to lower space case'
530
+ end
531
+
532
+ context 'When a string lower_snake_case,' do
533
+ include_context 'lower_snake_case'
534
+
535
+ it_behaves_like 'be converted to lower space case'
536
+ end
537
+
538
+ context 'When a string Upper_Snake_Case,' do
539
+ include_context 'Upper_Snake_Case'
540
+
541
+ it_behaves_like 'be converted to lower space case'
542
+ end
543
+
544
+ context 'When a string lower-kebab-case,' do
545
+ include_context 'lower-kebab-case'
546
+
547
+ it_behaves_like 'be converted to lower space case'
548
+ end
549
+
550
+ context 'When a string Upper-Kebab-Case,' do
551
+ include_context 'Upper-Kebab-Case'
552
+
553
+ it_behaves_like 'be converted to lower space case'
554
+ end
555
+
556
+ context 'When a string lower space case,' do
557
+ include_context 'lower space case'
558
+
559
+ it_behaves_like 'be converted to lower space case'
560
+ end
561
+
562
+ context 'When a string Upper Space Case,' do
563
+ include_context 'Upper Space Case'
564
+
565
+ it_behaves_like 'be converted to lower space case'
566
+ end
567
+ context 'When a string lower.dot.case,' do
568
+ include_context 'lower.dot.case'
569
+
570
+ it_behaves_like 'be converted to lower space case'
571
+ end
572
+
573
+ context 'When a string Upper.Dot.Case,' do
574
+ include_context 'Upper.Dot.Case'
575
+
576
+ it_behaves_like 'be converted to lower space case'
577
+ end
578
+ end
579
+
580
+
581
+ # ----------------------------------------------------------------------------
582
+ # Convert to Upper Space Case
583
+ # ----------------------------------------------------------------------------
584
+ describe 'CONVERT TO Upper Space Case' do
585
+ subject { string.to_uspace }
586
+
587
+ # Define shared examples.
588
+ # --------------------------------------------------------------------------
589
+ shared_examples 'be converted to Upper Space Case' do
590
+ it { is_expected.to eq 'We Are Brushdown' }
591
+ end
592
+ # --------------------------------------------------------------------------
593
+
594
+ context 'When a string has one word,' do
595
+ include_context 'one word'
596
+
597
+ it { is_expected.to eq 'String' }
598
+ end
599
+
600
+ context 'When a string lowerCamelCase,' do
601
+ include_context 'lowerCamelCase'
602
+
603
+ it_behaves_like 'be converted to Upper Space Case'
604
+ end
605
+
606
+ context 'When a string UpperCamelCase,' do
607
+ include_context 'UpperCamelCase'
608
+
609
+ it_behaves_like 'be converted to Upper Space Case'
610
+ end
611
+
612
+ context 'When a string lower_snake_case,' do
613
+ include_context 'lower_snake_case'
614
+
615
+ it_behaves_like 'be converted to Upper Space Case'
616
+ end
617
+
618
+ context 'When a string Upper_Snake_Case,' do
619
+ include_context 'Upper_Snake_Case'
620
+
621
+ it_behaves_like 'be converted to Upper Space Case'
622
+ end
623
+
624
+ context 'When a string lower-kebab-case,' do
625
+ include_context 'lower-kebab-case'
626
+
627
+ it_behaves_like 'be converted to Upper Space Case'
628
+ end
629
+
630
+ context 'When a string Upper-Kebab-Case,' do
631
+ include_context 'Upper-Kebab-Case'
632
+
633
+ it_behaves_like 'be converted to Upper Space Case'
634
+ end
635
+
636
+ context 'When a string lower space case,' do
637
+ include_context 'lower space case'
638
+
639
+ it_behaves_like 'be converted to Upper Space Case'
640
+ end
641
+
642
+ context 'When a string Upper Space Case,' do
643
+ include_context 'Upper Space Case'
644
+
645
+ it_behaves_like 'be converted to Upper Space Case'
646
+ end
647
+ context 'When a string lower.dot.case,' do
648
+ include_context 'lower.dot.case'
649
+
650
+ it_behaves_like 'be converted to Upper Space Case'
651
+ end
652
+
653
+ context 'When a string Upper.Dot.Case,' do
654
+ include_context 'Upper.Dot.Case'
655
+
656
+ it_behaves_like 'be converted to Upper Space Case'
657
+ end
658
+ end
659
+
660
+
661
+ # ----------------------------------------------------------------------------
662
+ # Convert to lower.dot.case
663
+ # ----------------------------------------------------------------------------
664
+ describe 'CONVERT TO lower.dot.case' do
665
+ subject { string.to_ldot }
666
+
667
+ # Define shared examples.
668
+ # --------------------------------------------------------------------------
669
+ shared_examples 'be converted to lower.dot.case' do
670
+ it { is_expected.to eq 'we.are.brushdown' }
671
+ end
672
+ # --------------------------------------------------------------------------
673
+
674
+ context 'When a string has one word,' do
675
+ include_context 'one word'
676
+
677
+ it { is_expected.to eq 'string' }
678
+ end
679
+
680
+ context 'When a string lowerCamelCase,' do
681
+ include_context 'lowerCamelCase'
682
+
683
+ it_behaves_like 'be converted to lower.dot.case'
684
+ end
685
+
686
+ context 'When a string UpperCamelCase,' do
687
+ include_context 'UpperCamelCase'
688
+
689
+ it_behaves_like 'be converted to lower.dot.case'
690
+ end
691
+
692
+ context 'When a string lower_snake_case,' do
693
+ include_context 'lower_snake_case'
694
+
695
+ it_behaves_like 'be converted to lower.dot.case'
696
+ end
697
+
698
+ context 'When a string Upper_Snake_Case,' do
699
+ include_context 'Upper_Snake_Case'
700
+
701
+ it_behaves_like 'be converted to lower.dot.case'
702
+ end
703
+
704
+ context 'When a string lower-kebab-case,' do
705
+ include_context 'lower-kebab-case'
706
+
707
+ it_behaves_like 'be converted to lower.dot.case'
708
+ end
709
+
710
+ context 'When a string Upper-Kebab-Case,' do
711
+ include_context 'Upper-Kebab-Case'
712
+
713
+ it_behaves_like 'be converted to lower.dot.case'
714
+ end
715
+
716
+ context 'When a string lower space case,' do
717
+ include_context 'lower space case'
718
+
719
+ it_behaves_like 'be converted to lower.dot.case'
720
+ end
721
+
722
+ context 'When a string Upper Space Case,' do
723
+ include_context 'Upper Space Case'
724
+
725
+ it_behaves_like 'be converted to lower.dot.case'
726
+ end
727
+ context 'When a string lower.dot.case,' do
728
+ include_context 'lower.dot.case'
729
+
730
+ it_behaves_like 'be converted to lower.dot.case'
731
+ end
732
+
733
+ context 'When a string Upper.Dot.Case,' do
734
+ include_context 'Upper.Dot.Case'
735
+
736
+ it_behaves_like 'be converted to lower.dot.case'
737
+ end
738
+ end
739
+
740
+
741
+ # ----------------------------------------------------------------------------
742
+ # Convert to Upper.Dot.Case
743
+ # ----------------------------------------------------------------------------
744
+ describe 'CONVERT TO Upper.Dot.Case' do
745
+ subject { string.to_udot }
746
+
747
+ # Define shared examples.
748
+ # --------------------------------------------------------------------------
749
+ shared_examples 'be converted to Upper.Dot.Case' do
750
+ it { is_expected.to eq 'We.Are.Brushdown' }
751
+ end
752
+ # --------------------------------------------------------------------------
753
+
754
+ context 'When a string has one word,' do
755
+ include_context 'one word'
756
+
757
+ it { is_expected.to eq 'String' }
758
+ end
759
+
760
+ context 'When a string lowerCamelCase,' do
761
+ include_context 'lowerCamelCase'
762
+
763
+ it_behaves_like 'be converted to Upper.Dot.Case'
764
+ end
765
+
766
+ context 'When a string UpperCamelCase,' do
767
+ include_context 'UpperCamelCase'
768
+
769
+ it_behaves_like 'be converted to Upper.Dot.Case'
770
+ end
771
+
772
+ context 'When a string lower_snake_case,' do
773
+ include_context 'lower_snake_case'
774
+
775
+ it_behaves_like 'be converted to Upper.Dot.Case'
776
+ end
777
+
778
+ context 'When a string Upper_Snake_Case,' do
779
+ include_context 'Upper_Snake_Case'
780
+
781
+ it_behaves_like 'be converted to Upper.Dot.Case'
782
+ end
783
+
784
+ context 'When a string lower-kebab-case,' do
785
+ include_context 'lower-kebab-case'
786
+
787
+ it_behaves_like 'be converted to Upper.Dot.Case'
788
+ end
789
+
790
+ context 'When a string Upper-Kebab-Case,' do
791
+ include_context 'Upper-Kebab-Case'
792
+
793
+ it_behaves_like 'be converted to Upper.Dot.Case'
794
+ end
795
+
796
+ context 'When a string lower space case,' do
797
+ include_context 'lower space case'
798
+
799
+ it_behaves_like 'be converted to Upper.Dot.Case'
800
+ end
801
+
802
+ context 'When a string Upper Space Case,' do
803
+ include_context 'Upper Space Case'
804
+
805
+ it_behaves_like 'be converted to Upper.Dot.Case'
806
+ end
807
+ context 'When a string lower.dot.case,' do
808
+ include_context 'lower.dot.case'
809
+
810
+ it_behaves_like 'be converted to Upper.Dot.Case'
811
+ end
812
+
813
+ context 'When a string Upper.Dot.Case,' do
814
+ include_context 'Upper.Dot.Case'
815
+
816
+ it_behaves_like 'be converted to Upper.Dot.Case'
817
+ end
818
+ end
819
+
820
+
821
+ # ----------------------------------------------------------------------------
822
+ # Split string according to camel case
823
+ # ----------------------------------------------------------------------------
824
+ describe 'SPLIT ACCORDING TO CAMEL CASE' do
825
+ let(:string) { nil }
826
+ subject { string.split_camel }
827
+
828
+ context 'When string is Upper Camel Case,' do
829
+ let!(:string) { 'ThisIsWord' }
830
+ it { is_expected.to eq ['This', 'Is', 'Word'] }
831
+ end
832
+
833
+ context 'When string is Lower Camel Case,' do
834
+ let!(:string) { 'thisIsWord' }
835
+ it { is_expected.to eq ['this', 'Is', 'Word'] }
836
+ end
837
+
838
+ context 'When string is not Camel Case,' do
839
+ let!(:string) { 'thisisword' }
840
+ it { is_expected.to eq ['thisisword'] }
841
+ end
842
+ end
843
+
844
+
845
+ # ----------------------------------------------------------------------------
846
+ # Check is_upper?
847
+ # ----------------------------------------------------------------------------
848
+ describe 'CHECK is_upper?' do
849
+ let(:character) { nil }
850
+ subject { character.is_upper? }
851
+
852
+ context 'when a character is upper case,' do
853
+ let(:character) { 'C' }
854
+ it { is_expected.to eq true }
855
+ end
856
+
857
+ context 'when a character is lower case,' do
858
+ let(:character) { 'c' }
859
+ it { is_expected.to eq false }
860
+ end
861
+ end
862
+
863
+
864
+ # ----------------------------------------------------------------------------
865
+ # Check is_lower?
866
+ # ----------------------------------------------------------------------------
867
+ describe 'CHECK is_lower?' do
868
+ let(:character) { nil }
869
+ subject { character.is_lower? }
870
+
871
+ context 'when a character is lower case,' do
872
+ let(:character) { 'c' }
873
+ it { is_expected.to eq true }
874
+ end
875
+
876
+ context 'when a character is uppser case,' do
877
+ let(:character) { 'C' }
878
+ it { is_expected.to eq false }
879
+ end
880
+ end
881
+
882
+
883
+ # ----------------------------------------------------------------------------
884
+ # Make first character lower case
885
+ # ----------------------------------------------------------------------------
886
+ describe 'MAKE FIRST CHARACTER LOWER CASE' do
887
+ let(:string) { nil }
888
+ subject { string.make_head_lower }
889
+
890
+ context 'When first character is Upper Case,' do
891
+ let(:string) { 'ThisIsString' }
892
+ it { is_expected.to eq 'thisIsString' }
893
+ end
894
+
895
+ context 'When first character is Lower Case,' do
896
+ let(:string) { 'thisIsString' }
897
+ it { is_expected.to eq 'thisIsString' }
898
+ end
899
+ end
900
+
901
+ end