clever-ruby 0.6.1 → 0.6.2
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 +8 -8
- data/CHANGELOG.md +6 -0
- data/clever-ruby.gemspec +2 -4
- data/lib/clever-ruby/version.rb +1 -1
- data/test/integration/api_operations/list_test.rb +51 -46
- data/test/integration/district_test.rb +54 -52
- data/test/integration/error_handling_test.rb +3 -3
- data/test/test_helper.rb +0 -2
- data/test/unit/clever_test.rb +4 -4
- data/test/unit/configuration_test.rb +17 -5
- data/test/unit/event_test.rb +6 -6
- data/test/unit/optional_attributes_test.rb +5 -6
- metadata +16 -44
    
        checksums.yaml
    CHANGED
    
    | @@ -1,15 +1,15 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            !binary "U0hBMQ==":
         | 
| 3 3 | 
             
              metadata.gz: !binary |-
         | 
| 4 | 
            -
                 | 
| 4 | 
            +
                NmI3NzcwOGI0ZjVjNTRmMDRiZTg5YjZiZjAyNWZjNzkzNTUxNTg2Yg==
         | 
| 5 5 | 
             
              data.tar.gz: !binary |-
         | 
| 6 | 
            -
                 | 
| 6 | 
            +
                MGViMmNhMjI2Mjg4MDc5Nzc1ZDFmNjM5OTc1ODhkMGIyMmZmMDFlZA==
         | 
| 7 7 | 
             
            SHA512:
         | 
| 8 8 | 
             
              metadata.gz: !binary |-
         | 
| 9 | 
            -
                 | 
| 10 | 
            -
                 | 
| 11 | 
            -
                 | 
| 9 | 
            +
                YmJhMTU5OThjMWQ2ZDJhYmI0NDY4MmEyNmQ5NGY2YmI4NDQ3NTZmMjY5M2Ux
         | 
| 10 | 
            +
                YjUwNzcwMGE5ZDEwOTA4YjcyMzA3OGY0OGYyYzlmZDJjNmI2NTgxOTE5NjRh
         | 
| 11 | 
            +
                ZmNkN2U3YTUwYjMzNTA3OGM1N2NlNzEyNzE2MDYzZmZmODc3MzA=
         | 
| 12 12 | 
             
              data.tar.gz: !binary |-
         | 
| 13 | 
            -
                 | 
| 14 | 
            -
                 | 
| 15 | 
            -
                 | 
| 13 | 
            +
                OWJhZjIzMDVjNzlkODM4NmVhMjJiYzcxYTk5MTM3NmIyOWFhY2NkYTI3MzBl
         | 
| 14 | 
            +
                ZWFhMWYxMTlhNzMxY2RhMzQ1YzQyMTc4NGVjOTQxMmFjZDM4NjczYWUwOWI4
         | 
| 15 | 
            +
                MjY5Y2YyMzhmODNjNjFiOGE0MzYzY2JkODU1YmFhMjZlNmJkYmQ=
         | 
    
        data/CHANGELOG.md
    CHANGED
    
    
    
        data/clever-ruby.gemspec
    CHANGED
    
    | @@ -21,16 +21,14 @@ Gem::Specification.new do |gem| | |
| 21 21 |  | 
| 22 22 | 
             
              gem.add_runtime_dependency 'multi_json',    '~> 1.10.0'
         | 
| 23 23 | 
             
              gem.add_runtime_dependency 'rest-client',   '~> 1.6.7'
         | 
| 24 | 
            +
              gem.add_runtime_dependency 'activesupport', '~> 4.1.5'
         | 
| 24 25 |  | 
| 25 26 | 
             
              gem.add_development_dependency 'rake'
         | 
| 26 | 
            -
              gem.add_development_dependency 'minitest',      '~>  | 
| 27 | 
            -
              gem.add_development_dependency 'shoulda',       '~> 3.3.2'
         | 
| 27 | 
            +
              gem.add_development_dependency 'minitest',      '~> 5.4.1'
         | 
| 28 28 | 
             
              gem.add_development_dependency 'yard',          '~> 0.8.7'
         | 
| 29 29 | 
             
              gem.add_development_dependency 'yardstick',     '~> 0.9.9'
         | 
| 30 30 | 
             
              gem.add_development_dependency 'redcarpet',     '~> 3.1.2'
         | 
| 31 31 | 
             
              gem.add_development_dependency 'vcr',           '~> 2.4.0'
         | 
