specfactor 0.1.2 → 0.1.3
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.
- checksums.yaml +4 -4
- data/.idea/workspace.xml +155 -50
- data/Gemfile.lock +1 -1
- data/README.md +5 -1
- data/lib/factory_module.rb +25 -0
- data/lib/spec_module.rb +6 -35
- data/lib/specfac/version.rb +1 -1
- data/lib/specfac.rb +24 -3
- data/lib/specfac_utils.rb +31 -0
- data/specfac.gemspec +1 -1
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d739864d0784ab157abaef131a5d6f217f8774307e01abc1c5357d09b2b2ae78
|
4
|
+
data.tar.gz: d13788dfcefcdf0cf3751c2292ec748854b43aba751c0528b21047e27c5eed80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1601fcdf5bdac2d49e8ca6c2b0b142229d40f6499c0a3ec0782a9a971433a02a882aeb0b946603e4e2dfb1ffd24858b9a6fe83abb9c8fbc72e67266bff904a4e
|
7
|
+
data.tar.gz: 419133f0c23a86741936c039717f3a48d047d3254a77e841eac740156f218abd55c61d4eb9af6a532c441d99881427ea203b49c77de43bd15073c79657ac5773
|
data/.idea/workspace.xml
CHANGED
@@ -2,8 +2,12 @@
|
|
2
2
|
<project version="4">
|
3
3
|
<component name="ChangeListManager">
|
4
4
|
<list default="true" id="9c170d0c-08bf-4830-a863-b6dfc3a02d09" name="Default" comment="">
|
5
|
-
<change beforePath="$PROJECT_DIR
|
5
|
+
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
6
|
+
<change beforePath="$PROJECT_DIR$/Gemfile.lock" beforeDir="false" afterPath="$PROJECT_DIR$/Gemfile.lock" afterDir="false" />
|
7
|
+
<change beforePath="$PROJECT_DIR$/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
|
6
8
|
<change beforePath="$PROJECT_DIR$/lib/specfac.rb" beforeDir="false" afterPath="$PROJECT_DIR$/lib/specfac.rb" afterDir="false" />
|
9
|
+
<change beforePath="$PROJECT_DIR$/lib/specfac/version.rb" beforeDir="false" afterPath="$PROJECT_DIR$/lib/specfac/version.rb" afterDir="false" />
|
10
|
+
<change beforePath="$PROJECT_DIR$/specfac.gemspec" beforeDir="false" afterPath="$PROJECT_DIR$/specfac.gemspec" afterDir="false" />
|
7
11
|
</list>
|
8
12
|
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
|
9
13
|
<option name="TRACKING_ENABLED" value="true" />
|
@@ -14,35 +18,36 @@
|
|
14
18
|
</component>
|
15
19
|
<component name="FileEditorManager">
|
16
20
|
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
|
17
|
-
<file leaf-file-name="specfac.gemspec" pinned="false" current-in-tab="
|
21
|
+
<file leaf-file-name="specfac.gemspec" pinned="false" current-in-tab="true">
|
18
22
|
<entry file="file://$PROJECT_DIR$/specfac.gemspec">
|
19
23
|
<provider selected="true" editor-type-id="text-editor">
|
20
|
-
<state relative-caret-position="
|
21
|
-
<caret line="
|
24
|
+
<state relative-caret-position="165">
|
25
|
+
<caret line="11" column="124" selection-start-line="11" selection-start-column="124" selection-end-line="11" selection-end-column="124" />
|
22
26
|
</state>
|
23
27
|
</provider>
|
24
28
|
</entry>
|
25
29
|
</file>
|
26
|
-
<file leaf-file-name=".
|
27
|
-
<entry file="file://$PROJECT_DIR
|
30
|
+
<file leaf-file-name="specfac.rb" pinned="false" current-in-tab="false">
|
31
|
+
<entry file="file://$PROJECT_DIR$/lib/specfac.rb">
|
28
32
|
<provider selected="true" editor-type-id="text-editor">
|
29
|
-
<state relative-caret-position="
|
30
|
-
<caret line="
|
33
|
+
<state relative-caret-position="314">
|
34
|
+
<caret line="38" column="20" selection-start-line="38" selection-start-column="20" selection-end-line="38" selection-end-column="20" />
|
31
35
|
</state>
|
32
36
|
</provider>
|
33
37
|
</entry>
|
34
38
|
</file>
|
35
|
-
<file leaf-file-name="
|
36
|
-
<entry file="file://$PROJECT_DIR$/
|
37
|
-
<provider selected="true" editor-type-id="text-editor"
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
39
|
+
<file leaf-file-name="dogs_controller_spec.rb" pinned="false" current-in-tab="false">
|
40
|
+
<entry file="file://$PROJECT_DIR$/spec/controllers/dogs_controller_spec.rb">
|
41
|
+
<provider selected="true" editor-type-id="text-editor" />
|
42
|
+
</entry>
|
43
|
+
</file>
|
44
|
+
<file leaf-file-name="tests_controller_spec.rb" pinned="false" current-in-tab="false">
|
45
|
+
<entry file="file://$PROJECT_DIR$/spec/controllers/tests_controller_spec.rb">
|
46
|
+
<provider selected="true" editor-type-id="text-editor" />
|
42
47
|
</entry>
|
43
48
|
</file>
|
44
|
-
<file leaf-file-name="
|
45
|
-
<entry file="file://$PROJECT_DIR$/spec/
|
49
|
+
<file leaf-file-name="dogs_spec.rb" pinned="false" current-in-tab="false">
|
50
|
+
<entry file="file://$PROJECT_DIR$/spec/factories/dogs_spec.rb">
|
46
51
|
<provider selected="true" editor-type-id="text-editor" />
|
47
52
|
</entry>
|
48
53
|
</file>
|
@@ -50,8 +55,8 @@
|
|
50
55
|
<entry file="file://$PROJECT_DIR$/README.md">
|
51
56
|
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
|
52
57
|
<state split_layout="SPLIT">
|
53
|
-
<first_editor relative-caret-position="
|
54
|
-
<caret line="
|
58
|
+
<first_editor relative-caret-position="372">
|
59
|
+
<caret line="49" column="32" selection-start-line="49" selection-start-column="32" selection-end-line="49" selection-end-column="32" />
|
55
60
|
</first_editor>
|
56
61
|
<second_editor />
|
57
62
|
</state>
|
@@ -70,8 +75,26 @@
|
|
70
75
|
<file leaf-file-name="spec_module.rb" pinned="false" current-in-tab="false">
|
71
76
|
<entry file="file://$PROJECT_DIR$/lib/spec_module.rb">
|
72
77
|
<provider selected="true" editor-type-id="text-editor">
|
73
|
-
<state relative-caret-position="
|
74
|
-
<caret line="
|
78
|
+
<state relative-caret-position="120">
|
79
|
+
<caret line="8" column="21" selection-start-line="8" selection-start-column="21" selection-end-line="8" selection-end-column="21" />
|
80
|
+
</state>
|
81
|
+
</provider>
|
82
|
+
</entry>
|
83
|
+
</file>
|
84
|
+
<file leaf-file-name="factory_module.rb" pinned="false" current-in-tab="false">
|
85
|
+
<entry file="file://$PROJECT_DIR$/lib/factory_module.rb">
|
86
|
+
<provider selected="true" editor-type-id="text-editor">
|
87
|
+
<state relative-caret-position="60">
|
88
|
+
<caret line="4" lean-forward="true" selection-start-line="4" selection-end-line="4" />
|
89
|
+
</state>
|
90
|
+
</provider>
|
91
|
+
</entry>
|
92
|
+
</file>
|
93
|
+
<file leaf-file-name="specfac_utils.rb" pinned="false" current-in-tab="false">
|
94
|
+
<entry file="file://$PROJECT_DIR$/lib/specfac_utils.rb">
|
95
|
+
<provider selected="true" editor-type-id="text-editor">
|
96
|
+
<state relative-caret-position="450">
|
97
|
+
<caret line="30" column="3" selection-start-line="30" selection-start-column="3" selection-end-line="30" selection-end-column="3" />
|
75
98
|
</state>
|
76
99
|
</provider>
|
77
100
|
</entry>
|
@@ -82,10 +105,12 @@
|
|
82
105
|
<findStrings>
|
83
106
|
<find>Walter</find>
|
84
107
|
<find>SpecModule</find>
|
108
|
+
<find>"</find>
|
85
109
|
</findStrings>
|
86
110
|
<replaceStrings>
|
87
111
|
<replace>Specfac</replace>
|
88
112
|
<replace>Utils</replace>
|
113
|
+
<replace>'</replace>
|
89
114
|
</replaceStrings>
|
90
115
|
</component>
|
91
116
|
<component name="Git.Settings">
|
@@ -95,12 +120,15 @@
|
|
95
120
|
<option name="CHANGED_PATHS">
|
96
121
|
<list>
|
97
122
|
<option value="$PROJECT_DIR$/exe/specfac" />
|
98
|
-
<option value="$PROJECT_DIR$/specfac.gemspec" />
|
99
123
|
<option value="$PROJECT_DIR$/.gitignore" />
|
100
|
-
<option value="$PROJECT_DIR$/README.md" />
|
101
|
-
<option value="$PROJECT_DIR$/lib/specfac/version.rb" />
|
102
124
|
<option value="$PROJECT_DIR$/lib/factory/spec_module.rb" />
|
125
|
+
<option value="$PROJECT_DIR$/lib/specfac_utils.rb" />
|
126
|
+
<option value="$PROJECT_DIR$/lib/factory_module.rb" />
|
127
|
+
<option value="$PROJECT_DIR$/lib/spec_module.rb" />
|
128
|
+
<option value="$PROJECT_DIR$/lib/specfac/version.rb" />
|
103
129
|
<option value="$PROJECT_DIR$/lib/specfac.rb" />
|
130
|
+
<option value="$PROJECT_DIR$/README.md" />
|
131
|
+
<option value="$PROJECT_DIR$/specfac.gemspec" />
|
104
132
|
</list>
|
105
133
|
</option>
|
106
134
|
</component>
|
@@ -123,6 +151,7 @@
|
|
123
151
|
<foldersAlwaysOnTop value="true" />
|
124
152
|
</navigator>
|
125
153
|
<panes>
|
154
|
+
<pane id="Scope" />
|
126
155
|
<pane id="ProjectPane">
|
127
156
|
<subPane>
|
128
157
|
<expand>
|
@@ -157,11 +186,16 @@
|
|
157
186
|
<item name="spec" type="462c0819:PsiDirectoryNode" />
|
158
187
|
<item name="controllers" type="462c0819:PsiDirectoryNode" />
|
159
188
|
</path>
|
189
|
+
<path>
|
190
|
+
<item name="specfac" type="b2602c69:ProjectViewProjectNode" />
|
191
|
+
<item name="specfac" type="462c0819:PsiDirectoryNode" />
|
192
|
+
<item name="spec" type="462c0819:PsiDirectoryNode" />
|
193
|
+
<item name="factories" type="462c0819:PsiDirectoryNode" />
|
194
|
+
</path>
|
160
195
|
</expand>
|
161
196
|
<select />
|
162
197
|
</subPane>
|
163
198
|
</pane>
|
164
|
-
<pane id="Scope" />
|
165
199
|
</panes>
|
166
200
|
</component>
|
167
201
|
<component name="PropertiesComponent">
|
@@ -202,18 +236,20 @@
|
|
202
236
|
<workItem from="1534450332680" duration="4232000" />
|
203
237
|
<workItem from="1534944836242" duration="417000" />
|
204
238
|
<workItem from="1534945842456" duration="1238000" />
|
205
|
-
<workItem from="1535055366512" duration="
|
239
|
+
<workItem from="1535055366512" duration="3819000" />
|
240
|
+
<workItem from="1535063383155" duration="1862000" />
|
241
|
+
<workItem from="1535082797411" duration="1957000" />
|
206
242
|
</task>
|
207
243
|
<servers />
|
208
244
|
</component>
|
209
245
|
<component name="TimeTrackingManager">
|
210
|
-
<option name="totallyTimeSpent" value="
|
246
|
+
<option name="totallyTimeSpent" value="13525000" />
|
211
247
|
</component>
|
212
248
|
<component name="ToolWindowManager">
|
213
249
|
<frame x="0" y="23" width="1440" height="797" extended-state="0" />
|
214
250
|
<editor active="true" />
|
215
251
|
<layout>
|
216
|
-
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.
|
252
|
+
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.26752505" />
|
217
253
|
<window_info anchor="bottom" id="TODO" order="6" />
|
218
254
|
<window_info anchor="bottom" id="Docker" order="7" show_stripe_button="false" />
|
219
255
|
<window_info anchor="bottom" id="Event Log" order="7" side_tool="true" />
|
@@ -241,6 +277,47 @@
|
|
241
277
|
<option name="myLimit" value="2678400000" />
|
242
278
|
</component>
|
243
279
|
<component name="editorHistoryManager">
|
280
|
+
<entry file="file://$PROJECT_DIR$/.gitignore">
|
281
|
+
<provider selected="true" editor-type-id="text-editor">
|
282
|
+
<state relative-caret-position="120">
|
283
|
+
<caret line="8" column="18" selection-start-line="8" selection-start-column="18" selection-end-line="8" selection-end-column="18" />
|
284
|
+
</state>
|
285
|
+
</provider>
|
286
|
+
</entry>
|
287
|
+
<entry file="file://$PROJECT_DIR$/spec/controllers/yammos_controller_spec.rb">
|
288
|
+
<provider selected="true" editor-type-id="text-editor" />
|
289
|
+
</entry>
|
290
|
+
<entry file="file://$PROJECT_DIR$/README.md">
|
291
|
+
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
|
292
|
+
<state split_layout="SPLIT">
|
293
|
+
<first_editor relative-caret-position="765">
|
294
|
+
<caret line="51" column="94" selection-start-line="51" selection-start-column="94" selection-end-line="51" selection-end-column="94" />
|
295
|
+
</first_editor>
|
296
|
+
<second_editor />
|
297
|
+
</state>
|
298
|
+
</provider>
|
299
|
+
</entry>
|
300
|
+
<entry file="file://$PROJECT_DIR$/lib/specfac/version.rb">
|
301
|
+
<provider selected="true" editor-type-id="text-editor">
|
302
|
+
<state relative-caret-position="15">
|
303
|
+
<caret line="1" column="18" selection-start-line="1" selection-start-column="18" selection-end-line="1" selection-end-column="18" />
|
304
|
+
</state>
|
305
|
+
</provider>
|
306
|
+
</entry>
|
307
|
+
<entry file="file://$PROJECT_DIR$/lib/spec_module.rb">
|
308
|
+
<provider selected="true" editor-type-id="text-editor">
|
309
|
+
<state relative-caret-position="555">
|
310
|
+
<caret line="37" column="29" selection-start-line="37" selection-start-column="29" selection-end-line="37" selection-end-column="29" />
|
311
|
+
</state>
|
312
|
+
</provider>
|
313
|
+
</entry>
|
314
|
+
<entry file="file://$PROJECT_DIR$/lib/specfac.rb">
|
315
|
+
<provider selected="true" editor-type-id="text-editor">
|
316
|
+
<state relative-caret-position="570">
|
317
|
+
<caret line="38" lean-forward="true" selection-start-line="38" selection-end-line="38" />
|
318
|
+
</state>
|
319
|
+
</provider>
|
320
|
+
</entry>
|
244
321
|
<entry file="file://$PROJECT_DIR$/specfac.gemspec">
|
245
322
|
<provider selected="true" editor-type-id="text-editor">
|
246
323
|
<state relative-caret-position="390">
|
@@ -379,13 +456,6 @@
|
|
379
456
|
</state>
|
380
457
|
</provider>
|
381
458
|
</entry>
|
382
|
-
<entry file="file://$PROJECT_DIR$/specfac.gemspec">
|
383
|
-
<provider selected="true" editor-type-id="text-editor">
|
384
|
-
<state relative-caret-position="390">
|
385
|
-
<caret line="26" column="49" selection-start-line="26" selection-start-column="49" selection-end-line="26" selection-end-column="49" />
|
386
|
-
</state>
|
387
|
-
</provider>
|
388
|
-
</entry>
|
389
459
|
<entry file="file://$PROJECT_DIR$/.gitignore">
|
390
460
|
<provider selected="true" editor-type-id="text-editor">
|
391
461
|
<state relative-caret-position="120">
|
@@ -394,17 +464,30 @@
|
|
394
464
|
</provider>
|
395
465
|
</entry>
|
396
466
|
<entry file="file://$PROJECT_DIR$/spec/spec_helper.rb" />
|
397
|
-
<entry file="file://$PROJECT_DIR$/spec/controllers/tests_controller_spec.rb" />
|
398
467
|
<entry file="file://$PROJECT_DIR$/spec/controllers/rabbits_controller_spec.rb" />
|
399
468
|
<entry file="file://$PROJECT_DIR$/spec/controllers/robots_controller_spec.rb" />
|
400
469
|
<entry file="file://$PROJECT_DIR$/spec/controllers/yoddels_controller_spec.rb" />
|
401
|
-
<entry file="file://$PROJECT_DIR$/
|
402
|
-
<provider selected="true" editor-type-id="
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
<
|
470
|
+
<entry file="file://$PROJECT_DIR$/spec/controllers/yammos_controller_spec.rb">
|
471
|
+
<provider selected="true" editor-type-id="text-editor" />
|
472
|
+
</entry>
|
473
|
+
<entry file="file://$PROJECT_DIR$/lib/specfac_utils.rb">
|
474
|
+
<provider selected="true" editor-type-id="text-editor">
|
475
|
+
<state relative-caret-position="450">
|
476
|
+
<caret line="30" column="3" selection-start-line="30" selection-start-column="3" selection-end-line="30" selection-end-column="3" />
|
477
|
+
</state>
|
478
|
+
</provider>
|
479
|
+
</entry>
|
480
|
+
<entry file="file://$PROJECT_DIR$/lib/factory_module.rb">
|
481
|
+
<provider selected="true" editor-type-id="text-editor">
|
482
|
+
<state relative-caret-position="60">
|
483
|
+
<caret line="4" lean-forward="true" selection-start-line="4" selection-end-line="4" />
|
484
|
+
</state>
|
485
|
+
</provider>
|
486
|
+
</entry>
|
487
|
+
<entry file="file://$PROJECT_DIR$/lib/spec_module.rb">
|
488
|
+
<provider selected="true" editor-type-id="text-editor">
|
489
|
+
<state relative-caret-position="120">
|
490
|
+
<caret line="8" column="21" selection-start-line="8" selection-start-column="21" selection-end-line="8" selection-end-column="21" />
|
408
491
|
</state>
|
409
492
|
</provider>
|
410
493
|
</entry>
|
@@ -415,20 +498,42 @@
|
|
415
498
|
</state>
|
416
499
|
</provider>
|
417
500
|
</entry>
|
418
|
-
<entry file="file://$PROJECT_DIR$/
|
501
|
+
<entry file="file://$PROJECT_DIR$/spec/factories/static_spec.rb">
|
502
|
+
<provider selected="true" editor-type-id="text-editor" />
|
503
|
+
</entry>
|
504
|
+
<entry file="file://$PROJECT_DIR$/spec/controllers/rog_controller_spec.rb">
|
505
|
+
<provider selected="true" editor-type-id="text-editor" />
|
506
|
+
</entry>
|
507
|
+
<entry file="file://$PROJECT_DIR$/lib/specfac.rb">
|
419
508
|
<provider selected="true" editor-type-id="text-editor">
|
420
|
-
<state relative-caret-position="
|
421
|
-
<caret line="
|
509
|
+
<state relative-caret-position="314">
|
510
|
+
<caret line="38" column="20" selection-start-line="38" selection-start-column="20" selection-end-line="38" selection-end-column="20" />
|
422
511
|
</state>
|
423
512
|
</provider>
|
424
513
|
</entry>
|
425
|
-
<entry file="file://$PROJECT_DIR$/spec/controllers/
|
514
|
+
<entry file="file://$PROJECT_DIR$/spec/controllers/dogs_controller_spec.rb">
|
426
515
|
<provider selected="true" editor-type-id="text-editor" />
|
427
516
|
</entry>
|
428
|
-
<entry file="file://$PROJECT_DIR$/
|
517
|
+
<entry file="file://$PROJECT_DIR$/spec/controllers/tests_controller_spec.rb">
|
518
|
+
<provider selected="true" editor-type-id="text-editor" />
|
519
|
+
</entry>
|
520
|
+
<entry file="file://$PROJECT_DIR$/spec/factories/dogs_spec.rb">
|
521
|
+
<provider selected="true" editor-type-id="text-editor" />
|
522
|
+
</entry>
|
523
|
+
<entry file="file://$PROJECT_DIR$/README.md">
|
524
|
+
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
|
525
|
+
<state split_layout="SPLIT">
|
526
|
+
<first_editor relative-caret-position="372">
|
527
|
+
<caret line="49" column="32" selection-start-line="49" selection-start-column="32" selection-end-line="49" selection-end-column="32" />
|
528
|
+
</first_editor>
|
529
|
+
<second_editor />
|
530
|
+
</state>
|
531
|
+
</provider>
|
532
|
+
</entry>
|
533
|
+
<entry file="file://$PROJECT_DIR$/specfac.gemspec">
|
429
534
|
<provider selected="true" editor-type-id="text-editor">
|
430
|
-
<state relative-caret-position="
|
431
|
-
<caret line="
|
535
|
+
<state relative-caret-position="165">
|
536
|
+
<caret line="11" column="124" selection-start-line="11" selection-start-column="124" selection-end-line="11" selection-end-column="124" />
|
432
537
|
</state>
|
433
538
|
</provider>
|
434
539
|
</entry>
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -31,7 +31,7 @@ Or install it yourself as:
|
|
31
31
|
|
32
32
|
In terminal, type:
|
33
33
|
|
34
|
-
specfac [controller] [actions]
|
34
|
+
specfac generate [controller] [actions]
|
35
35
|
|
36
36
|
__[controller]__ should be the name of the controller you'd like to generate tests for
|
37
37
|
|
@@ -45,6 +45,10 @@ An example for all available tests:
|
|
45
45
|
|
46
46
|
specfac generate participants ALL
|
47
47
|
|
48
|
+
An example generating a FactoryBot factory for the controller:
|
49
|
+
|
50
|
+
specfac generate -f dogs ALL
|
51
|
+
|
48
52
|
Currently, tests can be generated for :index, :show, :new, :create, :edit, :update, and :destroy.
|
49
53
|
|
50
54
|
## Contributing
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'specfac_utils'
|
2
|
+
|
3
|
+
module FactoryModule
|
4
|
+
include Utils
|
5
|
+
|
6
|
+
def self.create
|
7
|
+
"FactoryBot.define do
|
8
|
+
factory :#{Utils.si} do
|
9
|
+
# insert attributes
|
10
|
+
|
11
|
+
factory :invalid_#{Utils.si} do
|
12
|
+
# insert attributes
|
13
|
+
end
|
14
|
+
|
15
|
+
factory :updated_#{Utils.si} do
|
16
|
+
# insert attributes
|
17
|
+
end
|
18
|
+
|
19
|
+
factory :second_#{Utils.si} do
|
20
|
+
# insert attributes
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end"
|
24
|
+
end
|
25
|
+
end
|
data/lib/spec_module.rb
CHANGED
@@ -1,34 +1,5 @@
|
|
1
|
-
require '
|
2
|
-
require 'active_support/core_ext/string'
|
1
|
+
require 'specfac_utils'
|
3
2
|
|
4
|
-
module Utils
|
5
|
-
@@term = nil
|
6
|
-
|
7
|
-
def self.define_utils_methods_params(term)
|
8
|
-
@@term = term
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.si
|
12
|
-
Utils.singularize(@@term)
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.si_ca
|
16
|
-
Utils.singularize(@@term.capitalize)
|
17
|
-
end
|
18
|
-
|
19
|
-
def self.pl
|
20
|
-
Utils.pluralize(@@term)
|
21
|
-
end
|
22
|
-
|
23
|
-
def self.pluralize(string)
|
24
|
-
return ActiveSupport::Inflector.pluralize(string)
|
25
|
-
end
|
26
|
-
|
27
|
-
def self.singularize(string)
|
28
|
-
return ActiveSupport::Inflector.singularize(string)
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
32
3
|
module SpecModule
|
33
4
|
include Utils
|
34
5
|
|
@@ -81,7 +52,7 @@ module SpecModule
|
|
81
52
|
"describe 'POST #create' do
|
82
53
|
let(:#{Utils.si}) {create(:#{Utils.si})}
|
83
54
|
let(:valid_attributes) { attributes_for(:#{Utils.si} )}
|
84
|
-
let(:invalid_attributes) { attributes_for(:invalid_#{Utils.si}
|
55
|
+
let(:invalid_attributes) { attributes_for(:invalid_#{Utils.si})}
|
85
56
|
it 'creates a new #{Utils.si}' do
|
86
57
|
expect{
|
87
58
|
post :create, params: {#{Utils.si}: valid_attributes}
|
@@ -96,7 +67,7 @@ module SpecModule
|
|
96
67
|
expect(flash[:notice]).to be_present
|
97
68
|
end
|
98
69
|
it 'fails to create a new #{Utils.si}' do
|
99
|
-
expect(build(:invalid_#{Utils.si}
|
70
|
+
expect(build(:invalid_#{Utils.si})).to be_invalid
|
100
71
|
end
|
101
72
|
it 'redirects to new template on failure to save new #{Utils.si}' do
|
102
73
|
post :create, params: {#{Utils.si}: invalid_attributes}
|
@@ -125,11 +96,11 @@ module SpecModule
|
|
125
96
|
let(:#{Utils.si}) {create(:#{Utils.si})}
|
126
97
|
let(:valid_attributes) { attributes_for(:#{Utils.si} )}
|
127
98
|
let(:new_attributes) { attributes_for(:updated_#{Utils.si})}
|
128
|
-
let(:invalid_attributes) { attributes_for(:invalid_#{Utils.si}
|
99
|
+
let(:invalid_attributes) { attributes_for(:invalid_#{Utils.si})}
|
129
100
|
it 'updates attributes for #{Utils.si}' do
|
130
101
|
patch :update, params: {id: #{Utils.si}.to_param,#{Utils.si}: new_attributes}
|
131
102
|
#{Utils.si}.reload
|
132
|
-
# expect(#{Utils.si}.name).to eq('
|
103
|
+
# expect(#{Utils.si}.name).to eq('example')
|
133
104
|
# expect(#{Utils.si}.points).to eq(800)
|
134
105
|
end
|
135
106
|
it 'redirects on update' do
|
@@ -145,7 +116,7 @@ module SpecModule
|
|
145
116
|
expect(flash[:alert]).to be_present
|
146
117
|
end
|
147
118
|
it 'fails to update #{Utils.si}' do
|
148
|
-
expect(build(:invalid_#{Utils.si}
|
119
|
+
expect(build(:invalid_#{Utils.si})).to be_invalid
|
149
120
|
end
|
150
121
|
it 'redirects to edit template on failure to update #{Utils.si}' do
|
151
122
|
patch :update, params: {id: #{Utils.si}.to_param,#{Utils.si}: invalid_attributes}
|
data/lib/specfac/version.rb
CHANGED
data/lib/specfac.rb
CHANGED
@@ -1,14 +1,17 @@
|
|
1
1
|
require 'specfac'
|
2
2
|
require 'thor'
|
3
3
|
require 'spec_module'
|
4
|
+
require 'factory_module'
|
4
5
|
module SpecFac
|
5
6
|
class CLI < Thor
|
6
7
|
include Utils
|
7
8
|
include SpecModule
|
9
|
+
include FactoryModule
|
8
10
|
attr_accessor :dir_controllers, :dir_factories, :working_dirs, :working_file, :protected_methods, :available_methods, :found_methods
|
9
11
|
|
10
12
|
######### AVAILABLE COMMANDS
|
11
13
|
desc "generate [controller] [actions]", "generates tests for specified actions"
|
14
|
+
option :f, :type => :boolean
|
12
15
|
def generate(*args)
|
13
16
|
@working_dirs = ["spec", "controllers", "factories"]
|
14
17
|
@dir_controllers = "#{@working_dirs[0]}/#{@working_dirs[1]}"
|
@@ -20,7 +23,23 @@ module SpecFac
|
|
20
23
|
|
21
24
|
controller = args.shift
|
22
25
|
actions = args
|
23
|
-
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
if controller
|
31
|
+
sanitize(controller, actions)
|
32
|
+
else
|
33
|
+
puts "Please provide a controller name."
|
34
|
+
exit
|
35
|
+
end
|
36
|
+
|
37
|
+
# Factories
|
38
|
+
|
39
|
+
if options[:f]
|
40
|
+
controller != nil ? @working_file = "#{@dir_factories}/#{controller.downcase}_spec.rb" : @working_file = "#{@dir_factories}/sample_spec.rb"
|
41
|
+
opener("factory", FactoryModule.create)
|
42
|
+
end
|
24
43
|
end
|
25
44
|
|
26
45
|
######## UTILITY METHODS
|
@@ -35,17 +54,19 @@ module SpecFac
|
|
35
54
|
def pull_src(controller, actions)
|
36
55
|
create_directories(@working_dirs[0], @dir_controllers, @dir_factories)
|
37
56
|
@working_file = "#{@dir_controllers}/#{controller.downcase}_controller_spec.rb"
|
38
|
-
#
|
57
|
+
# Spec tests
|
39
58
|
|
40
59
|
opener(
|
41
60
|
"header",
|
42
61
|
["require 'rails_helper'","RSpec.describe #{controller.capitalize}Controller, type: :controller do"]
|
43
62
|
)
|
44
|
-
|
63
|
+
|
45
64
|
Utils.define_utils_methods_params(controller)
|
46
65
|
actions != nil ? actions.each {|action| opener("body", SpecModule.public_send(action.to_sym))} : nil
|
47
66
|
opener("end", "end")
|
48
67
|
|
68
|
+
|
69
|
+
|
49
70
|
end
|
50
71
|
|
51
72
|
def opener(mode, lines)
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'active_support'
|
2
|
+
require 'active_support/core_ext/string'
|
3
|
+
|
4
|
+
module Utils
|
5
|
+
@@term = nil
|
6
|
+
|
7
|
+
def self.define_utils_methods_params(term)
|
8
|
+
@@term = term
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.si
|
12
|
+
Utils.singularize(@@term)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.si_ca
|
16
|
+
Utils.singularize(@@term.capitalize)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.pl
|
20
|
+
Utils.pluralize(@@term)
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.pluralize(string)
|
24
|
+
return ActiveSupport::Inflector.pluralize(string)
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.singularize(string)
|
28
|
+
return ActiveSupport::Inflector.singularize(string)
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
data/specfac.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["viktharien"]
|
10
10
|
spec.email = ["viktharien@zoho.com"]
|
11
11
|
|
12
|
-
spec.summary = %q{
|
12
|
+
spec.summary = %q{SpecFactor is a CLI for generating rspec controller tests. The gem is in a proof-of-concept stage.}
|
13
13
|
spec.homepage = "https://github.com/viktharien/specfacthor"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: specfactor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- viktharien
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-08-
|
11
|
+
date: 2018-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -106,9 +106,11 @@ files:
|
|
106
106
|
- bin/console
|
107
107
|
- bin/setup
|
108
108
|
- exe/specfac
|
109
|
+
- lib/factory_module.rb
|
109
110
|
- lib/spec_module.rb
|
110
111
|
- lib/specfac.rb
|
111
112
|
- lib/specfac/version.rb
|
113
|
+
- lib/specfac_utils.rb
|
112
114
|
- pull_me.txt
|
113
115
|
- specfac.gemspec
|
114
116
|
homepage: https://github.com/viktharien/specfacthor
|
@@ -134,5 +136,6 @@ rubyforge_project:
|
|
134
136
|
rubygems_version: 2.7.7
|
135
137
|
signing_key:
|
136
138
|
specification_version: 4
|
137
|
-
summary:
|
139
|
+
summary: SpecFactor is a CLI for generating rspec controller tests. The gem is in
|
140
|
+
a proof-of-concept stage.
|
138
141
|
test_files: []
|