spec/bearcat/client/module_items_spec.rb in bearcat-1.3.39 vs spec/bearcat/client/module_items_spec.rb in bearcat-1.3.40

- old
+ new

@@ -19,6 +19,42 @@ item = @client.module_item(1, 1, 2) expect(item['id']).to eq(2) end end + describe '#create_module_item' do + it 'creates a module item' do + params = { module_item: { title: 'Test Page', + content_id: '1-dot-1-intro-to-disease', + type: 'Page' }} + stub_request(:post, "http://canvas.instructure.com/api/v1/courses/1/modules/1/items") + .with(body: params) + .to_return(json_response("module_item.json")) + module_item = @client.create_module_item(1, 1, params) + expect(module_item['title']).to eq('Test Page') + expect(module_item['page_url']).to eq('1-dot-1-intro-to-disease') + end + end + + describe '#update_module_item' do + it 'updates a module item' do + params = { module_item: { title: 'Test Page', + content_id: '1-dot-1-intro-to-disease', + type: 'Page' }} + stub_request(:put, "http://canvas.instructure.com/api/v1/courses/1/modules/1/items/2") + .with(body: params) + .to_return(json_response("module_item.json")) + module_item = @client.update_module_item(1, 1, 2, params) + expect(module_item['title']).to eq('Test Page') + expect(module_item['page_url']).to eq('1-dot-1-intro-to-disease') + end + end + + describe '#delete_module_item' do + it 'deletes a module item' do + stub_request(:delete, "http://canvas.instructure.com/api/v1/courses/1/modules/1/items/2") + .to_return(json_response('module_item.json')) + module_item = @client.delete_module_item(1, 1, 2) + expect(module_item["id"]).to eq(2) + end + end end