| 32 32 | 
             
              gem.add_development_dependency 'webmock',       '~> 1.9.0'
         | 
| 33 | 
            -
              gem.add_development_dependency 'pry',           '~> 0.10.1'
         | 
| 34 | 
            -
              gem.add_development_dependency 'activesupport', '~> 3.2.11'
         | 
| 35 33 | 
             
              gem.add_development_dependency 'rubocop',       '~> 0.26.0'
         | 
| 36 34 | 
             
            end
         | 
    
        data/lib/clever-ruby/version.rb
    CHANGED
    
    
| @@ -1,28 +1,38 @@ | |
| 1 1 | 
             
            require 'test_helper'
         | 
| 2 2 |  | 
| 3 | 
            +
            def resource_name(resource)
         | 
| 4 | 
            +
              resource.name.split('::')[-1].downcase
         | 
| 5 | 
            +
            end
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            def resources
         | 
| 8 | 
            +
              [Clever::District, Clever::School, Clever::Teacher,
         | 
| 9 | 
            +
               Clever::Student, Clever::Section, Clever::Event]
         | 
| 10 | 
            +
            end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            module Minitest
         | 
| 13 | 
            +
              # Extend default Minitest assertions
         | 
| 14 | 
            +
              module Assertions
         | 
| 15 | 
            +
                def assert_resource_type(resource, elem)
         | 
| 16 | 
            +
                  assert_instance_of resource, elem, "All elems of #{resource.url} should be of "\
         | 
| 17 | 
            +
                    "type #{resource.name}, instead got #{elem.class.name}. elem: #{elem.inspect}"
         | 
| 18 | 
            +
                end
         | 
| 19 | 
            +
              end
         | 
| 20 | 
            +
            end
         | 
| 21 | 
            +
             | 
| 3 22 | 
             
            # Test api_operations/List
         | 
| 4 | 
            -
             | 
| 5 | 
            -
               | 
| 23 | 
            +
            describe Clever::APIOperations::List do
         | 
| 24 | 
            +
              before do
         | 
| 6 25 | 
             
                Clever.configure do |config|
         | 
| 7 26 | 
             
                  config.api_key = 'DEMO_KEY'
         | 
| 8 27 | 
             
                end
         | 
| 9 28 | 
             
              end
         | 
| 10 29 |  | 
| 11 | 
            -
              def assert_type(resource, elem)
         | 
| 12 | 
            -
                assert_instance_of resource, elem, "All elems of #{resource.url} should be of "\
         | 
| 13 | 
            -
                  "type #{resource.name}, instead got #{elem.class.name}. elem: #{elem.inspect}"
         | 
| 14 | 
            -
              end
         | 
| 15 | 
            -
             | 
| 16 | 
            -
              def self.resource_name(resource)
         | 
| 17 | 
            -
                resource.name.split('::')[-1].downcase
         | 
| 18 | 
            -
              end
         | 
| 19 | 
            -
             | 
| 20 30 | 
             
              [[Clever::District, 1], [Clever::School, 3], [Clever::Teacher, 89],
         | 
| 21 31 | 
             
               [Clever::Student, 1004], [Clever::Section, 379], [Clever::Event, 13]].each do |test_data|
         | 
| 22 32 | 
             
                resource, expected = test_data
         | 
| 23 33 | 
             
                name = resource_name resource
         | 
| 24 34 |  | 
| 25 | 
            -
                 | 
| 35 | 
            +
                it "counts #{name} properly" do
         | 
| 26 36 | 
             
                  VCR.use_cassette "#{name}_count" do
         | 
| 27 37 | 
             
                    count = resource.count
         | 
| 28 38 | 
             
                    assert count.is_a?(Integer), "count should return an Integer. count: #{count}"
         | 
| @@ -32,43 +42,30 @@ class ListTest < Test::Unit::TestCase | |
| 32 42 | 
             
                end
         | 
| 33 43 | 
             
              end
         | 
| 34 44 |  | 
| 35 | 
            -
               | 
| 36 | 
            -
               Clever::Student, Clever::Section, Clever::Event].each do |resource|
         | 
| 45 | 
            +
              resources.each do |resource|
         | 
| 37 46 | 
             
                name = resource_name resource
         | 
| 38 47 |  | 
| 39 | 
            -
                 | 
| 48 | 
            +
                it "rejects invalid id for #{resource}.find one" do
         | 
| 40 49 | 
             
                  id = 'invalid_id'
         | 
