Sha256: 0e2c1f80eff6953dc19ff38228b98f85d53f6709b1f8e0827287cde504a25489
Contents?: true
Size: 1.79 KB
Versions: 2
Compression:
Stored size: 1.79 KB
Contents
require 'helper' describe Bearcat::Client::Enrollments do before do @client = Bearcat::Client.new(prefix:"http://canvas.instructure.com", token: "test_token") end it "returns all enrollments for a user" do stub_get(@client, "/api/v1/users/1/enrollments").to_return(json_response("user_enrollments.json")) enrollments = @client.user_enrollments(1) expect(enrollments.first['course_id']).to eq(3) expect(enrollments.first['course_section_id']).to eq(70) expect(enrollments.first['id']).to eq(2) expect(enrollments.first['user']['id']).to eq(1) expect(enrollments.first['user']['name']).to eq('test@instructure.com') end it "enrolls a student in a section" do stub_post(@client, "/api/v1/sections/70/enrollments") .with(:body => {"enrollment"=>{"user_id"=>"1", "type"=>"StudentEnrollment"}}) .to_return(json_response("enroll_student.json")) enrollment = @client.enroll_in_section(70, {"enrollment[user_id]" => 1, "enrollment[type]" => "StudentEnrollment"}) expect(enrollment["course_id"]).to eq(3) expect(enrollment["course_section_id"]).to eq(70) expect(enrollment["id"]).to eq(1386) expect(enrollment["role"]).to eq("StudentEnrollment") expect(enrollment["enrollment_state"]).to eq("invited") end it "concludes a students enrollment" do stub_request(:delete, "http://canvas.instructure.com/api/v1/courses/3/enrollments/1386?task=conclude").to_return(json_response("conclude_enrollment.json")) enrollment = @client.conclude_enrollment(3, 1386, {"task" => "conclude"}) expect(enrollment["course_id"]).to eq(3) expect(enrollment["course_section_id"]).to eq(70) expect(enrollment["id"]).to eq(1386) expect(enrollment["role"]).to eq("StudentEnrollment") expect(enrollment["enrollment_state"]).to eq("completed") end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
bearcat-0.1.1 | spec/bearcat/client/enrollments_spec.rb |
bearcat-0.1 | spec/bearcat/client/enrollments_spec.rb |