bearcat 0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. data/Rakefile +8 -0
  2. data/bearcat.gemspec +27 -0
  3. data/lib/bearcat.rb +2 -0
  4. data/lib/bearcat/api_array.rb +118 -0
  5. data/lib/bearcat/client.rb +20 -0
  6. data/lib/bearcat/client/assignments.rb +18 -0
  7. data/lib/bearcat/client/courses.rb +19 -0
  8. data/lib/bearcat/client/enrollments.rb +19 -0
  9. data/lib/bearcat/client/outcome_groups.rb +81 -0
  10. data/lib/bearcat/client/outcomes.rb +15 -0
  11. data/lib/bearcat/client/sections.rb +27 -0
  12. data/lib/bearcat/version.rb +3 -0
  13. data/spec/bearcat/client/assignments_spec.rb +39 -0
  14. data/spec/bearcat/client/courses_spec.rb +31 -0
  15. data/spec/bearcat/client/enrollments_spec.rb +42 -0
  16. data/spec/bearcat/client/outcome_groups_spec.rb +104 -0
  17. data/spec/bearcat/client/outcomes_spec.rb +27 -0
  18. data/spec/bearcat/client/sections_spec.rb +51 -0
  19. data/spec/bearcat/client_spec.rb +16 -0
  20. data/spec/bearcat_spec.rb +8 -0
  21. data/spec/fixtures/assignment_section_override.json +9 -0
  22. data/spec/fixtures/assignments.json +86 -0
  23. data/spec/fixtures/conclude_enrollment.json +20 -0
  24. data/spec/fixtures/course.json +46 -0
  25. data/spec/fixtures/course_sections.json +20 -0
  26. data/spec/fixtures/course_students.json +6 -0
  27. data/spec/fixtures/create_outcome_in_group.json +23 -0
  28. data/spec/fixtures/create_section.json +1 -0
  29. data/spec/fixtures/created_assignment.json +25 -0
  30. data/spec/fixtures/created_course.json +27 -0
  31. data/spec/fixtures/delete_section.json +1 -0
  32. data/spec/fixtures/enroll_student.json +20 -0
  33. data/spec/fixtures/link_unlink_outcome.json +23 -0
  34. data/spec/fixtures/outcome_group_import.json +22 -0
  35. data/spec/fixtures/outcome_groups.json +29 -0
  36. data/spec/fixtures/outcome_subgroup.json +22 -0
  37. data/spec/fixtures/outcome_subgroups.json +20 -0
  38. data/spec/fixtures/outcomes.json +33 -0
  39. data/spec/fixtures/paged_body.json +92 -0
  40. data/spec/fixtures/section.json +1 -0
  41. data/spec/fixtures/update_outcome.json +1 -0
  42. data/spec/fixtures/update_outcome_group.json +22 -0
  43. data/spec/fixtures/update_section.json +1 -0
  44. data/spec/fixtures/user_enrollments.json +23 -0
  45. data/spec/helper.rb +43 -0
  46. metadata +220 -0