| 41 | 
            -
                  assert_raises | 
| 42 | 
            -
                    resource.find id
         | 
| 43 | 
            -
                  end
         | 
| 50 | 
            +
                  assert_raises(ArgumentError) { resource.find id }
         | 
| 44 51 | 
             
                end
         | 
| 45 52 |  | 
| 46 | 
            -
                 | 
| 47 | 
            -
                  #  | 
| 48 | 
            -
             | 
| 49 | 
            -
             | 
| 50 | 
            -
                    resource | 
| 53 | 
            +
                it "finds a single #{name}" do
         | 
| 54 | 
            +
                  VCR.use_cassette "#{name}_find_one" do
         | 
| 55 | 
            +
                    id = resource.find.take(20).last.id
         | 
| 56 | 
            +
                    elem = resource.find id
         | 
| 57 | 
            +
                    assert_resource_type resource, elem
         | 
| 58 | 
            +
                    assert_equal id, elem.id
         | 
| 51 59 | 
             
                  end
         | 
| 52 60 | 
             
                end
         | 
| 53 61 |  | 
| 54 | 
            -
                 | 
| 55 | 
            -
                   | 
| 56 | 
            -
             | 
| 57 | 
            -
             | 
| 58 | 
            -
                      "a Clever::APIOperations::ResultsList, received #{result.inspect}"
         | 
| 59 | 
            -
                    count = 0
         | 
| 60 | 
            -
                    result.each do |elem|
         | 
| 61 | 
            -
                      count += 1
         | 
| 62 | 
            -
                      assert_type resource, elem
         | 
| 63 | 
            -
                    end
         | 
| 64 | 
            -
             | 
| 65 | 
            -
                    expected = resource.count
         | 
| 66 | 
            -
                    count.must_equal expected, "Expected #{expected} #{name}s to be "\
         | 
| 67 | 
            -
                      "retrieved but only #{count} were found. Perhaps the test data has changed?"
         | 
| 68 | 
            -
                  end
         | 
| 62 | 
            +
                it 'rejects invalid ids for Clever::District.find multiple' do
         | 
| 63 | 
            +
                  # one valid, one invalid
         | 
| 64 | 
            +
                  ids = %w(123412341234123412341234 invalid_id)
         | 
| 65 | 
            +
                  assert_raises(ArgumentError) { Clever::District.find ids }
         | 
| 69 66 | 
             
                end
         | 
| 70 67 |  | 
| 71 | 
            -
                 | 
| 68 | 
            +
                it "finds #{name}s with multiple ids" do
         | 
| 72 69 | 
             
                  VCR.use_cassette "#{name}_find_multiple" do
         | 
| 73 70 | 
             
                    to_query = []
         | 
| 74 71 | 
             
                    count = 0
         | 
| @@ -85,16 +82,24 @@ class ListTest < Test::Unit::TestCase | |
| 85 82 | 
             
                  end
         | 
| 86 83 | 
             
                end
         | 
| 87 84 |  | 
| 88 | 
            -
                 | 
| 89 | 
            -
                  VCR.use_cassette "#{name} | 
| 90 | 
            -
                     | 
| 91 | 
            -
                     | 
| 92 | 
            -
             | 
| 93 | 
            -
                     | 
| 85 | 
            +
                it "finds #{name}s by page" do
         | 
| 86 | 
            +
                  VCR.use_cassette "#{name}_find_by_page" do
         | 
| 87 | 
            +
                    result = resource.find
         | 
| 88 | 
            +
                    assert_instance_of Clever::APIOperations::ResultsList, result, 'Result should be '\
         | 
| 89 | 
            +
                      "a Clever::APIOperations::ResultsList, received #{result.inspect}"
         | 
| 90 | 
            +
                    count = 0
         | 
| 91 | 
            +
                    result.each do |elem|
         | 
| 92 | 
            +
                      count += 1
         | 
| 93 | 
            +
                      assert_resource_type resource, elem
         | 
| 94 | 
            +
                    end
         | 
| 95 | 
            +
             | 
| 96 | 
            +
                    expected = resource.count
         | 
| 97 | 
            +
                    count.must_equal expected, "Expected #{expected} #{name}s to be "\
         | 
| 98 | 
            +
                      "retrieved but only #{count} were found. Perhaps the test data has changed?"
         | 
| 94 99 | 
             
                  end
         | 
| 95 100 | 
             
                end
         | 
