require 'helper' describe Bearcat::Client::GroupMemberships do before do @client = Bearcat::Client.new(prefix: "http://canvas.instructure.com", token: "test_token") end it "creates a group membership" do stub_post(@client, "/api/v1/groups/3/memberships").with(:body => {"user_id"=>"6"}).to_return(json_response("created_group_membership.json")) created_group_membership = @client.create_group_membership(3, { user_id: 6 }) created_group_membership['id'] == 14 created_group_membership['group_id'] == 3 created_group_membership['workflow_state'] == 'accepted' created_group_membership['user_id'] == 6 end describe 'GroupMemberships#delete_group_membership' do context 'deleting the group membership by id' do it 'deletes a group membership' do stub_delete(@client, "/api/v1/groups/3/memberships/3").to_return(json_response("ok.json")) deleted_response = @client.delete_group_membership(3, 'memberships', 3) deleted_response['ok'] == true end end context 'deleting the group membership by user and group id' do it 'deletes a group membership' do stub_delete(@client, "/api/v1/groups/3/users/3").to_return(json_response("ok.json")) deleted_response = @client.delete_group_membership(3, 'users', 3) deleted_response['ok'] == true end end end end