poptart 0.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 (39) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +22 -0
  3. data/.rspec +1 -0
  4. data/.ruby-version +1 -0
  5. data/.travis.yml +3 -0
  6. data/Gemfile +3 -0
  7. data/Gemfile.lock +88 -0
  8. data/README.md +0 -0
  9. data/Rakefile +18 -0
  10. data/lib/poptart/.DS_Store +0 -0
  11. data/lib/poptart/model.rb +17 -0
  12. data/lib/poptart/question.rb +19 -0
  13. data/lib/poptart/request.rb +48 -0
  14. data/lib/poptart/root.rb +11 -0
  15. data/lib/poptart/survey.rb +37 -0
  16. data/lib/poptart/survey_question.rb +42 -0
  17. data/lib/poptart/user.rb +46 -0
  18. data/lib/poptart.rb +22 -0
  19. data/lib/version.rb +3 -0
  20. data/poptart.gemspec +31 -0
  21. data/spec/requests/answering_survey_questions_spec.rb +56 -0
  22. data/spec/requests/root_spec.rb +8 -0
  23. data/spec/requests/user_management_spec.rb +17 -0
  24. data/spec/spec_helper.rb +68 -0
  25. data/spec/vcr/answering/survey_questions_answers_a_survey_question.yml +1588 -0
  26. data/spec/vcr/answering/survey_questions_creates_and_returns_a_random_question_survey.yml +330 -0
  27. data/spec/vcr/answering/survey_questions_creates_and_returns_an_empty_survey.yml +272 -0
  28. data/spec/vcr/answering/survey_questions_finds_survey_question_for_id.yml +330 -0
  29. data/spec/vcr/poptart/root/returns_survey_links.yml +72 -0
  30. data/spec/vcr/poptart/user/answers_a_survey_question.yml +1580 -0
  31. data/spec/vcr/poptart/user/creates_a_user.yml +135 -0
  32. data/spec/vcr/poptart/user/creates_and_returns_a_random_question_survey.yml +341 -0
  33. data/spec/vcr/poptart/user/creates_and_returns_an_empty_survey.yml +272 -0
  34. data/spec/vcr/poptart/user/finds_survey_question_for_id.yml +327 -0
  35. data/spec/vcr/poptart/user/returns_a_user.yml +267 -0
  36. data/spec/vcr/user/management_creates_a_user.yml +135 -0
  37. data/spec/vcr/user/management_returns_a_user.yml +267 -0
  38. data/tags +72 -0
  39. metadata +266 -0