| 96 101 |  | 
| 97 | 
            -
                 | 
| 102 | 
            +
                it "retrieves all #{name}" do
         | 
| 98 103 | 
             
                  VCR.use_cassette("#{name}s") do
         | 
| 99 104 | 
             
                    elems = resource.all
         | 
| 100 105 | 
             
                    elems.each do |elem|
         | 
| @@ -1,85 +1,87 @@ | |
| 1 1 | 
             
            require 'test_helper'
         | 
| 2 2 |  | 
| 3 | 
            -
             | 
| 4 | 
            -
             | 
| 5 | 
            -
               | 
| 6 | 
            -
                 | 
| 7 | 
            -
                   | 
| 3 | 
            +
            module Minitest
         | 
| 4 | 
            +
              # Add assertions to Minitest
         | 
| 5 | 
            +
              module Assertions
         | 
| 6 | 
            +
                def assert_valid_object_list(plural_object_name, object_count, instance_name)
         | 
| 7 | 
            +
                  VCR.use_cassette("districts_#{plural_object_name}", allow_playback_repeats: true) do
         | 
| 8 | 
            +
                    district = Clever::District.all.first
         | 
| 9 | 
            +
                    district.send(plural_object_name).size.must_equal object_count
         | 
| 10 | 
            +
                    district.send(plural_object_name).first.must_be_instance_of instance_name
         | 
| 11 | 
            +
                  end
         | 
| 8 12 | 
             
                end
         | 
| 9 | 
            -
              end
         | 
| 10 13 |  | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            -
             | 
| 14 | 
            +
                def assert_valid_object_pages(object_name, limit, page_count)
         | 
| 15 | 
            +
                  VCR.use_cassette("districts_#{object_name}_pages", allow_playback_repeats: true) do
         | 
| 16 | 
            +
                    district = Clever::District.all.first
         | 
| 17 | 
            +
                    object_count_from_list = district.send("#{object_name}s", limit: 100_000).size
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                    object_count_from_paging = 0
         | 
| 20 | 
            +
                    pages = 0
         | 
| 21 | 
            +
                    district.send("#{object_name}_pages", limit: limit).each do |object_page|
         | 
| 22 | 
            +
                      pages += 1
         | 
| 23 | 
            +
                      objects = object_page.all
         | 
| 24 | 
            +
                      object_count_from_paging += objects.size
         | 
| 25 | 
            +
                    end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                    object_count_from_paging.must_equal object_count_from_list
         | 
| 28 | 
            +
                    pages.must_equal page_count
         | 
| 29 | 
            +
                  end
         | 
| 30 | 
            +
                end
         | 
| 17 31 | 
             
              end
         | 
| 32 | 
            +
            end
         | 
| 18 33 |  | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 34 | 
            +
            describe Clever::District do
         | 
| 35 | 
            +
              before do
         | 
| 36 | 
            +
                Clever.configure do |config|
         | 
| 37 | 
            +
                  config.api_key = 'DEMO_KEY'
         | 
| 38 | 
            +
                end
         | 
| 21 39 | 
             
              end
         | 
| 22 40 |  | 
| 23 | 
            -
               | 
| 24 | 
            -
                 | 
| 41 | 
            +
              it "retrieves a district's schools" do
         | 
| 42 | 
            +
                assert_valid_object_list 'schools', 3, Clever::School
         | 
| 25 43 | 
             
              end
         | 
| 26 44 |  | 
| 27 | 
            -
               | 
| 28 | 
            -
                 | 
| 45 | 
            +
              it "retrieves a district's teachers" do
         | 
| 46 | 
            +
                assert_valid_object_list 'teachers', 89, Clever::Teacher
         | 
| 29 47 | 
             
              end
         | 
| 30 48 |  | 
| 31 | 
            -
               | 
| 32 | 
            -
                 | 
| 49 | 
            +
              it "retrieves a district's sections" do
         | 
| 50 | 
            +
                assert_valid_object_list 'sections', 100, Clever::Section
         | 
| 33 51 | 
             
              end
         | 
| 34 52 |  | 
| 35 | 
            -
               | 
| 36 | 
            -
                 | 
| 53 | 
            +
              it "retrieves a district's students" do
         | 
| 54 | 
            +
                assert_valid_object_list 'students', 100, Clever::Student
         | 
| 37 55 | 
             
              end
         | 
| 38 56 |  | 
| 39 | 
            -
               | 
