Sha256: a2df63fff4a63200ca9ed1a94a5b4c4e109cfb3d208c769fbcf3c4b67b97426a
Contents?: true
Size: 1.28 KB
Versions: 121
Compression:
Stored size: 1.28 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_post(@client, "/confirm"). with(:body => {"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
121 entries across 121 versions & 1 rubygems