clever-ruby 0.0.1 → 0.0.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.
- data/.travis.yml +0 -1
- data/lib/clever-ruby.rb +4 -0
- data/lib/clever-ruby/api_resource.rb +6 -1
- data/lib/clever-ruby/clever_object.rb +5 -0
- data/lib/clever-ruby/configuration.rb +1 -1
- data/lib/clever-ruby/district.rb +30 -0
- data/lib/clever-ruby/school.rb +4 -0
- data/lib/clever-ruby/section.rb +4 -0
- data/lib/clever-ruby/student.rb +4 -0
- data/lib/clever-ruby/teacher.rb +4 -0
- data/lib/clever-ruby/version.rb +1 -1
- data/test/data/vcr_cassettes/districts.yml +3 -3
- data/test/data/vcr_cassettes/districts_schools.yml +205 -0
- data/test/data/vcr_cassettes/districts_sections.yml +291 -0
- data/test/data/vcr_cassettes/districts_students.yml +1474 -0
- data/test/data/vcr_cassettes/districts_students_filtered.yml +195 -0
- data/test/data/vcr_cassettes/districts_teachers.yml +241 -0
- data/test/data/vcr_cassettes/schools.yml +3 -3
- data/test/data/vcr_cassettes/schools_optional_attributes.yml +64 -0
- data/test/data/vcr_cassettes/sections.yml +3 -3
- data/test/data/vcr_cassettes/students.yml +5 -5
- data/test/data/vcr_cassettes/teachers.yml +170 -170
- data/test/integration/district_test.rb +44 -0
- data/test/unit/clever_test.rb +6 -6
- data/test/unit/configuration_test.rb +1 -1
- data/test/unit/optional_attributes_test.rb +33 -0
- metadata +18 -8
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ListTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
Clever.configure do |config|
|
6
|
+
config.api_key = "DEMO_KEY"
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
should "retrieve a district's schools" do
|
11
|
+
VCR.use_cassette("districts_schools") do
|
12
|
+
@district = Clever::District.all.first
|
13
|
+
@district.schools.size.must_equal 4
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
should "retrieve a district's teachers" do
|
18
|
+
VCR.use_cassette("districts_teachers") do
|
19
|
+
@district = Clever::District.all.first
|
20
|
+
@district.teachers.size.must_equal 48
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
should "retrieve a district's sections" do
|
25
|
+
VCR.use_cassette("districts_sections") do
|
26
|
+
@district = Clever::District.all.first
|
27
|
+
@district.sections.size.must_equal 44
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
should "retrieve a district's students" do
|
32
|
+
VCR.use_cassette("districts_students") do
|
33
|
+
@district = Clever::District.all.first
|
34
|
+
@district.students.size.must_equal 100
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
should "retrieve a district's students with a small filter" do
|
39
|
+
VCR.use_cassette("districts_students_filtered") do
|
40
|
+
@district = Clever::District.all.first
|
41
|
+
@district.students({limit: 2}).size.must_equal 2
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/test/unit/clever_test.rb
CHANGED
@@ -7,11 +7,11 @@ class CleverTest < Test::Unit::TestCase
|
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
-
should "return
|
11
|
-
assert_equal("https://api.getclever.com/v1.1/districts", Clever.
|
12
|
-
assert_equal("https://api.getclever.com/v1.1/schools", Clever.
|
13
|
-
assert_equal("https://api.getclever.com/v1.1/students", Clever.
|
14
|
-
assert_equal("https://api.getclever.com/v1.1/sections", Clever.
|
15
|
-
assert_equal("https://api.getclever.com/v1.1/teachers", Clever.
|
10
|
+
should "return top-level resource urls" do
|
11
|
+
assert_equal("https://api.getclever.com/v1.1/districts", Clever.resource_url("districts"))
|
12
|
+
assert_equal("https://api.getclever.com/v1.1/schools", Clever.resource_url("schools"))
|
13
|
+
assert_equal("https://api.getclever.com/v1.1/students", Clever.resource_url("students"))
|
14
|
+
assert_equal("https://api.getclever.com/v1.1/sections", Clever.resource_url("sections"))
|
15
|
+
assert_equal("https://api.getclever.com/v1.1/teachers", Clever.resource_url("teachers"))
|
16
16
|
end
|
17
17
|
end
|
@@ -16,7 +16,7 @@ class CleverConfigurationTest < Test::Unit::TestCase
|
|
16
16
|
end
|
17
17
|
|
18
18
|
should "set a default for the api base" do
|
19
|
-
Clever.configuration.api_base.must_equal('https://api.getclever.com/
|
19
|
+
Clever.configuration.api_base.must_equal('https://api.getclever.com/')
|
20
20
|
end
|
21
21
|
|
22
22
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class OptionalAttributesTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
Clever.configure do |config|
|
6
|
+
config.api_key = "DEMO_KEY"
|
7
|
+
end
|
8
|
+
|
9
|
+
VCR.use_cassette("schools_optional_attributes") do
|
10
|
+
@schools = Clever::School.all
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
should "return nil for an optional attribute that isnt present" do
|
15
|
+
clever_academy = @schools.detect{ |s| s.id == "4fee004cca2e43cf27000001"}
|
16
|
+
|
17
|
+
# Must not raise a NoMethodError.
|
18
|
+
clever_academy.state_id.must_equal nil
|
19
|
+
end
|
20
|
+
|
21
|
+
should "have the expected value for an optional attribute that is present" do
|
22
|
+
clever_prep = @schools.detect{ |s| s.id == "4fee004cca2e43cf27000002"}
|
23
|
+
clever_prep.state_id.must_equal "23"
|
24
|
+
end
|
25
|
+
|
26
|
+
should "raise a NoMethodError for an invalid attribute" do
|
27
|
+
clever_academy = @schools.detect{ |s| s.id == "4fee004cca2e43cf27000001"}
|
28
|
+
|
29
|
+
lambda {
|
30
|
+
clever_academy.some_attribute_that_doesnt_exist
|
31
|
+
}.must_raise NoMethodError
|
32
|
+
end
|
33
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clever-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-03-11 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: multi_json
|
@@ -174,14 +174,22 @@ files:
|
|
174
174
|
- lib/clever-ruby/util.rb
|
175
175
|
- lib/clever-ruby/version.rb
|
176
176
|
- test/data/vcr_cassettes/districts.yml
|
177
|
+
- test/data/vcr_cassettes/districts_schools.yml
|
178
|
+
- test/data/vcr_cassettes/districts_sections.yml
|
179
|
+
- test/data/vcr_cassettes/districts_students.yml
|
180
|
+
- test/data/vcr_cassettes/districts_students_filtered.yml
|
181
|
+
- test/data/vcr_cassettes/districts_teachers.yml
|
177
182
|
- test/data/vcr_cassettes/schools.yml
|
183
|
+
- test/data/vcr_cassettes/schools_optional_attributes.yml
|
178
184
|
- test/data/vcr_cassettes/sections.yml
|
179
185
|
- test/data/vcr_cassettes/students.yml
|
180
186
|
- test/data/vcr_cassettes/teachers.yml
|
181
187
|
- test/integration/api_operations/list_test.rb
|
188
|
+
- test/integration/district_test.rb
|
182
189
|
- test/test_helper.rb
|
183
190
|
- test/unit/clever_test.rb
|
184
191
|
- test/unit/configuration_test.rb
|
192
|
+
- test/unit/optional_attributes_test.rb
|
185
193
|
homepage: http://github.com/Clever/clever-ruby
|
186
194
|
licenses: []
|
187
195
|
post_install_message:
|
@@ -194,18 +202,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
194
202
|
- - ! '>='
|
195
203
|
- !ruby/object:Gem::Version
|
196
204
|
version: '0'
|
197
|
-
segments:
|
198
|
-
- 0
|
199
|
-
hash: -278580959744325448
|
200
205
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
201
206
|
none: false
|
202
207
|
requirements:
|
203
208
|
- - ! '>='
|
204
209
|
- !ruby/object:Gem::Version
|
205
210
|
version: '0'
|
206
|
-
segments:
|
207
|
-
- 0
|
208
|
-
hash: -278580959744325448
|
209
211
|
requirements: []
|
210
212
|
rubyforge_project:
|
211
213
|
rubygems_version: 1.8.23
|
@@ -214,11 +216,19 @@ specification_version: 3
|
|
214
216
|
summary: Ruby bindings to the Clever API.
|
215
217
|
test_files:
|
216
218
|
- test/data/vcr_cassettes/districts.yml
|
219
|
+
- test/data/vcr_cassettes/districts_schools.yml
|
220
|
+
- test/data/vcr_cassettes/districts_sections.yml
|
221
|
+
- test/data/vcr_cassettes/districts_students.yml
|
222
|
+
- test/data/vcr_cassettes/districts_students_filtered.yml
|
223
|
+
- test/data/vcr_cassettes/districts_teachers.yml
|
217
224
|
- test/data/vcr_cassettes/schools.yml
|
225
|
+
- test/data/vcr_cassettes/schools_optional_attributes.yml
|
218
226
|
- test/data/vcr_cassettes/sections.yml
|
219
227
|
- test/data/vcr_cassettes/students.yml
|
220
228
|
- test/data/vcr_cassettes/teachers.yml
|
221
229
|
- test/integration/api_operations/list_test.rb
|
230
|
+
- test/integration/district_test.rb
|
222
231
|
- test/test_helper.rb
|
223
232
|
- test/unit/clever_test.rb
|
224
233
|
- test/unit/configuration_test.rb
|
234
|
+
- test/unit/optional_attributes_test.rb
|