Sha256: ed4e2268feb40689f58e97c24d58b361676d1617a6534cffce800961af61f48c

Contents?: true

Size: 1.38 KB

Versions: 11

Compression:

Stored size: 1.38 KB

Contents

require File.join(File.dirname(__FILE__), '../spec_helper')

describe FbGraph::Collection, '.new' do
  before(:all) do
    fake_json(:get, 'platform/statuses?access_token=access_token', 'pages/statuses/platform_private')
  end

  it 'should return an array with pagination info' do
    collection = FbGraph::Page.new('platform', :access_token => 'access_token').statuses.collection
    collection.should be_kind_of(Array)
    collection.previous.should be_kind_of(Hash)
    collection.next.should be_kind_of(Hash)
  end

  it 'should allow blank data' do
    patterns = [
      FbGraph::Collection.new,
      FbGraph::Collection.new({}),
      FbGraph::Collection.new({:count => 5}),
      FbGraph::Collection.new(nil)
    ]
    patterns.each do |collection|
      collection.should be_kind_of(Array)
      collection.previous.should be_kind_of(Hash)
      collection.next.should be_kind_of(Hash)
      collection.should be_blank
      collection.previous.should be_blank
      collection.next.should be_blank
    end
  end

  it 'should fetch count as total_count' do
    collection = FbGraph::Collection.new({:count => 5})
    collection.total_count.should == 5
  end

  it 'should accept Array' do
    collection = FbGraph::Collection.new([1, 2, 3])
    collection.total_count.should == 3
    collection.should == [1, 2, 3]
    collection.previous.should be_blank
    collection.next.should be_blank
  end

end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
fb_graph-1.1.6 spec/fb_graph/collection_spec.rb
fb_graph-1.1.5 spec/fb_graph/collection_spec.rb
fb_graph-1.1.4 spec/fb_graph/collection_spec.rb
fb_graph-1.1.3 spec/fb_graph/collection_spec.rb
fb_graph-1.1.2 spec/fb_graph/collection_spec.rb
fb_graph-1.1.1 spec/fb_graph/collection_spec.rb
fb_graph-1.1.0 spec/fb_graph/collection_spec.rb
fb_graph-1.0.7 spec/fb_graph/collection_spec.rb
fb_graph-1.0.6 spec/fb_graph/collection_spec.rb
fb_graph-1.0.5 spec/fb_graph/collection_spec.rb
palidanx-fb_graph-1.0.4 spec/fb_graph/collection_spec.rb