spec/bearcat/client/outcome_groups_spec.rb in bearcat-0.1.1 vs spec/bearcat/client/outcome_groups_spec.rb in bearcat-0.3
- old
+ new
@@ -7,98 +7,104 @@
@client = Bearcat::Client.new(prefix: "http://canvas.instructure.com/api/v1/", token: "test_token")
end
describe "outcomes api slugs" do
it "returns the account api slug" do
- expect(@client.outcomes_context_slug({'account' => 3})).to eq("#{@client.config.prefix}accounts/3/outcome_groups/")
+ @client.outcomes_context_slug({'account' => 3}).should ==
+ 'accounts/3/outcome_groups/'
end
it "returns the course api slug" do
- expect(@client.outcomes_context_slug(PARAMS)).to eq("#{@client.config.prefix}courses/1/outcome_groups/")
+ @client.outcomes_context_slug(PARAMS).should ==
+ 'courses/1/outcome_groups/'
end
it "returns the global api slug" do
- expect(@client.outcomes_context_slug({})).to eq("#{@client.config.prefix}global/outcome_groups/")
+ @client.outcomes_context_slug({}).should ==
+ 'global/outcome_groups/'
end
it "raises an error if both account and course are in params" do
- expect { @client.outcomes_context_slug({'account' => 3, 'course' => 5}) }.to raise_error(ArgumentError)
+ expect { @client.outcomes_context_slug({'account' => 3, 'course' => 5}) }.
+ to raise_error(ArgumentError)
end
end
it "returns an outcome group" do
stub_get(@client, "#{@client.outcomes_context_slug(PARAMS)}5").to_return(json_response("outcome_groups.json"))
outcome = @client.show_outcome_group(5, PARAMS)
- expect(outcome['id']).to eq(5)
- expect(outcome['title']).to eq('Outcome group title')
- expect(outcome['description']).to eq('Outcome group description')
+ outcome['id'].should == 5
+ outcome['title'].should == 'Outcome group title'
+ outcome['description'].should == 'Outcome group description'
end
it "updates an outcome group" do
updated_outcome_title = 'updated outcome group title'
stub_put(@client, "#{@client.outcomes_context_slug(PARAMS)}2").with(:body => {"course" => "1", "title" => updated_outcome_title}).to_return(json_response("update_outcome_group.json"))
updated_outcome = @client.update_outcome_group(2, {"course" => "1", "title" => updated_outcome_title})
- expect(updated_outcome['id']).to eq(2)
- expect(updated_outcome['title']).to eq(updated_outcome_title)
+ updated_outcome['id'].should == 2
+ updated_outcome['title'].should == updated_outcome_title
end
it "deletes an outcome group" do
stub_delete(@client, "#{@client.outcomes_context_slug(PARAMS)}2").to_return(json_response("outcome_groups.json"))
deleted_outcome = @client.delete_outcome_group(2, PARAMS)
- expect(deleted_outcome).to_not eq("error")
+ deleted_outcome.should_not == "error"
end
it "returns linked outcomes" do
stub_get(@client, "#{@client.outcomes_context_slug(PARAMS)}2/outcomes").to_return(json_response("link_unlink_outcome.json"))
linked_outcomes = @client.list_linked_outcomes(2, PARAMS)
- expect(linked_outcomes['outcome_group']['title']).to eq('sup')
- expect(linked_outcomes['outcome']['context_type']).to eq('Course')
+ linked_outcomes['outcome_group']['title'].should == 'sup'
+ linked_outcomes['outcome']['context_type'].should == 'Course'
end
it "creates outcome in outcome group" do
title = 'this is a new title 3'
description = 'this is a new description 3'
stub_post(@client, "#{@client.outcomes_context_slug(PARAMS)}2/outcomes").with(:body => {"course" => "1", "title" => title, "description" => description}).to_return(json_response('create_outcome_in_group.json'))
created_outcome = @client.create_outcome_in_group(2, {"course" => "1", "title" => title, "description" => description})
- expect(created_outcome['outcome']['title']).to eq(title)
- expect(created_outcome['outcome']['id']).to eq(18)
- expect(created_outcome['url']).to eq('/api/v1/courses/1/outcome_groups/2/outcomes/18')
+ created_outcome['outcome']['title'].should == title
+ created_outcome['outcome']['id'].should == 18
+ created_outcome['url'].should == '/api/v1/courses/1/outcome_groups/2/outcomes/18'
end
it "links outcome in outcome group" do
- stub_put(@client, "#{@client.outcomes_context_slug(PARAMS)}2/outcomes/14").to_return(json_response('link_unlink_outcome.json'))
+ stub_put(@client, "#{@client.outcomes_context_slug(PARAMS)}2/outcomes/14").
+ to_return(json_response('link_unlink_outcome.json'))
linked_outcome = @client.link_outcome(2, 14, PARAMS)
- expect(linked_outcome['outcome']['title']).to eq('New Outcome sup')
- expect(linked_outcome['url']).to eq('/api/v1/courses/1/outcome_groups/2/outcomes/14')
+ linked_outcome['outcome']['title'].should == 'New Outcome sup'
+ linked_outcome['url'].should == '/api/v1/courses/1/outcome_groups/2/outcomes/14'
end
it "unlinks an outcome" do
- stub_delete(@client, "#{@client.outcomes_context_slug(PARAMS)}2/outcomes/14").to_return(json_response('link_unlink_outcome.json'))
+ stub_delete(@client, "#{@client.outcomes_context_slug(PARAMS)}2/outcomes/14").
+ to_return(json_response('link_unlink_outcome.json'))
unlinked_outcome = @client.unlink_outcome(2, 14, PARAMS)
- expect(unlinked_outcome).to_not eq("error")
+ unlinked_outcome.should_not == "error"
end
it "returns subgroups" do
stub_get(@client, "#{@client.outcomes_context_slug(PARAMS)}2/subgroups").to_return(json_response("outcome_subgroups.json"))
outcome_subgroups = @client.list_subgroups(2, PARAMS)
- expect(outcome_subgroups.count).to eq(2)
- expect(outcome_subgroups.first['title']).to eq('hello this is a new group')
- expect(outcome_subgroups.last['title']).to eq('this is the last group')
+ outcome_subgroups.count.should == 2
+ outcome_subgroups.first['title'].should == 'hello this is a new group'
+ outcome_subgroups.last['title'].should == 'this is the last group'
end
it "creates subgroups" do
title = "api created subgroup title"
description = "api created subgroup desc"
stub_post(@client, "#{@client.outcomes_context_slug(PARAMS)}2/subgroups").with(:body => {"course" => "1", "description" => description, "title" => title}).to_return(json_response("outcome_subgroup.json"))
outcome_subgroup = @client.create_subgroup(2, {"course" => "1", "description" => description, "title" => title})
- expect(outcome_subgroup['title']).to eq(title)
- expect(outcome_subgroup['description']).to eq(description)
+ outcome_subgroup['title'].should == title
+ outcome_subgroup['description'].should == description
end
it "imports outcome groups" do
stub_post(@client, "#{@client.outcomes_context_slug(PARAMS)}2/import").with(:body => {"course" => "1", "source_outcome_group_id" => "14"}).to_return(json_response("outcome_group_import.json"))
imported_outcome = @client.import_outcome_group(2, {"course" => "1", "source_outcome_group_id" => "14"})
- expect(imported_outcome['title']).to eq('this is a new group')
- expect(imported_outcome['parent_outcome_group']).to_not be_empty
+ imported_outcome['title'].should == 'this is a new group'
+ imported_outcome['parent_outcome_group'].should_not be_empty
end
end
\ No newline at end of file