Sha256: d1ed292ab7a58e82b5c5a3b2ea526d75a88a65d8ce3550d3d4c832ea10c06002

Contents?: true

Size: 1.49 KB

Versions: 4

Compression:

Stored size: 1.49 KB

Contents

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

describe Uploadcare::Api::File do
  before :all do
    @api = API
    @list = @api.file_list 1
  end

  it "should return file list" do
    @list.should be_kind_of(Uploadcare::Api::FileList)
  end

  it "should respont to results method" do
    @list.should respond_to :results
  end

  it "results should be an array" do
    @list.results.should be_kind_of(Array)
  end

  it "resulst should be UC files" do
    @list.results.each do |file|
      file.should be_kind_of(Uploadcare::Api::File)
    end
  end

  it "results should be not only files, but loaded files" do
    @list.results.each do |file|
      file.is_loaded?.should be true
    end
  end

  it "should load next page" do
    next_page = @list.next_page
    next_page.should be_kind_of(Uploadcare::Api::FileList)
  end

  it "should load prev page" do
    list =  @api.file_list 3
    prev_page = list.previous_page
    prev_page.should be_kind_of(Uploadcare::Api::FileList)
  end

  it "should load custom page" do
    page = @list.go_to(@list.pages - 1)
    page.should be_kind_of(Uploadcare::Api::FileList)
  end

  it "should not load next page if there isn't one" do
    page= @list.go_to @list.pages
    page.next_page.should be_nil
  end

  it "should not load prev page if there isn't one" do
    @list.previous_page.should be_nil
  end

  it "should not load custom page with index more than there is actually page in project" do
    page = @list.go_to @list.pages + 3
    page.should be_nil
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
uploadcare-ruby-1.2.2 spec/resources/file_list_spec.rb
uploadcare-ruby-1.2.1 spec/resources/file_list_spec.rb
uploadcare-ruby-1.1.0 spec/resources/file_list_spec.rb
uploadcare-ruby-1.0.6 spec/resources/file_list_spec.rb