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