poptart 0.0.4 → 0.0.5
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
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 64b322723a131db8bb8a376500573598aee988e0
         | 
| 4 | 
            +
              data.tar.gz: 80e1c8afe85c907e2d7d1a577717e8f324f8fcdf
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 073ecece14fb149678c5989d5e54b7eec2458cd0902b0f12a011af374fe9a67aa48c4455c5ae7c91a5e85bda9bc6bb8842c03172b652f15c27d77499cf2f422e
         | 
| 7 | 
            +
              data.tar.gz: 6e6fa0b9bc27db04f054a2800e8d326b2be9df08abfe1583272d59821321a34e370ad7daf997079b2d5450215adc1588bcc622611e6a2d51be6a656d967f70f0
         | 
    
        data/Gemfile.lock
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            PATH
         | 
| 2 2 | 
             
              remote: .
         | 
| 3 3 | 
             
              specs:
         | 
| 4 | 
            -
                poptart (0.0. | 
| 4 | 
            +
                poptart (0.0.4)
         | 
| 5 5 | 
             
                  activesupport
         | 
| 6 6 | 
             
                  faraday
         | 
| 7 7 | 
             
                  hashie
         | 
| @@ -37,7 +37,7 @@ GEM | |
| 37 37 | 
             
                guard-rspec (4.0.0)
         | 
| 38 38 | 
             
                  guard (~> 2.0)
         | 
| 39 39 | 
             
                  rspec (~> 2.14)
         | 
| 40 | 
            -
                hashie ( | 
| 40 | 
            +
                hashie (3.1.0)
         | 
| 41 41 | 
             
                i18n (0.6.9)
         | 
| 42 42 | 
             
                json (1.8.1)
         | 
| 43 43 | 
             
                listen (2.1.0)
         | 
| @@ -70,7 +70,7 @@ GEM | |
| 70 70 | 
             
                safe_yaml (0.9.7)
         | 
| 71 71 | 
             
                slop (3.4.6)
         | 
| 72 72 | 
             
                thor (0.18.1)
         | 
| 73 | 
            -
                thread_safe (0.3. | 
| 73 | 
            +
                thread_safe (0.3.4)
         | 
| 74 74 | 
             
                timers (1.1.0)
         | 
| 75 75 | 
             
                tzinfo (1.1.0)
         | 
| 76 76 | 
             
                  thread_safe (~> 0.1)
         | 
    
        data/lib/poptart/question.rb
    CHANGED
    
    | @@ -2,6 +2,14 @@ module Poptart | |
| 2 2 | 
             
              class Question < Model
         | 
| 3 3 | 
             
                extend Poptart::Request
         | 
| 4 4 |  | 
| 5 | 
            +
                attr_accessor :responses, :freeform
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                def initialize(response)
         | 
| 8 | 
            +
                  super
         | 
| 9 | 
            +
                  @responses = params['responses']
         | 
| 10 | 
            +
                  @freeform = params['freeform']
         | 
| 11 | 
            +
                end
         | 
| 12 | 
            +
             | 
| 5 13 | 
             
                def self.all(params = {})
         | 
| 6 14 | 
             
                  root = Poptart::Root.get_root
         | 
| 7 15 | 
             
                  response = get(root.links.questions.href)
         | 
| @@ -15,5 +23,9 @@ module Poptart | |
| 15 23 | 
             
                    end
         | 
| 16 24 | 
             
                  end.compact
         | 
| 17 25 | 
             
                end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                def freeform?
         | 
| 28 | 
            +
                  @freeform
         | 
| 29 | 
            +
                end
         | 
| 18 30 | 
             
              end
         | 
| 19 31 | 
             
            end
         | 
    
        data/lib/version.rb
    CHANGED
    
    
| @@ -1,21 +1,21 @@ | |
| 1 1 | 
             
            require 'spec_helper'
         | 
| 2 2 |  | 
| 3 | 
            -
            describe 'Answering survey questions', :vcr | 
| 4 | 
            -
              it "creates and returns an empty survey" do
         | 
| 3 | 
            +
            describe 'Answering survey questions', :vcr do
         | 
| 4 | 
            +
              it "creates and returns an empty survey", :vcr do
         | 
| 5 5 | 
             
                user = Poptart::User.create(42)
         | 
| 6 6 | 
             
                survey = user.create_survey
         | 
| 7 7 | 
             
                survey.user_id.should == user.id
         | 
| 8 8 | 
             
                survey.survey_questions.count.should == 0
         | 
| 9 9 | 
             
              end
         | 
| 10 10 |  | 
| 11 | 
            -
              it "creates and returns a random question survey" do
         | 
| 11 | 
            +
              it "creates and returns a random question survey", :vcr do
         | 
| 12 12 | 
             
                user = Poptart::User.create(42)
         | 
| 13 13 | 
             
                survey = user.create_random_survey
         | 
| 14 14 | 
             
                survey.user_id.should == user.id
         | 
| 15 15 | 
             
                survey.survey_questions.count.should == 6
         | 
| 16 16 | 
             
              end
         | 
| 17 17 |  | 
| 18 | 
            -
              it "answers a survey question" do
         | 
| 18 | 
            +
              it "answers a survey question", :vcr do
         | 
| 19 19 | 
             
                user = Poptart::User.create(42)
         | 
| 20 20 | 
             
                survey = user.create_random_survey
         | 
| 21 21 | 
             
                survey_question = survey.survey_questions.first
         | 
| @@ -27,7 +27,7 @@ describe 'Answering survey questions', :vcr, :record => :all do | |
| 27 27 | 
             
                survey.survey_questions.first.answer.should == "foo"
         | 
| 28 28 | 
             
              end
         | 
| 29 29 |  | 
| 30 | 
            -
              it "answers a survey question" do
         | 
| 30 | 
            +
              it "answers a survey question", :vcr do
         | 
| 31 31 | 
             
                boolean_questions = Poptart::Question.all(type: 'boolean')
         | 
| 32 32 | 
             
                user = Poptart::User.create(42)
         | 
| 33 33 | 
             
                survey = user.create_survey
         | 
| @@ -46,7 +46,28 @@ describe 'Answering survey questions', :vcr, :record => :all do | |
| 46 46 | 
             
                survey.survey_questions.first.answer.should == 'true'
         | 
| 47 47 | 
             
              end
         | 
| 48 48 |  | 
| 49 | 
            -
              it " | 
| 49 | 
            +
              it "answers a multiple choice question", :vcr do
         | 
| 50 | 
            +
                questions = Poptart::Question.all(type: 'multiple')
         | 
| 51 | 
            +
                question = questions.find { |question| question.responses.include?('At Home') }
         | 
| 52 | 
            +
                user = Poptart::User.create(42)
         | 
| 53 | 
            +
                survey = user.create_survey
         | 
| 54 | 
            +
                survey.add_question(question).should be
         | 
| 55 | 
            +
             | 
| 56 | 
            +
                survey = user.survey_for_id(survey.id)
         | 
| 57 | 
            +
                survey.survey_questions.count.should == 1
         | 
| 58 | 
            +
                survey_question = survey.survey_questions.first
         | 
| 59 | 
            +
                survey_question.responses.should == ["At Home", "At Work", "In a car", "Other"]
         | 
| 60 | 
            +
                survey_question.type.should == 'multiple'
         | 
| 61 | 
            +
             | 
| 62 | 
            +
                survey_question.answer = 'At Home'
         | 
| 63 | 
            +
                survey_question.submit.should be
         | 
| 64 | 
            +
             | 
| 65 | 
            +
                survey = user.survey_for_id(survey.id)
         | 
| 66 | 
            +
                survey.survey_questions.first.answer.should == 'At Home'
         | 
| 67 | 
            +
                survey.completed?.should be
         | 
| 68 | 
            +
              end
         | 
| 69 | 
            +
             | 
| 70 | 
            +
              it "finds survey question for id", :vcr do
         | 
| 50 71 | 
             
                user = Poptart::User.create(42)
         | 
| 51 72 | 
             
                survey = user.create_random_survey
         | 
| 52 73 | 
             
                first_survey_question = survey.survey_questions.first
         |