Sha256: 6d8e6e7d219a704a0ce9e491675f3182cee47f0d42dea4f188a1a9592214bd0b

Contents?: true

Size: 1.94 KB

Versions: 72

Compression:

Stored size: 1.94 KB

Contents

require 'helper'

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

  it "returns all assignment groups for a course" do
    stub_get(@client, "/api/v1/courses/1/assignment_groups").to_return(json_response("assignment_groups.json"))
    assignment_groups = @client.list_assignment_groups(1)
    assignment_groups.count.should == 2
    assignment_groups.first["group_weight"].should == 500
    assignment_groups.first["id"].should == 2
    assignment_groups.first["name"].should == 'Quizzes'
  end

  it 'returns a single assignment_group' do
    stub_get(@client, '/api/v1/courses/2/assignment_groups/1').to_return(json_response("assignment_group.json"))
    assignment_group = @client.assignment_group(2, 1)
    assignment_group["group_weight"].should == 500
    assignment_group["id"].should == 2
    assignment_group["name"].should == 'Quizzes'
  end

  it 'creates an assignment_group' do
    params = {'name' => 'New Assignment Group'}
    stub_post(@client, "/api/v1/courses/2/assignment_groups").with(body: params).to_return(json_response("assignment_group.json"))
    new_assignment_group = @client.create_assignment_group(2, params)
    expect(new_assignment_group['name']).to eq('Quizzes')
  end

  it 'updates an assignment_group' do
    params = {'name' => 'Quizzes'}
    stub_put(@client, "/api/v1/courses/2/assignment_groups/1").with(body: params)
      .to_return(json_response("assignment_group.json"))
    updated_assignment_group = @client.update_assignment_group(2, 1, params)
    expect(updated_assignment_group['name']).to eq('Quizzes')
  end

  it 'deletes an assignment_group' do
    params = {'id' => '1'}
    stub_delete(@client, "/api/v1/courses/2/assignment_groups/2").to_return(json_response("assignment_group.json"))
    deleted_assignment_group = @client.delete_assignment_group(2, 2)
    deleted_assignment_group["id"].should == 2
  end

end

Version data entries

72 entries across 72 versions & 1 rubygems

Version Path
bearcat-1.5.37 spec/bearcat/client/assignment_groups_spec.rb
bearcat-1.5.36 spec/bearcat/client/assignment_groups_spec.rb
bearcat-1.5.35 spec/bearcat/client/assignment_groups_spec.rb
bearcat-1.5.34 spec/bearcat/client/assignment_groups_spec.rb
bearcat-1.5.33 spec/bearcat/client/assignment_groups_spec.rb
bearcat-1.5.32 spec/bearcat/client/assignment_groups_spec.rb
bearcat-1.5.31 spec/bearcat/client/assignment_groups_spec.rb
bearcat-1.5.30 spec/bearcat/client/assignment_groups_spec.rb
bearcat-1.5.29 spec/bearcat/client/assignment_groups_spec.rb
bearcat-1.5.28 spec/bearcat/client/assignment_groups_spec.rb
bearcat-1.5.28.beta1 spec/bearcat/client/assignment_groups_spec.rb
bearcat-1.5.26 spec/bearcat/client/assignment_groups_spec.rb
bearcat-1.5.24 spec/bearcat/client/assignment_groups_spec.rb
bearcat-1.5.23 spec/bearcat/client/assignment_groups_spec.rb
bearcat-1.5.20 spec/bearcat/client/assignment_groups_spec.rb
bearcat-1.5.19 spec/bearcat/client/assignment_groups_spec.rb
bearcat-1.5.17 spec/bearcat/client/assignment_groups_spec.rb
bearcat-1.5.16 spec/bearcat/client/assignment_groups_spec.rb
bearcat-1.5.15 spec/bearcat/client/assignment_groups_spec.rb
bearcat-1.5.14 spec/bearcat/client/assignment_groups_spec.rb