Sha256: 9d7fa878547285d2cd80fc54a990717ae55a0fb245164e27dd8d6b561b2a60d4

Contents?: true

Size: 1.01 KB

Versions: 5

Compression:

Stored size: 1.01 KB

Contents

require 'spec_helper'
require 'uri'
require 'socket'

describe Uploadcare::Api do
  before :each do
    @api = Uploadcare::Api.new(CONFIG)
    @file = File.open(File.join(File.dirname(__FILE__), 'view.png'))
    @url = "http://macaw.co/images/macaw-logo.png"
  end

  it 'should upload file or url' do
    file = @api.upload @file
    file.should be_an_instance_of Uploadcare::Api::File
  end

  it 'should raise an error when neither file nor url given' do
    expect { @api.upload 12 }.to raise_error
  end

  it 'should upload file' do
    file = @api.upload @file
    file.should be_an_instance_of Uploadcare::Api::File
  end

  it 'should upload from url' do
    file = @api.upload @url
    file.should be_an_instance_of Uploadcare::Api::File
  end

  it 'should not upload from invalid url' do
    expect { @api.upload 'not.url.' }.to raise_error
  end

  it 'uploaded file should have valid UUID' do
    file = @api.upload @url
    file.should be_an_instance_of Uploadcare::Api::File
    file.uuid.should match UUID_REGEX
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
uploadcare-ruby-1.0.4 spec/uploading_spec.rb
uploadcare-ruby-1.0.3 spec/uploading_spec.rb
uploadcare-ruby-1.0.2 spec/uploading_spec.rb
uploadcare-ruby-1.0.1.rc2 spec/uploading_spec.rb
uploadcare-ruby-1.0.1.rc1 spec/uploading_spec.rb