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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/marigold.rb +256 -252
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2bf47b50bdff8a7aabb6a41d502e5d46fdcd9e3a
4
- data.tar.gz: 64618f28beaa39eb2d18bf6f38bc1eb0115715a7
3
+ metadata.gz: 1d1f89e12409338b58ba032e35cb00f20dad028a
4
+ data.tar.gz: c56a2bf851a231853857ee051c34523c687d6767
5
5
  SHA512:
6
- metadata.gz: e4177c7b379ed76fa19693f7d896c9a3781c18a136a915fad295e7d06f2d723c978f5240bcdb429e9c5c6d3aca165c5f34ebbb2cf51ae1c68df5755531d6a660
7
- data.tar.gz: 33821d5dd501e3128b004bcc48ed73da269c7fbcaa0b501039d5ff0d5fec8b227a5b8b4486a17b07bfa5faf37c71749c6a71e7f93b3a88849e308d402710bb67
6
+ metadata.gz: 11aeb6e590543b7e324e63093860e4fae57c1ecc7150f5c352eef1a281018462fef80ad772040e752cac2f4f13e76a080c0eeab3695a0a0f4c8a5ea7eb893385
7
+ data.tar.gz: c4d0bd29634bf6e92ca3da590288063743df465b0fcf8904875b0ea4b1d18614dc0e6787320a4813e6a392d1cfc2ad9748e7ec57a2353373fe4035985fa64af7
@@ -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
- base = File.basename(file, File.extname(file))
8
- File.open(base + "_test.go", "w") { |f|
9
- # model name config
10
- upcase_name = base.slice(0,1).capitalize + base.slice(1..-1)
11
- plural_name = base.pluralize
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
- # Test Suite to generate
14
- f.write('package main_test')
15
- f.puts @string
16
+ # Test Suite to generate
17
+ f.write('package main_test')
18
+ f.puts @string
16
19
 
17
- f.write('import (')
18
- f.puts @string
19
- f.write(' "bytes"')
20
- f.puts @string
21
- f.write(' "net/http"')
22
- f.puts @string
23
- f.puts @string
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
- f.write(' . "github.com/onsi/ginkgo"')
26
- f.puts @string
27
- f.write(' . "github.com/onsi/gomega"')
28
- f.puts @string
29
- f.write(')')
30
- f.puts @string
31
- f.puts @string
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
- f.write('var _ = Describe("'+upcase_name+'", func() {')
34
- f.write(' var client = http.Client{}')
35
- f.puts @string
36
- f.puts @string
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
- 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
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
- 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
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
- 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
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
- 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(' })')
260
- f.puts @string
261
- f.write(' })')
262
- f.puts @string
263
- f.write('})')
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
- # Format the test suite code
267
- system "go fmt"
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.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-22 00:00:00.000000000 Z
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,