| 40 | 
            -
                 | 
| 57 | 
            +
              it "retrieves a district's events" do
         | 
| 58 | 
            +
                assert_valid_object_list 'events', 13, Clever::Event
         | 
| 41 59 | 
             
              end
         | 
| 42 60 |  | 
| 43 | 
            -
               | 
| 61 | 
            +
              it "retrieves a district's students with a small filter" do
         | 
| 44 62 | 
             
                VCR.use_cassette('districts_students_filtered') do
         | 
| 45 63 | 
             
                  @district = Clever::District.all.first
         | 
| 46 64 | 
             
                  @district.students(limit: 2).size.must_equal 2
         | 
| 47 65 | 
             
                end
         | 
| 48 66 | 
             
              end
         | 
| 49 67 |  | 
| 50 | 
            -
               | 
| 51 | 
            -
                 | 
| 68 | 
            +
              it "pages a district's schools" do
         | 
| 69 | 
            +
                assert_valid_object_pages 'school', 2, 2
         | 
| 52 70 | 
             
              end
         | 
| 53 71 |  | 
| 54 | 
            -
               | 
| 55 | 
            -
                 | 
| 72 | 
            +
              it "pages a district's teachers" do
         | 
| 73 | 
            +
                assert_valid_object_pages 'teacher', 10, 9
         | 
| 56 74 | 
             
              end
         | 
| 57 75 |  | 
| 58 | 
            -
               | 
| 59 | 
            -
             | 
| 60 | 
            -
              def test_object_list(plural_object_name, object_count, instance_name)
         | 
| 61 | 
            -
                VCR.use_cassette("districts_#{plural_object_name}", allow_playback_repeats: true) do
         | 
| 62 | 
            -
                  district = Clever::District.all.first
         | 
| 63 | 
            -
                  district.send(plural_object_name).size.must_equal object_count
         | 
| 64 | 
            -
                  district.send(plural_object_name).first.must_be_instance_of instance_name
         | 
| 65 | 
            -
                end
         | 
| 76 | 
            +
              it "pages a district's sections" do
         | 
| 77 | 
            +
                assert_valid_object_pages 'section', 10, 38
         | 
| 66 78 | 
             
              end
         | 
| 67 79 |  | 
| 68 | 
            -
               | 
| 69 | 
            -
                 | 
| 70 | 
            -
             | 
| 71 | 
            -
                  object_count_from_list = district.send("#{object_name}s", limit: 100_000).size
         | 
| 72 | 
            -
             | 
| 73 | 
            -
                  object_count_from_paging = 0
         | 
| 74 | 
            -
                  pages = 0
         | 
| 75 | 
            -
                  district.send("#{object_name}_pages", limit: limit).each do |object_page|
         | 
| 76 | 
            -
                    pages += 1
         | 
| 77 | 
            -
                    objects = object_page.all
         | 
| 78 | 
            -
                    object_count_from_paging += objects.size
         | 
| 79 | 
            -
                  end
         | 
| 80 | 
            +
              it "pages a district's students" do
         | 
| 81 | 
            +
                assert_valid_object_pages 'student', 50, 21
         | 
| 82 | 
            +
              end
         | 
| 80 83 |  | 
| 81 | 
            -
             | 
| 82 | 
            -
             | 
| 83 | 
            -
                end
         | 
| 84 | 
            +
              it "pages a district's events" do
         | 
| 85 | 
            +
                assert_valid_object_pages 'event', 1, 14
         | 
| 84 86 | 
             
              end
         | 
| 85 87 | 
             
            end
         | 
| @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            require 'test_helper'
         | 
| 2 2 |  | 
| 3 3 | 
             
            # Test error handling
         | 
| 4 | 
            -
             | 
| 5 | 
            -
               | 
| 4 | 
            +
            describe 'Error handling' do
         | 
| 5 | 
            +
              before do
         | 
| 6 6 | 
             
                Clever.configure do |config|
         | 
| 7 7 | 
             
                  config.api_key = 'DEMO_KEY'
         | 
| 8 8 | 
             
                end
         | 
| 9 9 | 
             
              end
         | 
| 10 10 |  | 
| 11 | 
            -
               | 
| 11 | 
            +
              it 'raises an InvalidRequestError when given a bad created_since' do
         | 
| 12 12 | 
             
                VCR.use_cassette('error_handling') do
         | 
| 13 13 | 
             
                  @district = Clever::District.all.first
         | 
