Sha256: 0be8bff75c631fccfd0f1a9f0a17ee5ae2417be7ca5d24f40f7a8509154c78d4

Contents?: true

Size: 1.52 KB

Versions: 1

Compression:

Stored size: 1.52 KB

Contents

require 'helper'

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

  it "returns course modules" do
    stub_get(@client, "/api/v1/courses/1/modules").to_return(json_response("modules.json"))
    modules = @client.course_modules(1)
    modules.count.should == 3
    modules.first['id'].should == 1
  end

  it "returns a course items module sequence" do
    query = {"asset_type" => "assignment", "asset_id" => '22'}
    stub_get(@client, "/api/v1/courses/1/module_item_sequence").with(query: query).to_return(json_response("module_item_sequence.json"))
    item_sequence = @client.course_module_item_sequence("1", query)
    items = item_sequence["modules"]
    items.count.should == 3
    items.last["id"].should == 3
  end

  describe "#course_module" do
    it "returns a course module" do
      stub_get(@client, "/api/v1/courses/1/modules/2").to_return(json_response("module.json"))
      context_module = @client.course_module(1, 2)
      expect(context_module['id']).to eq(2)
    end
  end

  describe "#create_module" do
    it "creates a new module" do
      name = "new module"
      stub_request(:post, "http://canvas.instructure.com/api/v1/courses/1/modules")
                  .with(body: {"name"=>"new module"})
                  .to_return(json_response("created_module.json"))
      course_module = @client.create_module(1, { name: name })
      course_module["name"].should == name
      course_module["id"].should == 1
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bearcat-1.3.39 spec/bearcat/client/modules_spec.rb