@@ -0,0 +1,330 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://localhost:3000/
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.0
12
+ Content-Type:
13
+ - application/json
14
+ Api-Token:
15
+ - testing
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ Accept:
19
+ - "*/*"
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: 'OK '
24
+ headers:
25
+ X-Frame-Options:
26
+ - SAMEORIGIN
27
+ X-Xss-Protection:
28
+ - 1; mode=block
29
+ X-Content-Type-Options:
30
+ - nosniff
31
+ X-Ua-Compatible:
32
+ - chrome=1
33
+ Content-Type:
34
+ - application/json; charset=utf-8
35
+ Etag:
36
+ - '"a723ac88b99a06c255a3384c2d01f4fb"'
37
+ Cache-Control:
38
+ - max-age=0, private, must-revalidate
39
+ X-Request-Id:
40
+ - 687942ab-0201-4f90-a9f2-51f603576901
41
+ X-Runtime:
42
+ - '0.009394'
43
+ Server:
44
+ - WEBrick/1.3.1 (Ruby/2.1.1/2014-02-24)
45
+ Date:
46
+ - Mon, 26 May 2014 20:53:53 GMT
47
+ Content-Length:
48
+ - '305'
49
+ Connection:
50
+ - Keep-Alive
51
+ body:
52
+ encoding: UTF-8
53
+ string: |-
54
+ {
55
+ "_links": {
56
+ "self": {
57
+ "href": "http://localhost:3000/api"
58
+ },
59
+ "surveys": {
60
+ "href": "http://localhost:3000/api/surveys"
61
+ },
62
+ "users": {
63
+ "href": "http://localhost:3000/api/users"
64
+ },
65
+ "questions": {
66
+ "href": "http://localhost:3000/api/questions"
67
+ }
68
+ }
69
+ }
70
+ http_version:
71
+ recorded_at: Mon, 26 May 2014 20:53:53 GMT
72
+ - request:
73
+ method: post
74
+ uri: http://localhost:3000/api/users
75
+ body:
76
+ encoding: UTF-8
77
+ string: '{"user":{"external_user_id":42}}'
78
+ headers:
79
+ User-Agent:
80
+ - Faraday v0.9.0
81
+ Content-Type:
82
+ - application/json
83
+ Api-Token:
84
+ - testing
85
+ Accept-Encoding:
86
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
87
+ Accept:
88
+ - "*/*"
89
+ response:
90
+ status:
91
+ code: 201
92
+ message: 'Created '
93
+ headers:
94
+ X-Frame-Options:
95
+ - SAMEORIGIN
96
+ X-Xss-Protection:
97
+ - 1; mode=block
98
+ X-Content-Type-Options:
99
+ - nosniff
100
+ X-Ua-Compatible:
101
+ - chrome=1
102
+ Content-Type:
103
+ - application/json; charset=utf-8
104
+ Etag:
105
+ - '"49dccf9410f7b577f49d0dcf86fb9556"'
106
+ Cache-Control:
107
+ - max-age=0, private, must-revalidate
108
+ X-Request-Id:
109
+ - 8d7f7866-84fe-4853-8b35-3101b7704bc3
110
+ X-Runtime:
111
+ - '0.011223'
112
+ Server:
113
+ - WEBrick/1.3.1 (Ruby/2.1.1/2014-02-24)
114
+ Date:
115
+ - Mon, 26 May 2014 20:53:53 GMT
116
+ Content-Length:
117
+ - '275'
118
+ Connection:
119
+ - Keep-Alive
120
+ body:
121
+ encoding: UTF-8
122
+ string: |-
123
+ {
124
+ "id": 234,
125
+ "external_user_id": 42,
126
+ "token": "38d7d61cc18a56e2c3319db6aa17d8695215db9a8b37a160b3458ba3f2bdd28b8bd25abfea8c133941623bc358e0e2ee42313d598e07a97ac889449279d7b61d",
127
+ "_links": {
128
+ "self": {
129
+ "href": "http://localhost:3000/api/users/234"
130
+ }
131
+ }
132
+ }
133
+ http_version:
134
+ recorded_at: Mon, 26 May 2014 20:53:53 GMT
135
+ - request:
136
+ method: post
137
+ uri: http://localhost:3000/api/surveys?random=true
138
+ body:
139
+ encoding: UTF-8
140
+ string: '{"survey":{"user_id":234}}'
141
+ headers:
142
+ User-Agent:
143
+ - Faraday v0.9.0
144
+ Content-Type:
145
+ - application/json
146
+ Api-Token:
147
+ - testing
148
+ Accept-Encoding:
149
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
150
+ Accept:
151
+ - "*/*"
152
+ response:
153
+ status:
154
+ code: 201
155
+ message: 'Created '
156
+ headers:
157
+ X-Frame-Options:
158
+ - SAMEORIGIN
159
+ X-Xss-Protection:
160
+ - 1; mode=block
161
+ X-Content-Type-Options:
162
+ - nosniff
163
+ X-Ua-Compatible:
164
+ - chrome=1
165
+ Content-Type:
166
+ - application/json; charset=utf-8
167
+ Etag:
168
+ - '"a4796f751c44045b68504fd24303b4bf"'
169
+ Cache-Control:
170
+ - max-age=0, private, must-revalidate
171
+ X-Request-Id:
172
+ - 82d391a4-188a-466c-8587-406b492185f6
173
+ X-Runtime:
174
+ - '0.069660'
175
+ Server:
176
+ - WEBrick/1.3.1 (Ruby/2.1.1/2014-02-24)
177
+ Date:
178
+ - Mon, 26 May 2014 20:53:53 GMT
179
+ Content-Length:
180
+ - '3670'
181
+ Connection:
182
+ - Keep-Alive
183
+ body:
184
+ encoding: UTF-8
185
+ string: |-
186
+ {
187
+ "id": 190,
188
+ "user_id": 234,
189
+ "survey_questions": [
190
+ {
191
+ "id": 660,
192
+ "text": "How well did you sleep last night?",
193
+ "type": "range",
194
+ "responses": [
195
+ "0",
196
+ "10"
197
+ ],
198
+ "freeform": false,
199
+ "_links": {
200
+ "self": {
201
+ "href": "http://localhost:3000/api/surveys/190/survey_questions/660"
202
+ },
203
+ "survey": {
204
+ "href": "http://localhost:3000/api/surveys/190"
205
+ },
206
+ "create": {
207
+ "href": "http://localhost:3000/api/surveys/190/survey_questions"
208
+ },
209
+ "submit": {
210
+ "href": "http://localhost:3000/api/surveys/190/survey_questions/660"
211
+ }
212
+ }
213
+ },
214
+ {
215
+ "id": 661,
216
+ "text": "To what extent are you focused on what you are doing?",
217
+ "type": "range",
218
+ "responses": [
219
+ "0",
220
+ "10"
221
+ ],
222
+ "freeform": false,
223
+ "_links": {
224
+ "self": {
225
+ "href": "http://localhost:3000/api/surveys/190/survey_questions/661"
226
+ },
227
+ "survey": {
228
+ "href": "http://localhost:3000/api/surveys/190"
229
+ },
230
+ "create": {
231
+ "href": "http://localhost:3000/api/surveys/190/survey_questions"
232
+ },
233
+ "submit": {
234
+ "href": "http://localhost:3000/api/surveys/190/survey_questions/661"
235
+ }
236
+ }
237
+ },
238
+ {
239
+ "id": 662,
240
+ "text": "Are you alone?",
241
+ "type": "boolean",
242
+ "responses": [
243
+ "t",
244
+ "f"
245
+ ],
246
+ "freeform": false,
247
+ "_links": {
248
+ "self": {
249
+ "href": "http://localhost:3000/api/surveys/190/survey_questions/662"
250
+ },
251
+ "survey": {
252
+ "href": "http://localhost:3000/api/surveys/190"
253
+ },
254
+ "create": {
255
+ "href": "http://localhost:3000/api/surveys/190/survey_questions"
256
+ },
257
+ "submit": {
258
+ "href": "http://localhost:3000/api/surveys/190/survey_questions/662"
259
+ }
260
+ }
261
+ },
262
+ {
263
+ "id": 663,
264
+ "text": "Beyond any work you've already done today, how many additional hours do you expect to work today?",
265
+ "type": "multiple",
266
+ "responses": [
267
+ "0 (none)",
268
+ "Less than 1 hour",
269
+ "1-2 hours",
270
+ "2-3 hours",
271
+ "3-4 hours",
272
+ "4-5 hours",
273
+ "5-6 hours"
274
+ ],
275
+ "freeform": false,
276
+ "_links": {
277
+ "self": {
278
+ "href": "http://localhost:3000/api/surveys/190/survey_questions/663"
279
+ },
280
+ "survey": {
281
+ "href": "http://localhost:3000/api/surveys/190"
282
+ },
283
+ "create": {
284
+ "href": "http://localhost:3000/api/surveys/190/survey_questions"
285
+ },
286
+ "submit": {
287
+ "href": "http://localhost:3000/api/surveys/190/survey_questions/663"
288
+ }
289
+ }
290
+ },
291
+ {
292
+ "id": 664,
293
+ "text": "To what extent is what you're doing interesting?",
294
+ "type": "range",
295
+ "responses": [
296
+ "0",
297
+ "10"
298
+ ],
299
+ "freeform": false,
300
+ "_links": {
301
+ "self": {
302
+ "href": "http://localhost:3000/api/surveys/190/survey_questions/664"
303
+ },
304
+ "survey": {
305
+ "href": "http://localhost:3000/api/surveys/190"
306
+ },
307
+ "create": {
308
+ "href": "http://localhost:3000/api/surveys/190/survey_questions"
309
+ },
310
+ "submit": {
311
+ "href": "http://localhost:3000/api/surveys/190/survey_questions/664"
312
+ }
313
+ }
314
+ }
315
+ ],
316
+ "_links": {
317
+ "self": {
318
+ "href": "http://localhost:3000/api/surveys/190"
319
+ },
320
+ "submit": {
321
+ "href": "http://localhost:3000/api/surveys/190/survey_questions"
322
+ },
323
+ "next": {
324
+ "href": "http://localhost:3000/api/surveys/190/survey_questions/660"
325
+ }
326
+ }
327
+ }
328
+ http_version:
329
+ recorded_at: Mon, 26 May 2014 20:53:53 GMT
330
+ recorded_with: VCR 2.6.0
@@ -0,0 +1,272 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://localhost:3000/
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.0
12
+ Content-Type:
13
+ - application/json
14
+ Api-Token:
15
+ - testing
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ Accept:
19
+ - "*/*"
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: 'OK '
24
+ headers:
25
+ X-Frame-Options:
26
+ - SAMEORIGIN
27
+ X-Xss-Protection:
28
+ - 1; mode=block
29
+ X-Content-Type-Options:
30
+ - nosniff
31
+ X-Ua-Compatible:
32
+ - chrome=1
33
+ Content-Type:
34
+ - application/json; charset=utf-8
35
+ Etag:
36
+ - '"a723ac88b99a06c255a3384c2d01f4fb"'
37
+ Cache-Control:
38
+ - max-age=0, private, must-revalidate
39
+ X-Request-Id:
40
+ - 59ac4297-fe1d-4cca-a534-72644ca2eabc
41
+ X-Runtime:
42
+ - '0.008227'
43
+ Server:
44
+ - WEBrick/1.3.1 (Ruby/2.1.1/2014-02-24)
45
+ Date:
46
+ - Mon, 26 May 2014 20:53:53 GMT
47
+ Content-Length:
48
+ - '305'
49
+ Connection:
50
+ - Keep-Alive
51
+ body:
52
+ encoding: UTF-8
53
+ string: |-
54
+ {
55
+ "_links": {
56
+ "self": {
57
+ "href": "http://localhost:3000/api"
58
+ },
59
+ "surveys": {
60
+ "href": "http://localhost:3000/api/surveys"
61
+ },
62
+ "users": {
63
+ "href": "http://localhost:3000/api/users"
64
+ },
65
+ "questions": {
66
+ "href": "http://localhost:3000/api/questions"
67
+ }
68
+ }
69
+ }
70
+ http_version:
71
+ recorded_at: Mon, 26 May 2014 20:53:53 GMT
72
+ - request:
73
+ method: post
74
+ uri: http://localhost:3000/api/users
75
+ body:
76
+ encoding: UTF-8
77
+ string: '{"user":{"external_user_id":42}}'
78
+ headers:
79
+ User-Agent:
80
+ - Faraday v0.9.0
81
+ Content-Type:
82
+ - application/json
83
+ Api-Token:
84
+ - testing
85
+ Accept-Encoding:
86
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
87
+ Accept:
88
+ - "*/*"
89
+ response:
90
+ status:
91
+ code: 201
92
+ message: 'Created '
93
+ headers:
94
+ X-Frame-Options:
95
+ - SAMEORIGIN
96
+ X-Xss-Protection:
97
+ - 1; mode=block
98
+ X-Content-Type-Options:
99
+ - nosniff
100
+ X-Ua-Compatible:
101
+ - chrome=1
102
+ Content-Type:
103
+ - application/json; charset=utf-8
104
+ Etag:
105
+ - '"4979010b9271953e426b409740f0db26"'
106
+ Cache-Control:
107
+ - max-age=0, private, must-revalidate
108
+ X-Request-Id:
109
+ - 74e54268-1434-40af-86df-0ec9699ef98c
110
+ X-Runtime:
111
+ - '0.011527'
112
+ Server:
113
+ - WEBrick/1.3.1 (Ruby/2.1.1/2014-02-24)
114
+ Date:
115
+ - Mon, 26 May 2014 20:53:53 GMT
116
+ Content-Length:
117
+ - '275'
118
+ Connection:
119
+ - Keep-Alive
120
+ body:
121
+ encoding: UTF-8
122
+ string: |-
123
+ {
124
+ "id": 233,
125
+ "external_user_id": 42,
126
+ "token": "38d7d61cc18a56e2c3319db6aa17d8695215db9a8b37a160b3458ba3f2bdd28b8bd25abfea8c133941623bc358e0e2ee42313d598e07a97ac889449279d7b61d",
127
+ "_links": {
128
+ "self": {
129
+ "href": "http://localhost:3000/api/users/233"
130
+ }
131
+ }
132
+ }
133
+ http_version:
134
+ recorded_at: Mon, 26 May 2014 20:53:53 GMT
135
+ - request:
136
+ method: get
137
+ uri: http://localhost:3000/
138
+ body:
139
+ encoding: US-ASCII
140
+ string: ''
141
+ headers:
142
+ User-Agent:
143
+ - Faraday v0.9.0
144
+ Content-Type:
145
+ - application/json
146
+ Api-Token:
147
+ - testing
148
+ Accept-Encoding:
149
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
150
+ Accept:
151
+ - "*/*"
152
+ response:
153
+ status:
154
+ code: 200
155
+ message: 'OK '
156
+ headers:
157
+ X-Frame-Options:
158
+ - SAMEORIGIN
159
+ X-Xss-Protection:
160
+ - 1; mode=block
161
+ X-Content-Type-Options:
162
+ - nosniff
163
+ X-Ua-Compatible:
164
+ - chrome=1
165
+ Content-Type:
166
+ - application/json; charset=utf-8
167
+ Etag:
168
+ - '"a723ac88b99a06c255a3384c2d01f4fb"'
169
+ Cache-Control:
170
+ - max-age=0, private, must-revalidate
171
+ X-Request-Id:
172
+ - e2afd766-adec-42fe-b530-23a3b795b9eb
173
+ X-Runtime:
174
+ - '0.008869'
175
+ Server:
176
+ - WEBrick/1.3.1 (Ruby/2.1.1/2014-02-24)
177
+ Date:
178
+ - Mon, 26 May 2014 20:53:53 GMT
179
+ Content-Length:
180
+ - '305'
181
+ Connection:
182
+ - Keep-Alive
183
+ body:
184
+ encoding: UTF-8
185
+ string: |-
186
+ {
187
+ "_links": {
188
+ "self": {
189
+ "href": "http://localhost:3000/api"
190
+ },
191
+ "surveys": {
192
+ "href": "http://localhost:3000/api/surveys"
193
+ },
194
+ "users": {
195
+ "href": "http://localhost:3000/api/users"
196
+ },
197
+ "questions": {
198
+ "href": "http://localhost:3000/api/questions"
199
+ }
200
+ }
201
+ }
202
+ http_version:
203
+ recorded_at: Mon, 26 May 2014 20:53:53 GMT
204
+ - request:
205
+ method: post
206
+ uri: http://localhost:3000/api/surveys
207
+ body:
208
+ encoding: UTF-8
209
+ string: '{"survey":{"user_id":233}}'
210
+ headers:
211
+ User-Agent:
212
+ - Faraday v0.9.0
213
+ Content-Type:
214
+ - application/json
215
+ Api-Token:
216
+ - testing
217
+ Accept-Encoding:
218
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
219
+ Accept:
220
+ - "*/*"
221
+ response:
222
+ status:
223
+ code: 201
224
+ message: 'Created '
225
+ headers:
226
+ X-Frame-Options:
227
+ - SAMEORIGIN
228
+ X-Xss-Protection:
229
+ - 1; mode=block
230
+ X-Content-Type-Options:
231
+ - nosniff
232
+ X-Ua-Compatible:
233
+ - chrome=1
234
+ Content-Type:
235
+ - application/json; charset=utf-8
236
+ Etag:
237
+ - '"e0772bb0155f32cba5a955ab2190a4c1"'
238
+ Cache-Control:
239
+ - max-age=0, private, must-revalidate
240
+ X-Request-Id:
241
+ - ff4b7ba8-9205-420b-a7ef-7d8254c23732
242
+ X-Runtime:
243
+ - '0.015195'
244
+ Server:
245
+ - WEBrick/1.3.1 (Ruby/2.1.1/2014-02-24)
246
+ Date:
247
+ - Mon, 26 May 2014 20:53:53 GMT
248
+ Content-Length:
249
+ - '250'
250
+ Connection:
251
+ - Keep-Alive
252
+ body:
253
+ encoding: UTF-8
254
+ string: |-
255
+ {
256
+ "id": 189,
257
+ "user_id": 233,
258
+ "survey_questions": [
259
+
260
+ ],
261
+ "_links": {
262
+ "self": {
263
+ "href": "http://localhost:3000/api/surveys/189"
264
+ },
265
+ "submit": {
266
+ "href": "http://localhost:3000/api/surveys/189/survey_questions"
267
+ }
268
+ }
269
+ }
270
+ http_version:
271
+ recorded_at: Mon, 26 May 2014 20:53:53 GMT
272
+ recorded_with: VCR 2.6.0