| 14 14 | 
             
                  lambda do
         | 
    
        data/test/test_helper.rb
    CHANGED
    
    
    
        data/test/unit/clever_test.rb
    CHANGED
    
    | @@ -2,14 +2,14 @@ require 'test_helper' | |
| 2 2 |  | 
| 3 3 | 
             
            # basic clever-ruby tests
         | 
| 4 4 | 
             
            # TODO: organize better
         | 
| 5 | 
            -
             | 
| 6 | 
            -
               | 
| 5 | 
            +
            describe Clever do
         | 
| 6 | 
            +
              before do
         | 
| 7 7 | 
             
                Clever.configure do |config|
         | 
| 8 8 | 
             
                  config.api_key = 'DEMO_KEY'
         | 
| 9 9 | 
             
                end
         | 
| 10 10 | 
             
              end
         | 
| 11 11 |  | 
| 12 | 
            -
               | 
| 12 | 
            +
              it 'returns correct urls for Resources' do
         | 
| 13 13 | 
             
                assert_equal 'v1.1/districts', Clever::District.url
         | 
| 14 14 | 
             
                assert_equal 'v1.1/schools', Clever::School.url
         | 
| 15 15 | 
             
                assert_equal 'v1.1/students', Clever::Student.url
         | 
| @@ -18,7 +18,7 @@ class CleverTest < Test::Unit::TestCase | |
| 18 18 | 
             
                assert_equal 'v1.1/events', Clever::Event.url
         | 
| 19 19 | 
             
              end
         | 
| 20 20 |  | 
| 21 | 
            -
               | 
| 21 | 
            +
              it 'uri-encodes params' do
         | 
| 22 22 | 
             
                query_string = Clever.convert_to_query_string created_at: '2013-02-15T 2:30:42Z'
         | 
| 23 23 | 
             
                query_string.must_equal 'created_at=2013-02-15T%202:30:42Z'
         | 
| 24 24 | 
             
              end
         | 
| @@ -1,19 +1,31 @@ | |
| 1 1 | 
             
            require 'test_helper'
         | 
| 2 2 |  | 
| 3 3 | 
             
            # test api configuraton
         | 
| 4 | 
            -
             | 
| 5 | 
            -
               | 
| 4 | 
            +
            describe Clever::Configuration do
         | 
| 5 | 
            +
              it 'raises an error if no api key is set' do
         | 
| 6 | 
            +
                Clever.configure do |config|
         | 
| 7 | 
            +
                  config.api_key = nil
         | 
| 8 | 
            +
                  config.token = nil
         | 
| 9 | 
            +
                end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                -> { Clever.request(:get, 'a') }.must_raise Clever::AuthenticationError
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
              it 'sets the api key' do
         | 
| 6 15 | 
             
                Clever.configure do |config|
         | 
| 7 16 | 
             
                  config.api_key = 'DEMO_KEY'
         | 
| 8 17 | 
             
                end
         | 
| 9 18 | 
             
                assert_equal 'DEMO_KEY', Clever.api_key
         | 
| 10 19 | 
             
              end
         | 
| 11 20 |  | 
| 12 | 
            -
               | 
| 13 | 
            -
                 | 
| 21 | 
            +
              it 'sets the api token' do
         | 
| 22 | 
            +
                Clever.configure do |config|
         | 
| 23 | 
            +
                  config.token = 'DEMO_TOKEN'
         | 
| 24 | 
            +
                end
         | 
| 25 | 
            +
                assert_equal 'DEMO_TOKEN', Clever.token
         | 
| 14 26 | 
             
              end
         | 
| 15 27 |  | 
| 16 | 
            -
               | 
| 28 | 
            +
              it 'sets a default for the api base' do
         | 
| 17 29 | 
             
                Clever.configuration.api_base.must_equal 'https://api.clever.com/'
         | 
| 18 30 | 
             
              end
         | 
| 19 31 | 
             
            end
         | 
    
        data/test/unit/event_test.rb
    CHANGED
    
    | @@ -1,8 +1,8 @@ | |
| 1 1 | 
             
            require 'test_helper'
         | 
| 2 2 |  | 
| 3 3 | 
             
            # test events resource
         | 
| 4 | 
            -
             | 
| 5 | 
            -
               | 
| 4 | 
            +
            describe Clever::Event do
         | 
| 5 | 
            +
              before do
         | 