@@ -0,0 +1,6 @@
1
+ {
2
+ "id": 2,
3
+ "name": "test@student.com",
4
+ "sortable_name": "test@student.com",
5
+ "short_name": "test@student.com"
6
+ }
@@ -0,0 +1,23 @@
1
+ {
2
+ "context_id": 1,
3
+ "context_type": "Course",
4
+ "url": "/api/v1/courses/1/outcome_groups/2/outcomes/18",
5
+ "outcome_group": {
6
+ "id": 2,
7
+ "title": "Local Testing",
8
+ "vendor_guid": null,
9
+ "url": "/api/v1/accounts/1/outcome_groups/12",
10
+ "subgroups_url": "/api/v1/accounts/1/outcome_groups/12/subgroups",
11
+ "outcomes_url": "/api/v1/accounts/1/outcome_groups/12/outcomes",
12
+ "can_edit": true
13
+ },
14
+ "outcome": {
15
+ "context_id": 1,
16
+ "context_type": "Course",
17
+ "id": 18,
18
+ "vendor_guid": null,
19
+ "title": "this is a new title 3",
20
+ "url": "/api/v1/outcomes/18",
21
+ "can_edit": true
22
+ }
23
+ }
@@ -0,0 +1 @@
1
+ {"course_id": 3, "end_at": null, "id": 72, "name": "Section003", "nonxlist_course_id": null, "start_at": null, "sis_section_id": null}
@@ -0,0 +1,25 @@
1
+ {
2
+ "assignment_group_id": 2,
3
+ "automatic_peer_reviews": false,
4
+ "description": null,
5
+ "due_at": null,
6
+ "grade_group_students_individually": null,
7
+ "grading_standard_id": null,
8
+ "grading_type": "points",
9
+ "group_category_id": null,
10
+ "id": 1,
11
+ "lock_at": null,
12
+ "peer_reviews": false,
13
+ "points_possible": null,
14
+ "position": 1,
15
+ "unlock_at": null,
16
+ "course_id": 1,
17
+ "name": "new assignment",
18
+ "submission_types": [
19
+ "none"
20
+ ],
21
+ "muted": false,
22
+ "html_url": "http://localhost:3000/courses/1/assignments/1",
23
+ "needs_grading_count": 0,
24
+ "locked_for_user": false
25
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "account_id": 1,
3
+ "allow_student_forum_attachments": false,
4
+ "allow_wiki_comments": null,
5
+ "conclude_at": null,
6
+ "course_code": "Unnamed",
7
+ "default_view": "feed",
8
+ "id": 1,
9
+ "is_public": null,
10
+ "license": null,
11
+ "name": "new course",
12
+ "open_enrollment": null,
13
+ "restrict_enrollments_to_course_dates": null,
14
+ "root_account_id": 1,
15
+ "self_enrollment": null,
16
+ "start_at": null,
17
+ "end_at": null,
18
+ "public_syllabus": false,
19
+ "storage_quota_mb": 500,
20
+ "hide_final_grades": false,
21
+ "apply_assignment_group_weights": false,
22
+ "calendar": {
23
+ "ics": "http://localhost:3000/feeds/calendars/course_RW5J2UvNOTRjAfdp0qpXLnDNqv1391xSjWlxnfMB.ics"
24
+ },
25
+ "sis_course_id": null,
26
+ "workflow_state": "unpublished"
27
+ }
@@ -0,0 +1 @@
1
+ {"course_id": 3, "end_at": null, "id": 72, "name": "Section003", "nonxlist_course_id": null, "start_at": null, "sis_section_id": null}
@@ -0,0 +1,20 @@
1
+ {"associated_user_id": null,
2
+ "course_id": 3,
3
+ "course_section_id": 70,
4
+ "id": 1386,
5
+ "limit_privileges_to_course_section": false,
6
+ "root_account_id": 1,
7
+ "type": "StudentEnrollment",
8
+ "updated_at": "2013-06-27T09:43:57-06:00",
9
+ "user_id": 1,
10
+ "enrollment_state": "invited",
11
+ "role": "StudentEnrollment",
12
+ "grades": {
13
+ "html_url": "http://localhost:3000/courses/310/grades/1",
14
+ "current_score": null,
15
+ "final_score": null,
16
+ "current_grade": null,
17
+ "final_grade": null
18
+ },
19
+ "html_url": "http://localhost:3000/courses/310/users/1"
20
+ }
@@ -0,0 +1,23 @@
1
+ {
2
+ "context_id": 1,
3
+ "context_type": "Course",
4
+ "url": "/api/v1/courses/1/outcome_groups/2/outcomes/14",
5
+ "outcome_group": {
6
+ "id": 2,
7
+ "title": "sup",
8
+ "vendor_guid": null,
9
+ "url": "/api/v1/courses/1/outcome_groups/14",
10
+ "subgroups_url": "/api/v1/courses/1/outcome_groups/14/subgroups",
11
+ "outcomes_url": "/api/v1/courses/1/outcome_groups/14/outcomes",
12
+ "can_edit": true
13
+ },
14
+ "outcome": {
15
+ "context_id": 1,
16
+ "context_type": "Course",
17
+ "id": 14,
18
+ "vendor_guid": null,
19
+ "title": "New Outcome sup",
20
+ "url": "/api/v1/courses/14",
21
+ "can_edit": true
22
+ }
23
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "id": 23,
3
+ "title": "this is a new group",
4
+ "vendor_guid": null,
5
+ "url": "/api/v1/courses/1/outcome_groups/23",
6
+ "subgroups_url": "/api/v1/courses/1/outcome_groups/23/subgroups",
7
+ "outcomes_url": "/api/v1/courses/1/outcome_groups/23/outcomes",
8
+ "can_edit": true,
9
+ "import_url": "/api/v1/courses/1/outcome_groups/23/import",
10
+ "parent_outcome_group": {
11
+ "id": 14,
12
+ "title": "sup",
13
+ "vendor_guid": null,
14
+ "url": "/api/v1/courses/1/outcome_groups/14",
15
+ "subgroups_url": "/api/v1/courses/1/outcome_groups/14/subgroups",
16
+ "outcomes_url": "/api/v1/courses/1/outcome_groups/14/outcomes",
17
+ "can_edit": true
18
+ },
19
+ "context_id": 1,
20
+ "context_type": "Course",
21
+ "description": ""
22
+ }
@@ -0,0 +1,29 @@
1
+ {
2
+ "id": 5,
3
+
4
+ "url": "/api/v1/courses/1/outcome_groups/5",
5
+
6
+ "parent_outcome_group": {
7
+ "id": 1,
8
+ "url": "/api/v1/courses/1/outcome_groups/1",
9
+ "title": "parent outcome group",
10
+ "subgroups_url": "/api/v1/courses/1/outcome_groups/1/subgroups",
11
+ "outcomes_url": "/api/v1/courses/1/outcome_groups/1/outcomes",
12
+ "can_edit": true
13
+ },
14
+
15
+ "context_id": 1,
16
+ "context_type": "Course",
17
+
18
+ "title": "Outcome group title",
19
+
20
+ "description": "Outcome group description",
21
+
22
+ "subgroups_url": "/api/v1/courses/1/outcome_groups/5/subgroups",
23
+
24
+ "outcomes_url": "/api/v1/courses/1/outcome_groups/5/outcomes",
25
+
26
+ "import_url": "/api/v1/courses/1/outcome_groups/5/import",
27
+
28
+ "can_edit": true
29
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "id": 19,
3
+ "title": "api created subgroup title",
4
+ "vendor_guid": null,
5
+ "url": "/api/v1/courses/1/outcome_groups/19",
6
+ "subgroups_url": "/api/v1/courses/1/outcome_groups/19/subgroups",
7
+ "outcomes_url": "/api/v1/courses/1/outcome_groups/19/outcomes",
8
+ "can_edit": true,
9
+ "import_url": "/api/v1/courses/1/outcome_groups/19/import",
10
+ "parent_outcome_group": {
11
+ "id": 2,
12
+ "title": "api testing",
13
+ "vendor_guid": null,
14
+ "url": "/api/v1/courses/1/outcome_groups/2",
15
+ "subgroups_url": "/api/v1/courses/1/outcome_groups/2/subgroups",
16
+ "outcomes_url": "/api/v1/courses/1/outcome_groups/2/outcomes",
17
+ "can_edit": true
18
+ },
19
+ "context_id": 1,
20
+ "context_type": "Course",
21
+ "description": "api created subgroup desc"
22
+ }
@@ -0,0 +1,20 @@
1
+ [
2
+ {
3
+ "id": 10,
4
+ "title": "hello this is a new group",
5
+ "vendor_guid": null,
6
+ "url": "/api/v1/courses/1/outcome_groups/10",
7
+ "subgroups_url": "/api/v1/courses/1/outcome_groups/10/subgroups",
8
+ "outcomes_url": "/api/v1/courses/1/outcome_groups/10/outcomes",
9
+ "can_edit": true
10
+ },
11
+ {
12
+ "id": 13,
13
+ "title": "this is the last group",
14
+ "vendor_guid": null,
15
+ "url": "/api/v1/courses/1/outcome_groups/13",
16
+ "subgroups_url": "/api/v1/courses/1/outcome_groups/13/subgroups",
17
+ "outcomes_url": "/api/v1/courses/1/outcome_groups/13/outcomes",
18
+ "can_edit": true
19
+ }
20
+ ]
@@ -0,0 +1,33 @@
1
+ {
2
+ "id": 1,
3
+
4
+ "url": "/api/v1/outcomes/1",
5
+
6
+ "context_id": 1,
7
+ "context_type": "Course",
8
+
9
+ "title": "Test Outcome title",
10
+
11
+ "description": "Test Outcome description",
12
+
13
+ "points_possible": 5,
14
+
15
+ "mastery_points": 3,
16
+
17
+ "ratings": [
18
+ {
19
+ "description": "Exceeds Expectations",
20
+ "points": 5
21
+ },
22
+ {
23
+ "description": "Meets Expectations",
24
+ "points": 3
25
+ },
26
+ {
27
+ "description": "Does Not Meet Expectations",
28
+ "points": 0
29
+ }
30
+ ],
31
+
32
+ "can_edit": true
33
+ }
@@ -0,0 +1,92 @@
1
+ [
2
+ {
3
+ "id": 1991,
4
+ "name": "Jim Gloom",
5
+ "sortable_name": "Jim Gloom",
6
+ "short_name": "Gloom, Jim",
7
+ "sis_user_id": "foa2342",
8
+ "sis_login_id": "jimmy",
9
+ "login_id": "jimmy@foo.com"
10
+ },
11
+ {
12
+ "id": 2749,
13
+ "name": "Kim Bar",
14
+ "sortable_name": "Bar, Kim",
15
+ "short_name": "Kim",
16
+ "sis_user_id": "2df232",
17
+ "sis_login_id": "f23ra3a",
18
+ "login_id": "Kim"
19
+ },
20
+ {
21
+ "id": 1992,
22
+ "name": "Heckler Five",
23
+ "sortable_name": "Five, Helckler",
24
+ "short_name": "Gloom, Jim",
25
+ "sis_user_id": "foa2342",
26
+ "sis_login_id": "jimmy",
27
+ "login_id": "jimmy@foo.com"
28
+ },
29
+ {
30
+ "id": 2743,
31
+ "name": "Kim Bar",
32
+ "sortable_name": "Bar, Kim",
33
+ "short_name": "Kim",
34
+ "sis_user_id": "2df232",
35
+ "sis_login_id": "f23ra3a",
36
+ "login_id": "Kim"
37
+ },
38
+ {
39
+ "id": 1994,
40
+ "name": "Jim Gloom",
41
+ "sortable_name": "Jim Gloom",
42
+ "short_name": "Gloom, Jim",
43
+ "sis_user_id": "foa2342",
44
+ "sis_login_id": "jimmy",
45
+ "login_id": "jimmy@foo.com"
46
+ },
47
+ {
48
+ "id": 2745,
49
+ "name": "Kim Bar",
50
+ "sortable_name": "Bar, Kim",
51
+ "short_name": "Kim",
52
+ "sis_user_id": "2df232",
53
+ "sis_login_id": "f23ra3a",
54
+ "login_id": "Kim"
55
+ },
56
+ {
57
+ "id": 1996,
58
+ "name": "Jim Gloom",
59
+ "sortable_name": "Jim Gloom",
60
+ "short_name": "Gloom, Jim",
61
+ "sis_user_id": "foa2342",
62
+ "sis_login_id": "jimmy",
63
+ "login_id": "jimmy@foo.com"
64
+ },
65
+ {
66
+ "id": 2747,
67
+ "name": "Kim Bar",
68
+ "sortable_name": "Bar, Kim",
69
+ "short_name": "Kim",
70
+ "sis_user_id": "2df232",
71
+ "sis_login_id": "f23ra3a",
72
+ "login_id": "Kim"
73
+ },
74
+ {
75
+ "id": 1998,
76
+ "name": "Jim Gloom",
77
+ "sortable_name": "Jim Gloom",
78
+ "short_name": "Gloom, Jim",
79
+ "sis_user_id": "foa2342",
80
+ "sis_login_id": "jimmy",
81
+ "login_id": "jimmy@foo.com"
82
+ },
83
+ {
84
+ "id": 2750,
85
+ "name": "Kim Bar",
86
+ "sortable_name": "Bar, Kim",
87
+ "short_name": "Kim",
88
+ "sis_user_id": "2df232",
89
+ "sis_login_id": "f23ra3a",
90
+ "login_id": "Kim"
91
+ }
92
+ ]
@@ -0,0 +1 @@
1
+ {"course_id":3,"end_at":null,"id":72,"name":"Section003","nonxlist_course_id":null,"start_at":null,"sis_section_id":null}
@@ -0,0 +1 @@
1
+ {"id": 5, "title": "updated outcome title", "description": "updated outcome desc"}
@@ -0,0 +1,22 @@
1
+ {
2
+ "id": 2,
3
+ "title": "updated outcome group title",
4
+ "vendor_guid": null,
5
+ "url": "/api/v1/courses/1/outcome_groups/10",
6
+ "subgroups_url": "/api/v1/courses/1/outcome_groups/10/subgroups",
7
+ "outcomes_url": "/api/v1/courses/1/outcome_groups/10/outcomes",
8
+ "can_edit": true,
9
+ "import_url": "/api/v1/courses/1/outcome_groups/10/import",
10
+ "parent_outcome_group": {
11
+ "id": 2,
12
+ "title": "api testing",
13
+ "vendor_guid": null,
14
+ "url": "/api/v1/courses/1/outcome_groups/2",
15
+ "subgroups_url": "/api/v1/courses/1/outcome_groups/2/subgroups",
16
+ "outcomes_url": "/api/v1/courses/1/outcome_groups/2/outcomes",
17
+ "can_edit": true
18
+ },
19
+ "context_id": 1,
20
+ "context_type": "Course",
21
+ "description": ""
22
+ }
@@ -0,0 +1 @@
1
+ {"course_id": 3, "end_at": null, "id": 72, "name": "Section003", "nonxlist_course_id": null, "start_at": null, "sis_section_id": null}
@@ -0,0 +1,23 @@
1
+ [
2
+ {
3
+ "associated_user_id": null,
4
+ "course_id": 3,
5
+ "course_section_id": 70,
6
+ "id": 2,
7
+ "limit_privileges_to_course_section": false,
8
+ "root_account_id": 1,
9
+ "type": "TeacherEnrollment",
10
+ "updated_at": "2013-06-25T15:08:02-06:00",
11
+ "user_id": 1,
12
+ "enrollment_state": "active",
13
+ "role": "TeacherEnrollment",
14
+ "html_url": "http://localhost:3000/courses/3/users/1",
15
+ "user": {
16
+ "id": 1,
17
+ "name": "test@instructure.com",
18
+ "sortable_name": "test@instructure.com",
19
+ "short_name": "test@instructure.com",
20
+ "login_id": "test@instructure.com"
21
+ }
22
+ }
23
+ ]
data/spec/helper.rb ADDED
@@ -0,0 +1,43 @@
1
+ require 'footrest'
2
+ require 'bearcat'
3
+ require 'rspec'
4
+ require 'webmock/rspec'
5
+ require 'json'
6
+
7
+ WebMock.disable_net_connect!
8
+
9
+ RSpec.configure do |config|
10
+ config.expect_with :rspec do |c|
11
+ c.syntax = :expect
12
+ end
13
+ end
14
+
15
+ def fixture(file)
16
+ File.new(File.join(File.expand_path("../fixtures", __FILE__), file))
17
+ end
18
+
19
+ def stub_get(client, url)
20
+ stub_request(:get, "#{client.config[:prefix]}#{url}")
21
+ end
22
+
23
+ def stub_post(client, url)
24
+ stub_request(:post, "#{client.config[:prefix]}#{url}")
25
+ end
26
+
27
+ def stub_put(client, url)
28
+ stub_request(:put, "#{client.config[:prefix]}#{url}")
29
+ end
30
+
31
+ def stub_delete(client, url)
32
+ stub_request(:delete, "#{client.config[:prefix]}#{url}")
33
+ end
34
+
35
+ def json_response(file)
36
+ {
37
+ :body => fixture(file),
38
+ :headers => {
39
+ :content_type => 'application/json; charset=utf-8'
40
+ }
41
+ }
42
+ end
43
+