marigold 1.0.0 → 1.0.1
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/lib/marigold.rb +256 -252
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d1f89e12409338b58ba032e35cb00f20dad028a
|
4
|
+
data.tar.gz: c56a2bf851a231853857ee051c34523c687d6767
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11aeb6e590543b7e324e63093860e4fae57c1ecc7150f5c352eef1a281018462fef80ad772040e752cac2f4f13e76a080c0eeab3695a0a0f4c8a5ea7eb893385
|
7
|
+
data.tar.gz: c4d0bd29634bf6e92ca3da590288063743df465b0fcf8904875b0ea4b1d18614dc0e6787320a4813e6a392d1cfc2ad9748e7ec57a2353373fe4035985fa64af7
|
data/lib/marigold.rb
CHANGED
@@ -4,265 +4,269 @@ require 'active_support/inflector'
|
|
4
4
|
# test file in the format "<filename>_test.go". Then
|
5
5
|
# Generate code based on file name.
|
6
6
|
Dir.glob("./*.go") do |file|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
if file == "./main.go"
|
8
|
+
elsif file.slice(-8..-1) == "_test.go"
|
9
|
+
else
|
10
|
+
base = File.basename(file, File.extname(file))
|
11
|
+
File.open(base + "_test.go", "w") { |f|
|
12
|
+
# model name config
|
13
|
+
upcase_name = base.slice(0,1).capitalize + base.slice(1..-1)
|
14
|
+
plural_name = base.pluralize
|
12
15
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
+
# Test Suite to generate
|
17
|
+
f.write('package main_test')
|
18
|
+
f.puts @string
|
16
19
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
f.write('import (')
|
21
|
+
f.puts @string
|
22
|
+
f.write(' "bytes"')
|
23
|
+
f.puts @string
|
24
|
+
f.write(' "net/http"')
|
25
|
+
f.puts @string
|
26
|
+
f.puts @string
|
24
27
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
f.write(' . "github.com/onsi/ginkgo"')
|
29
|
+
f.puts @string
|
30
|
+
f.write(' . "github.com/onsi/gomega"')
|
31
|
+
f.puts @string
|
32
|
+
f.write(')')
|
33
|
+
f.puts @string
|
34
|
+
f.puts @string
|
32
35
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
36
|
+
f.write('var _ = Describe("'+upcase_name+'", func() {')
|
37
|
+
f.write(' var client = http.Client{}')
|
38
|
+
f.puts @string
|
39
|
+
f.puts @string
|
37
40
|
|
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
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
41
|
+
f.write(' Describe("POST /api/'+plural_name+'", func() {')
|
42
|
+
f.puts @string
|
43
|
+
f.write(' Context("with wrong '+base+' attributes", func() {')
|
44
|
+
f.puts @string
|
45
|
+
f.write(' It("responds with a 400", func() {')
|
46
|
+
f.puts @string
|
47
|
+
f.write(' reader := bytes.NewReader([]byte(`{')
|
48
|
+
f.puts @string
|
49
|
+
f.write(' TODO: JSON Object to POST with')
|
50
|
+
f.puts @string
|
51
|
+
f.write(' }`))')
|
52
|
+
f.puts @string
|
53
|
+
f.puts @string
|
54
|
+
f.write(' req, err := http.NewRequest("POST", _SERVER_+"/api/'+plural_name+'", reader)')
|
55
|
+
f.puts @string
|
56
|
+
f.write(' Expect(err).To(BeNil())')
|
57
|
+
f.puts @string
|
58
|
+
f.puts @string
|
59
|
+
f.write(' resp, err := client.Do(req)')
|
60
|
+
f.puts @string
|
61
|
+
f.write(' Expect(err).To(BeNil())')
|
62
|
+
f.puts @string
|
63
|
+
f.puts @string
|
64
|
+
f.write(' Expect(resp.StatusCode).To(Equal(http.StatusBadRequest))')
|
65
|
+
f.puts @string
|
66
|
+
f.puts @string
|
67
|
+
f.write(' })')
|
68
|
+
f.puts @string
|
69
|
+
f.write(' })')
|
70
|
+
f.puts @string
|
71
|
+
f.write(' Context("with correct '+base+' attributes", func() {')
|
72
|
+
f.puts @string
|
73
|
+
f.write(' It("responds with a 201", func() {')
|
74
|
+
f.puts @string
|
75
|
+
f.write(' reader := bytes.NewReader([]byte(`{')
|
76
|
+
f.puts @string
|
77
|
+
f.write(' TODO: JSON Object to POST with')
|
78
|
+
f.puts @string
|
79
|
+
f.write(' }`))')
|
80
|
+
f.puts @string
|
81
|
+
f.puts @string
|
82
|
+
f.write(' req, err := http.NewRequest("POST", _SERVER_+"/api/'+plural_name+'", reader)')
|
83
|
+
f.puts @string
|
84
|
+
f.write(' Expect(err).To(BeNil())')
|
85
|
+
f.puts @string
|
86
|
+
f.puts @string
|
87
|
+
f.write(' resp, err := client.Do(req)')
|
88
|
+
f.puts @string
|
89
|
+
f.write(' Expect(err).To(BeNil())')
|
90
|
+
f.puts @string
|
91
|
+
f.puts @string
|
92
|
+
f.write(' Expect(resp.StatusCode).To(Equal(http.StatusCreated))')
|
93
|
+
f.puts @string
|
94
|
+
f.puts @string
|
95
|
+
f.write(' })')
|
96
|
+
f.puts @string
|
97
|
+
f.write(' })')
|
98
|
+
f.puts @string
|
99
|
+
f.write(' })')
|
100
|
+
f.puts @string
|
101
|
+
f.puts @string
|
99
102
|
|
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
|
-
|
103
|
+
f.write(' Describe("GET /api/'+plural_name+'/:id", func() {')
|
104
|
+
f.puts @string
|
105
|
+
f.write(' Context("with non-existing '+base+'", func() {')
|
106
|
+
f.puts @string
|
107
|
+
f.write(' It("responds with a 404", func() {')
|
108
|
+
f.puts @string
|
109
|
+
f.puts @string
|
110
|
+
f.write(' req, err := http.NewRequest("GET", _SERVER_+"/api/'+plural_name+'/0", nil)')
|
111
|
+
f.puts @string
|
112
|
+
f.write(' Expect(err).To(BeNil())')
|
113
|
+
f.puts @string
|
114
|
+
f.puts @string
|
115
|
+
f.write(' resp, err := client.Do(req)')
|
116
|
+
f.puts @string
|
117
|
+
f.write(' Expect(err).To(BeNil())')
|
118
|
+
f.puts @string
|
119
|
+
f.puts @string
|
120
|
+
f.write(' Expect(resp.StatusCode).To(Equal(http.StatusNotFound))')
|
121
|
+
f.puts @string
|
122
|
+
f.puts @string
|
123
|
+
f.write(' })')
|
124
|
+
f.puts @string
|
125
|
+
f.write(' })')
|
126
|
+
f.puts @string
|
127
|
+
f.write(' Context("with existing '+base+'", func() {')
|
128
|
+
f.puts @string
|
129
|
+
f.write(' It("responds with a 200", func() {')
|
130
|
+
f.puts @string
|
131
|
+
f.puts @string
|
132
|
+
f.write(' req, err := http.NewRequest("GET", _SERVER_+"/api/'+plural_name+'/1", nil)')
|
133
|
+
f.puts @string
|
134
|
+
f.write(' Expect(err).To(BeNil())')
|
135
|
+
f.puts @string
|
136
|
+
f.puts @string
|
137
|
+
f.write(' resp, err := client.Do(req)')
|
138
|
+
f.puts @string
|
139
|
+
f.write(' Expect(err).To(BeNil())')
|
140
|
+
f.puts @string
|
141
|
+
f.puts @string
|
142
|
+
f.write(' Expect(resp.StatusCode).To(Equal(http.StatusOK))')
|
143
|
+
f.puts @string
|
144
|
+
f.puts @string
|
145
|
+
f.write(' })')
|
146
|
+
f.puts @string
|
147
|
+
f.write(' })')
|
148
|
+
f.puts @string
|
149
|
+
f.write(' })')
|
150
|
+
f.puts @string
|
151
|
+
f.puts @string
|
149
152
|
|
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
|
-
|
153
|
+
f.write(' Describe("PUT /api/'+plural_name+'/:id", func() {')
|
154
|
+
f.puts @string
|
155
|
+
f.write(' Context("with incorrect '+base+' attributes", func() {')
|
156
|
+
f.puts @string
|
157
|
+
f.write(' It("responds with a 400", func() {')
|
158
|
+
f.puts @string
|
159
|
+
f.write(' reader := bytes.NewReader([]byte(`{')
|
160
|
+
f.puts @string
|
161
|
+
f.write(' TODO: JSON Object to POST with')
|
162
|
+
f.puts @string
|
163
|
+
f.write(' }`))')
|
164
|
+
f.puts @string
|
165
|
+
f.puts @string
|
166
|
+
f.write(' req, err := http.NewRequest("PUT", _SERVER_+"/api/'+plural_name+'/1", reader)')
|
167
|
+
f.puts @string
|
168
|
+
f.write(' Expect(err).To(BeNil())')
|
169
|
+
f.puts @string
|
170
|
+
f.puts @string
|
171
|
+
f.write('')
|
172
|
+
f.puts @string
|
173
|
+
f.write(' resp, err := client.Do(req)')
|
174
|
+
f.puts @string
|
175
|
+
f.write(' Expect(err).To(BeNil())')
|
176
|
+
f.puts @string
|
177
|
+
f.puts @string
|
178
|
+
f.write(' Expect(resp.StatusCode).To(Equal(http.StatusBadRequest))')
|
179
|
+
f.puts @string
|
180
|
+
f.puts @string
|
181
|
+
f.write(' })')
|
182
|
+
f.puts @string
|
183
|
+
f.write(' })')
|
184
|
+
f.puts @string
|
185
|
+
f.write(' Context("with correct '+base+' attributes", func() {')
|
186
|
+
f.puts @string
|
187
|
+
f.write(' It("responds with a 200", func() {')
|
188
|
+
f.puts @string
|
189
|
+
f.write(' reader := bytes.NewReader([]byte(`{')
|
190
|
+
f.puts @string
|
191
|
+
f.write(' TODO: JSON Object to POST with')
|
192
|
+
f.puts @string
|
193
|
+
f.write(' }`))')
|
194
|
+
f.puts @string
|
195
|
+
f.puts @string
|
196
|
+
f.write(' req, err := http.NewRequest("PUT", _SERVER_+"/api/'+plural_name+'/1", reader)')
|
197
|
+
f.puts @string
|
198
|
+
f.write(' Expect(err).To(BeNil())')
|
199
|
+
f.puts @string
|
200
|
+
f.puts @string
|
201
|
+
f.write(' resp, err := client.Do(req)')
|
202
|
+
f.puts @string
|
203
|
+
f.write(' Expect(err).To(BeNil())')
|
204
|
+
f.puts @string
|
205
|
+
f.puts @string
|
206
|
+
f.write(' Expect(resp.StatusCode).To(Equal(http.StatusNoContent))')
|
207
|
+
f.puts @string
|
208
|
+
f.write('')
|
209
|
+
f.puts @string
|
210
|
+
f.write(' })')
|
211
|
+
f.puts @string
|
212
|
+
f.write(' })')
|
213
|
+
f.puts @string
|
214
|
+
f.write(' })')
|
215
|
+
f.puts @string
|
216
|
+
f.puts @string
|
214
217
|
|
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
|
-
|
218
|
+
f.write(' Describe("DELETE /api/'+plural_name+'/:id", func() {')
|
219
|
+
f.puts @string
|
220
|
+
f.write(' Context("with non-existing '+base+'", func() {')
|
221
|
+
f.puts @string
|
222
|
+
f.write(' It("responds with a 404", func() {')
|
223
|
+
f.puts @string
|
224
|
+
f.puts @string
|
225
|
+
f.write(' req, err := http.NewRequest("DELETE", _SERVER_+"/api/'+plural_name+'/10200", nil)')
|
226
|
+
f.puts @string
|
227
|
+
f.write(' Expect(err).To(BeNil())')
|
228
|
+
f.puts @string
|
229
|
+
f.puts @string
|
230
|
+
f.write(' resp, err := client.Do(req)')
|
231
|
+
f.puts @string
|
232
|
+
f.write(' Expect(err).To(BeNil())')
|
233
|
+
f.puts @string
|
234
|
+
f.puts @string
|
235
|
+
f.write(' Expect(resp.StatusCode).To(Equal(http.StatusNotFound))')
|
236
|
+
f.puts @string
|
237
|
+
f.puts @string
|
238
|
+
f.write(' })')
|
239
|
+
f.puts @string
|
240
|
+
f.write(' })')
|
241
|
+
f.puts @string
|
242
|
+
f.write(' Context("with existing '+base+'", func() {')
|
243
|
+
f.puts @string
|
244
|
+
f.write(' It("responds with a 204", func() {')
|
245
|
+
f.puts @string
|
246
|
+
f.puts @string
|
247
|
+
f.write(' req, err := http.NewRequest("DELETE", _SERVER_+"/api/'+plural_name+'/1", nil)')
|
248
|
+
f.puts @string
|
249
|
+
f.write(' Expect(err).To(BeNil())')
|
250
|
+
f.puts @string
|
251
|
+
f.puts @string
|
252
|
+
f.write(' resp, err := client.Do(req)')
|
253
|
+
f.puts @string
|
254
|
+
f.write(' Expect(err).To(BeNil())')
|
255
|
+
f.puts @string
|
256
|
+
f.puts @string
|
257
|
+
f.write(' Expect(resp.StatusCode).To(Equal(http.StatusNoContent))')
|
258
|
+
f.puts @string
|
259
|
+
f.puts @string
|
260
|
+
f.write(' })')
|
261
|
+
f.puts @string
|
262
|
+
f.write(' })')
|
263
|
+
f.puts @string
|
264
|
+
f.write(' })')
|
265
|
+
f.puts @string
|
266
|
+
f.write('})')
|
267
|
+
}
|
265
268
|
|
266
|
-
|
267
|
-
|
269
|
+
# Format the test suite code
|
270
|
+
system "go fmt"
|
271
|
+
end
|
268
272
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: marigold
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Rucci
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-23 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: "Marigold is a script built for generating basic CRUD test for an API.
|
14
14
|
Focus is on \n generating endpoint tests for Go. Because of this,
|