require 'helper' describe Bearcat::Client::Reports do before do @client = Bearcat::Client.new(prefix: 'http://canvas.instructure.com', token: 'test_token') end it 'lists the reports availible' do stub_get(@client, '/api/v1/accounts/1/reports').to_return(json_response('report_list.json')) reports = @client.report_list(1) reports.count.should == 38 end it 'starts a report' do stub_post(@client, '/api/v1/accounts/1/reports/last_user_access_csv').to_return(json_response('start_report.json')) status = @client.start_report(1, 'last_user_access_csv') status['report'].should == 'last_user_access_csv' end it 'lists the report history' do stub_get(@client, '/api/v1/accounts/1/reports/last_user_access_csv').to_return(json_response('report_history.json')) history = @client.report_history(1, 'last_user_access_csv') history.count == 2 end it 'gets the status of a report' do stub_get(@client, '/api/v1/accounts/1/reports/last_user_access_csv/72').to_return(json_response('report_status.json')) status = @client.report_status(1, 'last_user_access_csv', 72) status['status'] == 'complete' end it 'deletes a report' do stub_delete(@client, '/api/v1/accounts/1/reports/last_user_access_csv/72').to_return(json_response('report_status.json')) status = @client.delete_report(1, 'last_user_access_csv', 72) status['report'] == 'last_user_access_csv' end end