Sha256: da553ce57c1abb349ce23ff80475536b3c1cbb6e1421f7ff72c8a3b0c4b989c6

Contents?: true

Size: 1.85 KB

Versions: 2

Compression:

Stored size: 1.85 KB

Contents

require 'helper'

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

  it "returns all sections for a course" do
    stub_get(@client, "/api/v1/courses/3/sections").to_return(json_response("course_sections.json"))
    sections = @client.course_sections(3)
    expect(sections.first['name']).to eq('test')
    expect(sections.first['id']).to eq(70)
    expect(sections.first['course_id']).to eq(3)
  end

  it "returns a section" do
    stub_get(@client, "/api/v1/sections/72").to_return(json_response("section.json"))
    section = @client.section(72)
    expect(section['name']).to eq('Section003')
    expect(section['id']).to eq(72)
    expect(section['course_id']).to eq(3)
  end

  it "creates a section" do
    stub_post(@client, "/api/v1/courses/3/sections").
      with(:body => {"course_section"=>{"name"=>"Section003"}}).to_return(json_response("create_section.json"))
    section = @client.create_section(3, {"course_section[name]" => "Section003"})
    expect(section['course_id']).to eq(3)
    expect(section['id']).to eq(72)
    expect(section['name']).to eq('Section003')
  end

  it "updates a section" do
    stub_put(@client, "/api/v1/sections/72").with(:body => {"course_section"=>{"name"=>"Section003"}}).to_return(json_response("update_section.json"))
    section = @client.update_section(72, {"course_section[name]" => "Section003"})
    expect(section['course_id']).to eq(3)
    expect(section['id']).to eq(72)
    expect(section['name']).to eq('Section003')
  end

  it "deletes a section" do
    stub_delete(@client, "/api/v1/sections/72").to_return(json_response("update_section.json"))
    section = @client.delete_section(72)
    expect(section['course_id']).to eq(3)
    expect(section['id']).to eq(72)
    expect(section['name']).to eq('Section003')
  end



end

Version data entries

2 entries across 2 versions & 1 rubygems

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