Sha256: acc48246aa13af5d726b7574a2fde2a6d6b16961c1c8539e602dbaf038ed64df

Contents?: true

Size: 1.68 KB

Versions: 32

Compression:

Stored size: 1.68 KB

Contents

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

describe FbGraph::Connections::Friends, '#friends' do
  context 'when included by FbGraph::User' do
    before do
      fake_json(:get, 'me/friends', 'users/friends/me_public')
      fake_json(:get, 'me/friends?access_token=access_token', 'users/friends/me_private')
      fake_json(:get, 'arjun/friends', 'users/friends/arjun_public')
      fake_json(:get, 'arjun/friends?access_token=access_token', 'users/friends/arjun_private')
    end

    context 'when no access_token given' do
      it 'should raise FbGraph::Exception' do
        lambda do
          FbGraph::User.new('arjun').friends
        end.should raise_exception(FbGraph::Exception)
      end
    end

    context 'when identifier is not me' do
      it 'should raise FbGraph::Exception' do
        lambda do
          FbGraph::User.new('arjun', :access_token => 'access_token').friends
        end.should raise_exception(FbGraph::Exception)
      end
    end

    context 'when identifier is me and no access_token is given' do
      it 'should raise FbGraph::Unauthorized' do
        lambda do
          FbGraph::User.new('me').friends
        end.should raise_exception(FbGraph::Unauthorized)
      end
    end

    context 'when identifier is me and access_token is given' do
      it 'should return friends as FbGraph::User' do
        users = FbGraph::User.new('me', :access_token => 'access_token').friends
        users.first.should == FbGraph::User.new(
          '6401',
          :access_token => 'access_token',
          :name => 'Kirk McMurray'
        )
        users.each do |user|
          user.should be_instance_of(FbGraph::User)
        end
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
fb_graph-1.6.7 spec/fb_graph/connections/friends_spec.rb
fb_graph-1.6.5 spec/fb_graph/connections/friends_spec.rb
fb_graph-1.6.4 spec/fb_graph/connections/friends_spec.rb
fb_graph-1.6.3 spec/fb_graph/connections/friends_spec.rb
fb_graph-1.6.2 spec/fb_graph/connections/friends_spec.rb
fb_graph-1.6.1 spec/fb_graph/connections/friends_spec.rb
fb_graph-1.6.0 spec/fb_graph/connections/friends_spec.rb
fb_graph-1.5.5 spec/fb_graph/connections/friends_spec.rb
fb_graph-1.5.4 spec/fb_graph/connections/friends_spec.rb
fb_graph-1.5.3 spec/fb_graph/connections/friends_spec.rb
fb_graph-1.5.2 spec/fb_graph/connections/friends_spec.rb
fb_graph-1.5.1 spec/fb_graph/connections/friends_spec.rb
fb_graph-1.5.0 spec/fb_graph/connections/friends_spec.rb
fb_graph-1.4.1 spec/fb_graph/connections/friends_spec.rb
fb_graph-1.4.0 spec/fb_graph/connections/friends_spec.rb
fb_graph-1.3.9 spec/fb_graph/connections/friends_spec.rb
fb_graph-1.3.8 spec/fb_graph/connections/friends_spec.rb
fb_graph-1.3.7 spec/fb_graph/connections/friends_spec.rb
fb_graph-1.3.6 spec/fb_graph/connections/friends_spec.rb
fb_graph-1.3.5 spec/fb_graph/connections/friends_spec.rb