require 'helper'

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

  it "returns an outcome" do
    stub_get(@client, "/api/v1/outcomes/1").to_return(json_response("outcomes.json"))
    outcome = @client.show_outcome(1)
    expect(outcome['title']).to eq('Test Outcome title')
    expect(outcome['id']).to eq(1)
    expect(outcome['description']).to eq('Test Outcome description')
    expect(outcome['points_possible']).to eq(5)
    expect(outcome['mastery_points']).to eq(3)
  end

  it "updates an outcome" do
    title = 'updated outcome title'
    description = 'updated outcome desc'
    stub_put(@client, "/api/v1/outcomes/5").with(:body => {"title" => title, "description" => description}).to_return(json_response("update_outcome.json"))
    outcome = @client.update_outcome(5, {"title" => title, "description" => description})
    expect(outcome['title']).to eq(title)
    expect(outcome['description']).to eq(description)
  end

end