rspec_piccolo 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +30 -15
- data/bin/piccolo +31 -30
- data/lib/rspec_piccolo.rb +227 -158
- data/lib/rspec_piccolo/version.rb +3 -3
- data/spec/rspec_piccolo_spec.rb +837 -747
- data/spec/spec_helper.rb +8 -8
- data/test.txt +1 -0
- metadata +15 -14
@@ -1,3 +1,3 @@
|
|
1
|
-
module RSpecPiccolo
|
2
|
-
VERSION =
|
3
|
-
end
|
1
|
+
module RSpecPiccolo
|
2
|
+
VERSION = '0.0.7'
|
3
|
+
end
|
data/spec/rspec_piccolo_spec.rb
CHANGED
@@ -1,747 +1,837 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
|
6
|
-
describe RSpecPiccolo::Core do
|
7
|
-
context :generate do
|
8
|
-
CASE1_EXPECTED
|
9
|
-
# encoding: utf-8
|
10
|
-
require "spec_helper"
|
11
|
-
require "hoge_core"
|
12
|
-
|
13
|
-
describe Hoge::Core do
|
14
|
-
|
15
|
-
|
16
|
-
end
|
17
|
-
EOS
|
18
|
-
|
19
|
-
CASE2_EXPECTED
|
20
|
-
# encoding: utf-8
|
21
|
-
require "spec_helper"
|
22
|
-
require "hoge_core"
|
23
|
-
|
24
|
-
describe Hoge::Core do
|
25
|
-
|
26
|
-
context :method1 do
|
27
|
-
cases = [
|
28
|
-
{
|
29
|
-
case_no: 1,
|
30
|
-
case_title: "case_title",
|
31
|
-
expected: "expected",
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
#
|
45
|
-
#
|
46
|
-
|
47
|
-
|
48
|
-
#
|
49
|
-
#
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
}
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
#
|
84
|
-
|
85
|
-
|
86
|
-
# --
|
87
|
-
# TODO: implement
|
88
|
-
# actual
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
#
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
#
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
#
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
{
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'rspec_piccolo'
|
4
|
+
require 'fileutils'
|
5
|
+
|
6
|
+
describe RSpecPiccolo::Core do
|
7
|
+
context :generate do
|
8
|
+
CASE1_EXPECTED = <<-EOS
|
9
|
+
# encoding: utf-8
|
10
|
+
require "spec_helper"
|
11
|
+
require "hoge_core"
|
12
|
+
|
13
|
+
describe Hoge::Core do
|
14
|
+
|
15
|
+
|
16
|
+
end
|
17
|
+
EOS
|
18
|
+
|
19
|
+
CASE2_EXPECTED = <<-EOS
|
20
|
+
# encoding: utf-8
|
21
|
+
require "spec_helper"
|
22
|
+
require "hoge_core"
|
23
|
+
|
24
|
+
describe Hoge::Core do
|
25
|
+
|
26
|
+
context :method1 do
|
27
|
+
cases = [
|
28
|
+
{
|
29
|
+
case_no: 1,
|
30
|
+
case_title: "case_title",
|
31
|
+
expected: "expected",
|
32
|
+
},
|
33
|
+
]
|
34
|
+
|
35
|
+
cases.each do |c|
|
36
|
+
it "|case_no=\#{c[:case_no]}|case_title=\#{c[:case_title]}" do
|
37
|
+
begin
|
38
|
+
case_before c
|
39
|
+
|
40
|
+
# -- given --
|
41
|
+
hoge_core = Hoge::Core.new
|
42
|
+
|
43
|
+
# -- when --
|
44
|
+
# TODO: implement execute code
|
45
|
+
# actual = hoge_core.method1
|
46
|
+
|
47
|
+
# -- then --
|
48
|
+
# TODO: implement assertion code
|
49
|
+
# expect(actual).to eq(c[:expected])
|
50
|
+
ensure
|
51
|
+
case_after c
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def case_before(c)
|
56
|
+
# implement each case before
|
57
|
+
end
|
58
|
+
|
59
|
+
def case_after(c)
|
60
|
+
# implement each case after
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context :method2 do
|
66
|
+
cases = [
|
67
|
+
{
|
68
|
+
case_no: 1,
|
69
|
+
case_title: "case_title",
|
70
|
+
expected: "expected",
|
71
|
+
},
|
72
|
+
]
|
73
|
+
|
74
|
+
cases.each do |c|
|
75
|
+
it "|case_no=\#{c[:case_no]}|case_title=\#{c[:case_title]}" do
|
76
|
+
begin
|
77
|
+
case_before c
|
78
|
+
|
79
|
+
# -- given --
|
80
|
+
hoge_core = Hoge::Core.new
|
81
|
+
|
82
|
+
# -- when --
|
83
|
+
# TODO: implement execute code
|
84
|
+
# actual = hoge_core.method2
|
85
|
+
|
86
|
+
# -- then --
|
87
|
+
# TODO: implement assertion code
|
88
|
+
# expect(actual).to eq(c[:expected])
|
89
|
+
ensure
|
90
|
+
case_after c
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def case_before(c)
|
95
|
+
# implement each case before
|
96
|
+
end
|
97
|
+
|
98
|
+
def case_after(c)
|
99
|
+
# implement each case after
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
EOS
|
105
|
+
|
106
|
+
CASE3_EXPECTED = <<-EOS
|
107
|
+
# encoding: utf-8
|
108
|
+
require "spec_helper"
|
109
|
+
require "only_class"
|
110
|
+
|
111
|
+
describe OnlyClass do
|
112
|
+
|
113
|
+
context :method1 do
|
114
|
+
cases = [
|
115
|
+
{
|
116
|
+
case_no: 1,
|
117
|
+
case_title: "case_title",
|
118
|
+
expected: "expected",
|
119
|
+
},
|
120
|
+
]
|
121
|
+
|
122
|
+
cases.each do |c|
|
123
|
+
it "|case_no=\#{c[:case_no]}|case_title=\#{c[:case_title]}" do
|
124
|
+
begin
|
125
|
+
case_before c
|
126
|
+
|
127
|
+
# -- given --
|
128
|
+
only_class = OnlyClass.new
|
129
|
+
|
130
|
+
# -- when --
|
131
|
+
# TODO: implement execute code
|
132
|
+
# actual = only_class.method1
|
133
|
+
|
134
|
+
# -- then --
|
135
|
+
# TODO: implement assertion code
|
136
|
+
# expect(actual).to eq(c[:expected])
|
137
|
+
ensure
|
138
|
+
case_after c
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
def case_before(c)
|
143
|
+
# implement each case before
|
144
|
+
end
|
145
|
+
|
146
|
+
def case_after(c)
|
147
|
+
# implement each case after
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
context :method2 do
|
153
|
+
cases = [
|
154
|
+
{
|
155
|
+
case_no: 1,
|
156
|
+
case_title: "case_title",
|
157
|
+
expected: "expected",
|
158
|
+
},
|
159
|
+
]
|
160
|
+
|
161
|
+
cases.each do |c|
|
162
|
+
it "|case_no=\#{c[:case_no]}|case_title=\#{c[:case_title]}" do
|
163
|
+
begin
|
164
|
+
case_before c
|
165
|
+
|
166
|
+
# -- given --
|
167
|
+
only_class = OnlyClass.new
|
168
|
+
|
169
|
+
# -- when --
|
170
|
+
# TODO: implement execute code
|
171
|
+
# actual = only_class.method2
|
172
|
+
|
173
|
+
# -- then --
|
174
|
+
# TODO: implement assertion code
|
175
|
+
# expect(actual).to eq(c[:expected])
|
176
|
+
ensure
|
177
|
+
case_after c
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
def case_before(c)
|
182
|
+
# implement each case before
|
183
|
+
end
|
184
|
+
|
185
|
+
def case_after(c)
|
186
|
+
# implement each case after
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
191
|
+
EOS
|
192
|
+
|
193
|
+
CASE4_EXPECTED = <<-EOS
|
194
|
+
# encoding: utf-8
|
195
|
+
require "spec_helper"
|
196
|
+
require "some_dir/hoge_core"
|
197
|
+
|
198
|
+
describe Hoge::Core do
|
199
|
+
|
200
|
+
context :method1 do
|
201
|
+
cases = [
|
202
|
+
{
|
203
|
+
case_no: 1,
|
204
|
+
case_title: "case_title",
|
205
|
+
expected: "expected",
|
206
|
+
},
|
207
|
+
]
|
208
|
+
|
209
|
+
cases.each do |c|
|
210
|
+
it "|case_no=\#{c[:case_no]}|case_title=\#{c[:case_title]}" do
|
211
|
+
begin
|
212
|
+
case_before c
|
213
|
+
|
214
|
+
# -- given --
|
215
|
+
hoge_core = Hoge::Core.new
|
216
|
+
|
217
|
+
# -- when --
|
218
|
+
# TODO: implement execute code
|
219
|
+
# actual = hoge_core.method1
|
220
|
+
|
221
|
+
# -- then --
|
222
|
+
# TODO: implement assertion code
|
223
|
+
# expect(actual).to eq(c[:expected])
|
224
|
+
ensure
|
225
|
+
case_after c
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
def case_before(c)
|
230
|
+
# implement each case before
|
231
|
+
end
|
232
|
+
|
233
|
+
def case_after(c)
|
234
|
+
# implement each case after
|
235
|
+
end
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
context :method2 do
|
240
|
+
cases = [
|
241
|
+
{
|
242
|
+
case_no: 1,
|
243
|
+
case_title: "case_title",
|
244
|
+
expected: "expected",
|
245
|
+
},
|
246
|
+
]
|
247
|
+
|
248
|
+
cases.each do |c|
|
249
|
+
it "|case_no=\#{c[:case_no]}|case_title=\#{c[:case_title]}" do
|
250
|
+
begin
|
251
|
+
case_before c
|
252
|
+
|
253
|
+
# -- given --
|
254
|
+
hoge_core = Hoge::Core.new
|
255
|
+
|
256
|
+
# -- when --
|
257
|
+
# TODO: implement execute code
|
258
|
+
# actual = hoge_core.method2
|
259
|
+
|
260
|
+
# -- then --
|
261
|
+
# TODO: implement assertion code
|
262
|
+
# expect(actual).to eq(c[:expected])
|
263
|
+
ensure
|
264
|
+
case_after c
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
def case_before(c)
|
269
|
+
# implement each case before
|
270
|
+
end
|
271
|
+
|
272
|
+
def case_after(c)
|
273
|
+
# implement each case after
|
274
|
+
end
|
275
|
+
end
|
276
|
+
end
|
277
|
+
end
|
278
|
+
EOS
|
279
|
+
|
280
|
+
CASE9_EXPECTED = <<-EOS
|
281
|
+
# encoding: utf-8
|
282
|
+
require "spec_helper"
|
283
|
+
require "some_dir/some_sub_dir/hoge_core"
|
284
|
+
|
285
|
+
describe Hoge::Core do
|
286
|
+
|
287
|
+
context :method1 do
|
288
|
+
cases = [
|
289
|
+
{
|
290
|
+
case_no: 1,
|
291
|
+
case_title: "case_title",
|
292
|
+
expected: "expected",
|
293
|
+
},
|
294
|
+
]
|
295
|
+
|
296
|
+
cases.each do |c|
|
297
|
+
it "|case_no=\#{c[:case_no]}|case_title=\#{c[:case_title]}" do
|
298
|
+
begin
|
299
|
+
case_before c
|
300
|
+
|
301
|
+
# -- given --
|
302
|
+
hoge_core = Hoge::Core.new
|
303
|
+
|
304
|
+
# -- when --
|
305
|
+
# TODO: implement execute code
|
306
|
+
# actual = hoge_core.method1
|
307
|
+
|
308
|
+
# -- then --
|
309
|
+
# TODO: implement assertion code
|
310
|
+
# expect(actual).to eq(c[:expected])
|
311
|
+
ensure
|
312
|
+
case_after c
|
313
|
+
end
|
314
|
+
end
|
315
|
+
|
316
|
+
def case_before(c)
|
317
|
+
# implement each case before
|
318
|
+
end
|
319
|
+
|
320
|
+
def case_after(c)
|
321
|
+
# implement each case after
|
322
|
+
end
|
323
|
+
end
|
324
|
+
end
|
325
|
+
|
326
|
+
context :method2 do
|
327
|
+
cases = [
|
328
|
+
{
|
329
|
+
case_no: 1,
|
330
|
+
case_title: "case_title",
|
331
|
+
expected: "expected",
|
332
|
+
},
|
333
|
+
]
|
334
|
+
|
335
|
+
cases.each do |c|
|
336
|
+
it "|case_no=\#{c[:case_no]}|case_title=\#{c[:case_title]}" do
|
337
|
+
begin
|
338
|
+
case_before c
|
339
|
+
|
340
|
+
# -- given --
|
341
|
+
hoge_core = Hoge::Core.new
|
342
|
+
|
343
|
+
# -- when --
|
344
|
+
# TODO: implement execute code
|
345
|
+
# actual = hoge_core.method2
|
346
|
+
|
347
|
+
# -- then --
|
348
|
+
# TODO: implement assertion code
|
349
|
+
# expect(actual).to eq(c[:expected])
|
350
|
+
ensure
|
351
|
+
case_after c
|
352
|
+
end
|
353
|
+
end
|
354
|
+
|
355
|
+
def case_before(c)
|
356
|
+
# implement each case before
|
357
|
+
end
|
358
|
+
|
359
|
+
def case_after(c)
|
360
|
+
# implement each case after
|
361
|
+
end
|
362
|
+
end
|
363
|
+
end
|
364
|
+
end
|
365
|
+
EOS
|
366
|
+
|
367
|
+
CASE10_EXPECTED = <<-EOS
|
368
|
+
# encoding: utf-8
|
369
|
+
require "spec_helper"
|
370
|
+
require "hoge_core"
|
371
|
+
|
372
|
+
describe Hoge::Core do
|
373
|
+
REPORT = "rspec_report"
|
374
|
+
DIRS = File.path(__FILE__).gsub(/^.*\\/spec\\//, '').gsub(File.basename(__FILE__), '')
|
375
|
+
OUT_DIR = "./#\{REPORT}/#\{DIRS}"
|
376
|
+
REPORT_NAME = report_name = File.basename(__FILE__, ".rb")
|
377
|
+
REPORT_FILE = "#\{OUT_DIR}#\{REPORT_NAME}.tsv"
|
378
|
+
|
379
|
+
mkspec_report = Proc.new do
|
380
|
+
Dir.mkdir(REPORT) unless File.exists?(REPORT)
|
381
|
+
FileUtils.mkdir_p(OUT_DIR) unless File.exists?(OUT_DIR)
|
382
|
+
File.open(REPORT_FILE, "w") {|f|f.puts "method\\tcase\\ttitle\\tsuccess\\/failure"}
|
383
|
+
end.call
|
384
|
+
|
385
|
+
success = Proc.new {|c|File.open(REPORT_FILE, "a") {|f|f.puts "\\tsuccess"}}
|
386
|
+
failure = Proc.new {|c|File.open(REPORT_FILE, "a") {|f|f.puts "\\tfailure"}}
|
387
|
+
|
388
|
+
context :method1 do
|
389
|
+
cases = [
|
390
|
+
{
|
391
|
+
case_no: 1,
|
392
|
+
case_title: "case_title",
|
393
|
+
expected: "expected",
|
394
|
+
success_hook: success,
|
395
|
+
failure_hook: failure
|
396
|
+
},
|
397
|
+
]
|
398
|
+
|
399
|
+
cases.each do |c|
|
400
|
+
it "|case_no=\#{c[:case_no]}|case_title=\#{c[:case_title]}" do
|
401
|
+
begin
|
402
|
+
case_before c
|
403
|
+
|
404
|
+
# -- given --
|
405
|
+
hoge_core = Hoge::Core.new
|
406
|
+
|
407
|
+
# -- when --
|
408
|
+
# TODO: implement execute code
|
409
|
+
# actual = hoge_core.method1
|
410
|
+
|
411
|
+
# -- then --
|
412
|
+
# TODO: implement assertion code
|
413
|
+
# ret = expect(actual).to eq(c[:expected])
|
414
|
+
ensure
|
415
|
+
case_after c
|
416
|
+
sf_hook = ret ? c[:success_hook] : c[:failure_hook]
|
417
|
+
sf_hook.call(c)
|
418
|
+
end
|
419
|
+
end
|
420
|
+
|
421
|
+
def case_before(c)
|
422
|
+
# implement each case before
|
423
|
+
File.open(REPORT_FILE, "a") {|f|f.print "method1\\t#\{c[:case_no]}\\t#\{c[:case_title]}"}
|
424
|
+
end
|
425
|
+
|
426
|
+
def case_after(c)
|
427
|
+
# implement each case after
|
428
|
+
end
|
429
|
+
end
|
430
|
+
end
|
431
|
+
|
432
|
+
context :method2 do
|
433
|
+
cases = [
|
434
|
+
{
|
435
|
+
case_no: 1,
|
436
|
+
case_title: "case_title",
|
437
|
+
expected: "expected",
|
438
|
+
success_hook: success,
|
439
|
+
failure_hook: failure
|
440
|
+
},
|
441
|
+
]
|
442
|
+
|
443
|
+
cases.each do |c|
|
444
|
+
it "|case_no=\#{c[:case_no]}|case_title=\#{c[:case_title]}" do
|
445
|
+
begin
|
446
|
+
case_before c
|
447
|
+
|
448
|
+
# -- given --
|
449
|
+
hoge_core = Hoge::Core.new
|
450
|
+
|
451
|
+
# -- when --
|
452
|
+
# TODO: implement execute code
|
453
|
+
# actual = hoge_core.method2
|
454
|
+
|
455
|
+
# -- then --
|
456
|
+
# TODO: implement assertion code
|
457
|
+
# ret = expect(actual).to eq(c[:expected])
|
458
|
+
ensure
|
459
|
+
case_after c
|
460
|
+
sf_hook = ret ? c[:success_hook] : c[:failure_hook]
|
461
|
+
sf_hook.call(c)
|
462
|
+
end
|
463
|
+
end
|
464
|
+
|
465
|
+
def case_before(c)
|
466
|
+
# implement each case before
|
467
|
+
File.open(REPORT_FILE, "a") {|f|f.print "method2\\t#\{c[:case_no]}\\t#\{c[:case_title]}"}
|
468
|
+
end
|
469
|
+
|
470
|
+
def case_after(c)
|
471
|
+
# implement each case after
|
472
|
+
end
|
473
|
+
end
|
474
|
+
end
|
475
|
+
end
|
476
|
+
EOS
|
477
|
+
|
478
|
+
CASE11_EXPECTED = <<-EOS
|
479
|
+
# encoding: utf-8
|
480
|
+
require "spec_helper"
|
481
|
+
require "hoge_core"
|
482
|
+
|
483
|
+
describe Hoge::Core do
|
484
|
+
|
485
|
+
context :method1 do
|
486
|
+
cases = [
|
487
|
+
{
|
488
|
+
case_no: 1,
|
489
|
+
case_title: "case_title",
|
490
|
+
expected: "expected",
|
491
|
+
},
|
492
|
+
]
|
493
|
+
|
494
|
+
cases.each do |c|
|
495
|
+
it "|case_no=\#{c[:case_no]}|case_title=\#{c[:case_title]}" do
|
496
|
+
begin
|
497
|
+
case_before c
|
498
|
+
|
499
|
+
# -- given --
|
500
|
+
hoge_core = Hoge::Core.new
|
501
|
+
|
502
|
+
# -- when --
|
503
|
+
# TODO: implement execute code
|
504
|
+
# actual = hoge_core.method1
|
505
|
+
|
506
|
+
# -- then --
|
507
|
+
# TODO: implement assertion code
|
508
|
+
# expect(actual).to eq(c[:expected])
|
509
|
+
ensure
|
510
|
+
case_after c
|
511
|
+
end
|
512
|
+
end
|
513
|
+
|
514
|
+
def case_before(c)
|
515
|
+
# implement each case before
|
516
|
+
end
|
517
|
+
|
518
|
+
def case_after(c)
|
519
|
+
# implement each case after
|
520
|
+
end
|
521
|
+
end
|
522
|
+
end
|
523
|
+
|
524
|
+
context :method2 do
|
525
|
+
cases = [
|
526
|
+
{
|
527
|
+
case_no: 1,
|
528
|
+
case_title: "case_title",
|
529
|
+
expected: "expected",
|
530
|
+
},
|
531
|
+
]
|
532
|
+
|
533
|
+
cases.each do |c|
|
534
|
+
it "|case_no=\#{c[:case_no]}|case_title=\#{c[:case_title]}" do
|
535
|
+
begin
|
536
|
+
case_before c
|
537
|
+
|
538
|
+
# -- given --
|
539
|
+
# nothing
|
540
|
+
|
541
|
+
# -- when --
|
542
|
+
# TODO: implement execute code
|
543
|
+
# actual = Hoge::Core.method2
|
544
|
+
|
545
|
+
# -- then --
|
546
|
+
# TODO: implement assertion code
|
547
|
+
# expect(actual).to eq(c[:expected])
|
548
|
+
ensure
|
549
|
+
case_after c
|
550
|
+
end
|
551
|
+
end
|
552
|
+
|
553
|
+
def case_before(c)
|
554
|
+
# implement each case before
|
555
|
+
end
|
556
|
+
|
557
|
+
def case_after(c)
|
558
|
+
# implement each case after
|
559
|
+
end
|
560
|
+
end
|
561
|
+
end
|
562
|
+
end
|
563
|
+
EOS
|
564
|
+
|
565
|
+
|
566
|
+
CASE12_EXPECTED = <<-EOS
|
567
|
+
# encoding: utf-8
|
568
|
+
require "spec_helper"
|
569
|
+
require "some_dir/hoge_core"
|
570
|
+
|
571
|
+
describe Hoge::Core do
|
572
|
+
|
573
|
+
context :method1 do
|
574
|
+
cases = [
|
575
|
+
{
|
576
|
+
case_no: 1,
|
577
|
+
case_title: "case_title",
|
578
|
+
expected: "expected",
|
579
|
+
},
|
580
|
+
]
|
581
|
+
|
582
|
+
cases.each do |c|
|
583
|
+
it "|case_no=\#{c[:case_no]}|case_title=\#{c[:case_title]}" do
|
584
|
+
begin
|
585
|
+
case_before c
|
586
|
+
|
587
|
+
# -- given --
|
588
|
+
hoge_core = Hoge::Core.new
|
589
|
+
|
590
|
+
# -- when --
|
591
|
+
# TODO: implement execute code
|
592
|
+
# actual = hoge_core.method1
|
593
|
+
|
594
|
+
# -- then --
|
595
|
+
# TODO: implement assertion code
|
596
|
+
# expect(actual).to eq(c[:expected])
|
597
|
+
ensure
|
598
|
+
case_after c
|
599
|
+
end
|
600
|
+
end
|
601
|
+
|
602
|
+
def case_before(c)
|
603
|
+
# implement each case before
|
604
|
+
end
|
605
|
+
|
606
|
+
def case_after(c)
|
607
|
+
# implement each case after
|
608
|
+
end
|
609
|
+
end
|
610
|
+
end
|
611
|
+
|
612
|
+
context :method2 do
|
613
|
+
cases = [
|
614
|
+
{
|
615
|
+
case_no: 1,
|
616
|
+
case_title: "case_title",
|
617
|
+
expected: "expected",
|
618
|
+
},
|
619
|
+
]
|
620
|
+
|
621
|
+
cases.each do |c|
|
622
|
+
it "|case_no=\#{c[:case_no]}|case_title=\#{c[:case_title]}" do
|
623
|
+
begin
|
624
|
+
case_before c
|
625
|
+
|
626
|
+
# -- given --
|
627
|
+
# nothing
|
628
|
+
|
629
|
+
# -- when --
|
630
|
+
# TODO: implement execute code
|
631
|
+
# actual = Hoge::Core.method2
|
632
|
+
|
633
|
+
# -- then --
|
634
|
+
# TODO: implement assertion code
|
635
|
+
# expect(actual).to eq(c[:expected])
|
636
|
+
ensure
|
637
|
+
case_after c
|
638
|
+
end
|
639
|
+
end
|
640
|
+
|
641
|
+
def case_before(c)
|
642
|
+
# implement each case before
|
643
|
+
end
|
644
|
+
|
645
|
+
def case_after(c)
|
646
|
+
# implement each case after
|
647
|
+
end
|
648
|
+
end
|
649
|
+
end
|
650
|
+
end
|
651
|
+
EOS
|
652
|
+
|
653
|
+
CASE12_PRODUCT_EXPECTED = <<-EOS
|
654
|
+
# encoding: utf-8
|
655
|
+
|
656
|
+
module Hoge
|
657
|
+
class Core
|
658
|
+
def method1
|
659
|
+
# TOOD: implement your code
|
660
|
+
end
|
661
|
+
|
662
|
+
def self.method2
|
663
|
+
# TOOD: implement your code
|
664
|
+
end
|
665
|
+
end
|
666
|
+
end
|
667
|
+
EOS
|
668
|
+
|
669
|
+
cases = [
|
670
|
+
{
|
671
|
+
case_no: 1,
|
672
|
+
case_title: 'only classname',
|
673
|
+
class_name: 'Hoge::Core',
|
674
|
+
class_path: 'hoge_core',
|
675
|
+
method_names: nil,
|
676
|
+
expected_file_name: './spec/hoge_core_spec.rb',
|
677
|
+
expected_file_exists: true,
|
678
|
+
expected_contents: CASE1_EXPECTED
|
679
|
+
},
|
680
|
+
{
|
681
|
+
case_no: 2,
|
682
|
+
case_title: 'classname(with module) and method_names',
|
683
|
+
class_name: 'Hoge::Core',
|
684
|
+
class_path: 'hoge_core',
|
685
|
+
method_names: ['method1', 'method2'],
|
686
|
+
expected_file_name: './spec/hoge_core_spec.rb',
|
687
|
+
expected_file_exists: true,
|
688
|
+
expected_contents: CASE2_EXPECTED
|
689
|
+
},
|
690
|
+
{
|
691
|
+
case_no: 3,
|
692
|
+
case_title: 'classname(with no module) and method_names',
|
693
|
+
class_name: 'OnlyClass',
|
694
|
+
class_path: 'only_class',
|
695
|
+
method_names: ['method1', 'method2'],
|
696
|
+
expected_file_name: './spec/only_class_spec.rb',
|
697
|
+
expected_file_exists: true,
|
698
|
+
expected_contents: CASE3_EXPECTED
|
699
|
+
},
|
700
|
+
{
|
701
|
+
case_no: 4,
|
702
|
+
case_title: 'with directory, classname(with module) and method_names',
|
703
|
+
class_name: 'Hoge::Core',
|
704
|
+
class_path: 'some_dir/hoge_core',
|
705
|
+
del_dir: 'some_dir',
|
706
|
+
method_names: ['method1', 'method2'],
|
707
|
+
expected_file_name: './spec/some_dir/hoge_core_spec.rb',
|
708
|
+
expected_file_exists: true,
|
709
|
+
expected_contents: CASE4_EXPECTED
|
710
|
+
},
|
711
|
+
{
|
712
|
+
case_no: 5,
|
713
|
+
case_title: 'nil_class',
|
714
|
+
class_name: nil,
|
715
|
+
class_path: 'some_dir/hoge_core',
|
716
|
+
method_names: ['method1'],
|
717
|
+
expect_error: true
|
718
|
+
},
|
719
|
+
{
|
720
|
+
case_no: 6,
|
721
|
+
case_title: 'empty_class',
|
722
|
+
class_name: '',
|
723
|
+
class_path: 'empty_class',
|
724
|
+
method_names: ['method1'],
|
725
|
+
expect_error: true
|
726
|
+
},
|
727
|
+
{
|
728
|
+
case_no: 7,
|
729
|
+
case_title: 'nil_class_path',
|
730
|
+
class_name: 'nil_class_path',
|
731
|
+
class_path: nil,
|
732
|
+
method_names: ['method1'],
|
733
|
+
expect_error: true
|
734
|
+
},
|
735
|
+
{
|
736
|
+
case_no: 8,
|
737
|
+
case_title: 'empty_class_path',
|
738
|
+
class_name: 'empty_class_path',
|
739
|
+
class_path: '',
|
740
|
+
method_names: ['method1'],
|
741
|
+
expect_error: true
|
742
|
+
},
|
743
|
+
{
|
744
|
+
case_no: 9,
|
745
|
+
case_title: 'with two directories, classname(with module) and method_names',
|
746
|
+
class_name: 'Hoge::Core',
|
747
|
+
class_path: 'some_dir/some_sub_dir/hoge_core',
|
748
|
+
del_dir: 'some_dir',
|
749
|
+
method_names: ['method1', 'method2'],
|
750
|
+
expected_file_name: './spec/some_dir/some_sub_dir/hoge_core_spec.rb',
|
751
|
+
expected_file_exists: true,
|
752
|
+
expected_contents: CASE9_EXPECTED
|
753
|
+
},
|
754
|
+
{
|
755
|
+
case_no: 10,
|
756
|
+
case_title: 'classname(with module) and method_names reportable',
|
757
|
+
class_name: 'Hoge::Core',
|
758
|
+
class_path: 'hoge_core',
|
759
|
+
method_names: ['method1', 'method2'],
|
760
|
+
reportable: true,
|
761
|
+
expected_file_name: './spec/hoge_core_spec.rb',
|
762
|
+
expected_file_exists: true,
|
763
|
+
expected_contents: CASE10_EXPECTED
|
764
|
+
},
|
765
|
+
{
|
766
|
+
case_no: 11,
|
767
|
+
case_title: 'classname(with module) and method_names(instance method, class method)',
|
768
|
+
class_name: 'Hoge::Core',
|
769
|
+
class_path: 'hoge_core',
|
770
|
+
method_names: ['method1', 'method2@c'],
|
771
|
+
expected_file_name: './spec/hoge_core_spec.rb',
|
772
|
+
expected_file_exists: true,
|
773
|
+
expected_contents: CASE11_EXPECTED
|
774
|
+
},
|
775
|
+
{
|
776
|
+
case_no: 12,
|
777
|
+
case_title: 'classname(with module) and method_names(instance method, class method) and product code output',
|
778
|
+
class_name: 'Hoge::Core',
|
779
|
+
class_path: 'some_dir/hoge_core',
|
780
|
+
method_names: ['method1', 'method2@c'],
|
781
|
+
productcode: true,
|
782
|
+
expected_file_name: './spec/some_dir/hoge_core_spec.rb',
|
783
|
+
expected_file_exists: true,
|
784
|
+
expected_product_file_name: './lib/some_dir/hoge_core.rb',
|
785
|
+
expected_product_file_exists: true,
|
786
|
+
expected_contents: CASE12_EXPECTED,
|
787
|
+
expected_product_contents: CASE12_PRODUCT_EXPECTED
|
788
|
+
},
|
789
|
+
]
|
790
|
+
|
791
|
+
cases.each do |c|
|
792
|
+
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
|
793
|
+
begin
|
794
|
+
case_before c
|
795
|
+
|
796
|
+
# -- given --
|
797
|
+
piccolo = RSpecPiccolo::Core.new
|
798
|
+
options = {}
|
799
|
+
options[:reportable] = c[:reportable]
|
800
|
+
options[:productcode] = c[:productcode]
|
801
|
+
|
802
|
+
# -- when --
|
803
|
+
if c[:expect_error]
|
804
|
+
lambda { piccolo.generate(c[:class_name], c[:class_path], c[:method_names], options) }.should raise_error(RSpecPiccolo::RSpecPiccoloError)
|
805
|
+
next
|
806
|
+
end
|
807
|
+
piccolo.generate(c[:class_name], c[:class_path], c[:method_names], options)
|
808
|
+
|
809
|
+
# -- then --
|
810
|
+
expect(File.exists?(c[:expected_file_name])).to be_true
|
811
|
+
actual = File.open(c[:expected_file_name]) { |f|f.read }
|
812
|
+
expect(actual).to eq(c[:expected_contents])
|
813
|
+
if c[:productcode]
|
814
|
+
expect(File.exists?(c[:expected_product_file_name])).to be_true
|
815
|
+
actual = File.open(c[:expected_product_file_name]) { |f|f.read }
|
816
|
+
expect(actual).to eq(c[:expected_product_contents])
|
817
|
+
end
|
818
|
+
ensure
|
819
|
+
case_after c
|
820
|
+
end
|
821
|
+
end
|
822
|
+
|
823
|
+
def case_before(c)
|
824
|
+
# implement each case before
|
825
|
+
end
|
826
|
+
|
827
|
+
def case_after(c)
|
828
|
+
# implement each case after
|
829
|
+
return if c[:expect_error]
|
830
|
+
File.delete(c[:expected_file_name]) if File.exists?(c[:expected_file_name])
|
831
|
+
FileUtils.rm_rf('spec/some_dir')
|
832
|
+
File.delete(c[:expected_product_file_name]) if !c[:expected_product_file_name].nil? && File.exists?(c[:expected_product_file_name])
|
833
|
+
FileUtils.rm_rf('lib/some_dir')
|
834
|
+
end
|
835
|
+
end
|
836
|
+
end
|
837
|
+
end
|