Sha256: c3df138ef4fd3b6d4d4bd9b27d136b577ce5cf3a09eda4322854e690072a750b
Contents?: true
Size: 1.26 KB
Versions: 37
Compression:
Stored size: 1.26 KB
Contents
require 'helper' describe Bearcat::Client::CanvasFiles do before do @client = Bearcat::Client.new(prefix: "http://canvas.instructure.com", token: "test_token") end it 'uploads a file' do stub_post(@client, "/my/upload/path"). with(:body => {"name" => "bearcat.jpg", "size" => "121363"}). to_return(json_response('canvas_files', 'declare_file.json')) stub_request(:post, "https://upload-url.invalid/"). to_return(status: 302, headers: {'Location' => 'https://confirm-upload.invalid/confirm?param=true'}) stub_get(@client, '/confirm').with(query: { param: true }).to_return(json_response('canvas_files', 'upload_success.json')) response = @client.upload_file('my/upload/path', fixture('bearcat.jpg')) expect(response['id']).to eq 123 end it 'throws an error on a failed file upload' do stub_post(@client, "/my/upload/path"). with(:body => {"name" => "bearcat.jpg", "size" => "121363"}). to_return(json_response('canvas_files', 'declare_file.json')) stub_request(:post, "https://upload-url.invalid/"). to_return(status: 400, headers: {'Location' => 'https://confirm-upload.invalid/confirm?param=true'}) expect { @client.upload_file('my/upload/path', fixture('bearcat.jpg')) }.to raise_exception end end
Version data entries
37 entries across 37 versions & 1 rubygems