poptart 0.0.6 → 0.0.7
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/Gemfile.lock +1 -1
- data/README.md +35 -0
- data/lib/poptart/survey.rb +2 -2
- data/lib/poptart/user.rb +2 -2
- data/lib/version.rb +1 -1
- data/spec/requests/answering_survey_questions_spec.rb +2 -2
- data/spec/vcr/answering/survey_questions_answers_a_multiple_choice_question.yml +1003 -77
- data/spec/vcr/answering/survey_questions_answers_a_survey_question.yml +1585 -346
- data/spec/vcr/answering/survey_questions_creates_and_returns_a_random_question_survey.yml +63 -74
- data/spec/vcr/answering/survey_questions_creates_and_returns_an_empty_survey.yml +29 -30
- data/spec/vcr/answering/survey_questions_finds_survey_question_for_id.yml +65 -110
- 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: 51e0f75b30a939cea82b52d482f51d586b2287bf
|
4
|
+
data.tar.gz: b1b3ec6398baa588562fe3add59bf73dc75fd2df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dbfc6a4f084112f76c30d8662fa8d38a14c1495f7217ed07ea6f90a5862d5711b9a107b28be326194649c593b1a637c495e86818e8f6174fe352d76555bdd1f8
|
7
|
+
data.tar.gz: 6d727efd65dd0d2695af39da9d094d1ff5f7914c145e2b15ffd65b4dc4d6b291537e4c81eb4ac40ed57bd8e2d50e7ee5ca65a0b523a38bbb7e616931a5707e84
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Poptart
|
2
|
+
|
3
|
+
The gem used to consume the REST API provided by [Happiness Service](https://github.com/austenito/happiness_service)
|
4
|
+
|
5
|
+
# Usage
|
6
|
+
|
7
|
+
The gem provides ActiveRecord-y like models exposing service endpoint attributes.
|
8
|
+
|
9
|
+
## User
|
10
|
+
|
11
|
+
To create a user:
|
12
|
+
|
13
|
+
```
|
14
|
+
user = User.create(14)
|
15
|
+
user.id # => 14
|
16
|
+
```
|
17
|
+
|
18
|
+
Users have a 1-many relationship to `surveys`. A user has read/write access to surveys as such:
|
19
|
+
|
20
|
+
```
|
21
|
+
user.create_survey
|
22
|
+
user.create_random_survey
|
23
|
+
user.survey_for_id(id)
|
24
|
+
user.survey_for_url #=> Do I want to get rid of this?
|
25
|
+
```
|
26
|
+
|
27
|
+
|
28
|
+
## Question
|
29
|
+
|
30
|
+
To find all questions:
|
31
|
+
|
32
|
+
```
|
33
|
+
questions = Question.all
|
34
|
+
|
35
|
+
```
|
data/lib/poptart/survey.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
module Poptart
|
2
2
|
class Survey < Model
|
3
3
|
include Poptart::Request
|
4
|
-
attr_accessor :
|
4
|
+
attr_accessor :service_user_id, :survey_questions
|
5
5
|
|
6
6
|
def initialize(response)
|
7
7
|
super
|
8
|
-
@
|
8
|
+
@service_user_id = params['service_user_id']
|
9
9
|
@completed = params['completed']
|
10
10
|
|
11
11
|
@survey_questions = params['survey_questions'].map do |survey_question|
|
data/lib/poptart/user.rb
CHANGED
@@ -22,13 +22,13 @@ module Poptart
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def create_survey
|
25
|
-
response = post(root.surveys_url, survey: {
|
25
|
+
response = post(root.surveys_url, survey: { service_user_id: service_user_id })
|
26
26
|
Poptart::Survey.new(response)
|
27
27
|
end
|
28
28
|
|
29
29
|
def create_random_survey
|
30
30
|
url = root.surveys_url(query: {random: true})
|
31
|
-
response = post(url, survey: {
|
31
|
+
response = post(url, survey: { service_user_id: service_user_id })
|
32
32
|
Poptart::Survey.new(response)
|
33
33
|
end
|
34
34
|
|
data/lib/version.rb
CHANGED
@@ -4,14 +4,14 @@ describe 'Answering survey questions' do
|
|
4
4
|
it "creates and returns an empty survey", :vcr do
|
5
5
|
user = Poptart::User.create
|
6
6
|
survey = user.create_survey
|
7
|
-
survey.
|
7
|
+
survey.service_user_id.should == user.service_user_id
|
8
8
|
survey.survey_questions.count.should == 0
|
9
9
|
end
|
10
10
|
|
11
11
|
it "creates and returns a random question survey", :vcr do
|
12
12
|
user = Poptart::User.create
|
13
13
|
survey = user.create_random_survey
|
14
|
-
survey.
|
14
|
+
survey.service_user_id.should == user.service_user_id
|
15
15
|
survey.survey_questions.count.should == 5
|
16
16
|
end
|
17
17
|
|