Sha256: d1da9033f0a513a46aa76b00c818cf63a61211aa8f2e8041ce4613aa3f61be2b

Contents?: true

Size: 1.62 KB

Versions: 2

Compression:

Stored size: 1.62 KB

Contents

require 'helper'

describe Bearcat::Client::Assignments do
  before do
    @client = Bearcat::Client.new(prefix: "http://canvas.instructure.com", token: "test_token")
  end

  it "returns all assignments for a course" do
    stub_get(@client, "/api/v1/courses/3/assignments").to_return(json_response("assignments.json"))
    assignments = @client.assignments(3)
    expect(assignments.count).to eq(2)
    expect(assignments.first["assignment_group_id"]).to eq(53)
    expect(assignments.first["id"]).to eq(123)
    expect(assignments.first["due_at"]).to eq(nil)
  end

  it "creates an assignment override for a section" do
    stub_post(@client, "/api/v1/courses/310/assignments/123/overrides")
      .with(:body => {"assignment_override"=>{"course_section_id"=>"74", "due_at"=>"2013-06-27T21:08:46Z"}})
      .to_return(json_response("assignment_section_override.json"))
    override = @client.create_assignment_override(310, 123, {
      "assignment_override[course_section_id]" => 74,
      "assignment_override[due_at]" => "2013-06-27T21:08:46Z"
    })
    expect(override["all_day"]).to eq(false)
    expect(override["due_at"]).to eq("2013-06-27T15:08:46-06:00")
    expect(override["id"]).to eq(1)
    expect(override["course_section_id"]).to eq(74)
  end

  it "creates a new assignment" do
    name = "new assignment"
    stub_post(@client, "/api/v1/courses/1/assignments").with(body: {"assignment" => {"name" => name}}).to_return(json_response("created_assignment.json"))
    assignment = @client.create_assignment(1, {"assignment" => {"name" => name}})
    expect(assignment["name"]).to eq(name)
    expect(assignment["id"]).to eq(1)
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bearcat-0.1.1 spec/bearcat/client/assignments_spec.rb
bearcat-0.1 spec/bearcat/client/assignments_spec.rb