| 6 6 | 
             
                @event = Clever::Event.construct_from(
         | 
| 7 7 | 
             
                  type: 'sections.created',
         | 
| 8 8 | 
             
                  data: {
         | 
| @@ -24,19 +24,19 @@ class EventTest < Test::Unit::TestCase | |
| 24 24 | 
             
                )
         | 
| 25 25 | 
             
              end
         | 
| 26 26 |  | 
| 27 | 
            -
               | 
| 27 | 
            +
              it 'creates a clever object for the object the event is about' do
         | 
| 28 28 | 
             
                @event.object.must_be_instance_of Clever::Section
         | 
| 29 29 | 
             
              end
         | 
| 30 30 |  | 
| 31 | 
            -
               | 
| 31 | 
            +
              it 'knows what action the event is about (created/updated/deleted)' do
         | 
| 32 32 | 
             
                @event.action.must_equal 'created'
         | 
| 33 33 | 
             
              end
         | 
| 34 34 |  | 
| 35 | 
            -
               | 
| 35 | 
            +
              it "returns an empty hash if there aren't previous attributes" do
         | 
| 36 36 | 
             
                @event.previous_attributes.must_equal {}
         | 
| 37 37 | 
             
              end
         | 
| 38 38 |  | 
| 39 | 
            -
               | 
| 39 | 
            +
              it "has an event's previous attributes" do
         | 
| 40 40 | 
             
                @updated_event.previous_attributes[:teacher].must_equal '510980a6923bcbba1f0cb500'
         | 
| 41 41 | 
             
              end
         | 
| 42 42 | 
             
            end
         | 
| @@ -1,8 +1,8 @@ | |
| 1 1 | 
             
            require 'test_helper'
         | 
| 2 2 |  | 
| 3 3 | 
             
            # Test optional attributes functionality
         | 
| 4 | 
            -
             | 
| 5 | 
            -
               | 
| 4 | 
            +
            describe 'Optional attributes' do
         | 
| 5 | 
            +
              before do
         | 
| 6 6 | 
             
                Clever.configure do |config|
         | 
| 7 7 | 
             
                  config.api_key = 'DEMO_KEY'
         | 
| 8 8 | 
             
                end
         | 
| @@ -12,7 +12,7 @@ class OptionalAttributesTest < Test::Unit::TestCase | |
| 12 12 | 
             
                end
         | 
| 13 13 | 
             
              end
         | 
| 14 14 |  | 
| 15 | 
            -
               | 
| 15 | 
            +
              it 'returns nil for an optional attribute that isnt present' do
         | 
| 16 16 | 
             
                school = @schools.find { |s| s.id == '530e595026403103360ff9fd' }
         | 
| 17 17 |  | 
| 18 18 | 
             
                # add an attribute that will not be exist in the test data
         | 
| @@ -27,14 +27,13 @@ class OptionalAttributesTest < Test::Unit::TestCase | |
| 27 27 | 
             
                school.legit_attribute.must_equal nil
         | 
| 28 28 | 
             
              end
         | 
| 29 29 |  | 
| 30 | 
            -
               | 
| 30 | 
            +
              it 'has the expected value for an optional attribute that is present' do
         | 
| 31 31 | 
             
                school = @schools.find { |s| s.id == '530e595026403103360ff9fd' }
         | 
| 32 32 | 
             
                school.state_id.must_equal '712345'
         | 
| 33 33 | 
             
              end
         | 
| 34 34 |  | 
| 35 | 
            -
               | 
| 35 | 
            +
              it 'raises a NoMethodError for an invalid attribute' do
         | 
| 36 36 | 
             
                school = @schools.find { |s| s.id == '530e595026403103360ff9fd' }
         | 
| 37 | 
            -
             | 
| 38 37 | 
             
                -> { school.some_attribute_that_doesnt_exist }.must_raise NoMethodError
         | 
| 39 38 | 
             
              end
         | 
| 40 39 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: clever-ruby
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.6. | 
| 4 | 
            +
              version: 0.6.2
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Clever Dev
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2014-09- | 
| 11 | 
            +
            date: 2014-09-12 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: multi_json
         | 
| @@ -39,47 +39,47 @@ dependencies: | |
| 39 39 | 
             
                  - !ruby/object:Gem::Version
         | 
| 40 40 | 
             
                    version: 1.6.7
         | 
| 41 41 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 42 | 
            -
              name:  | 
| 42 | 
            +
              name: activesupport
         | 
| 43 43 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 44 44 | 
             
                requirements:
         | 
| 45 | 
            -
                - -  | 
| 45 | 
            +
                - - ~>
         | 
| 46 46 | 
             
                  - !ruby/object:Gem::Version
         | 
| 47 | 
            -
                    version:  | 
| 48 | 
            -
              type: : | 
| 47 | 
            +
                    version: 4.1.5
         | 
| 48 | 
            +
              type: :runtime
         | 
| 49 49 | 
             
              prerelease: false
         | 
| 50 50 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 51 51 | 
             
                requirements:
         | 
| 52 | 
            -
                - -  | 
| 52 | 
            +
                - - ~>
         | 
| 53 53 | 
             
                  - !ruby/object:Gem::Version
         | 
| 54 | 
            -
                    version:  | 
| 54 | 
            +
                    version: 4.1.5
         | 
| 55 55 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 56 | 
            -
              name:  | 
| 56 | 
            +
              name: rake
         | 
| 57 57 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 58 58 | 
             
                requirements:
         | 
| 59 | 
            -
                - -  | 
| 59 | 
            +
                - - ! '>='
         | 
| 60 60 | 
             
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            -
                    version:  | 
| 61 | 
            +
                    version: '0'
         | 
| 62 62 | 
             
              type: :development
         | 
| 63 63 | 
             
              prerelease: false
         | 
| 64 64 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 65 65 | 
             
                requirements:
         | 
| 66 | 
            -
                - -  | 
| 66 | 
            +
                - - ! '>='
         | 
| 67 67 | 
             
                  - !ruby/object:Gem::Version
         | 
| 68 | 
            -
                    version:  | 
| 68 | 
            +
                    version: '0'
         | 
| 69 69 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 70 | 
            -
              name:  | 
| 70 | 
            +
              name: minitest
         | 
| 71 71 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 72 72 | 
             
                requirements:
         | 
| 73 73 | 
             
                - - ~>
         | 
| 74 74 | 
             
                  - !ruby/object:Gem::Version
         | 
| 75 | 
            -
                    version:  | 
| 75 | 
            +
                    version: 5.4.1
         | 
| 76 76 | 
             
              type: :development
         | 
| 77 77 | 
             
              prerelease: false
         | 
| 78 78 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 79 79 | 
             
                requirements:
         | 
| 80 80 | 
             
                - - ~>
         | 
| 81 81 | 
             
                  - !ruby/object:Gem::Version
         | 
| 82 | 
            -
                    version:  | 
| 82 | 
            +
                    version: 5.4.1
         | 
| 83 83 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 84 84 | 
             
              name: yard
         | 
| 85 85 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -150,34 +150,6 @@ dependencies: | |
| 150 150 | 
             
                - - ~>
         | 
| 151 151 | 
             
                  - !ruby/object:Gem::Version
         | 
| 152 152 | 
             
                    version: 1.9.0
         | 
| 153 | 
            -
            - !ruby/object:Gem::Dependency
         | 
| 154 | 
            -
              name: pry
         | 
| 155 | 
            -
              requirement: !ruby/object:Gem::Requirement
         | 
| 156 | 
            -
                requirements:
         | 
| 157 | 
            -
                - - ~>
         | 
| 158 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 159 | 
            -
                    version: 0.10.1
         | 
| 160 | 
            -
              type: :development
         | 
| 161 | 
            -
              prerelease: false
         | 
| 162 | 
            -
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 163 | 
            -
                requirements:
         | 
| 164 | 
            -
                - - ~>
         | 
| 165 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 166 | 
            -
                    version: 0.10.1
         | 
| 167 | 
            -
            - !ruby/object:Gem::Dependency
         | 
| 168 | 
            -
              name: activesupport
         | 
| 169 | 
            -
              requirement: !ruby/object:Gem::Requirement
         | 
| 170 | 
            -
                requirements:
         | 
| 171 | 
            -
                - - ~>
         | 
| 172 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 173 | 
            -
                    version: 3.2.11
         | 
| 174 | 
            -
              type: :development
         | 
| 175 | 
            -
              prerelease: false
         | 
| 176 | 
            -
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 177 | 
            -
                requirements:
         | 
| 178 | 
            -
                - - ~>
         | 
| 179 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 180 | 
            -
                    version: 3.2.11
         | 
| 181 153 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 182 154 | 
             
              name: rubocop
         | 
| 183 155 | 
             
              requirement: !ruby/object:Gem::Requirement
         |