Sha256: a91d4bff0c80463d159272bc55d385ca3b5e5fcb9c6e7656a45c890101892894

Contents?: true

Size: 1.84 KB

Versions: 104

Compression:

Stored size: 1.84 KB

Contents

require 'spec_helper'

describe FbGraph::Connections::Friends, '#friends' do
  context 'when included by FbGraph::User' do
    context 'when no access_token given' do
      it 'should raise FbGraph::Unauthorized' do
        mock_graph :get, 'arjun/friends', 'users/friends/arjun_public', :status => [401, 'Unauthorized'] do
          lambda do
            FbGraph::User.new('arjun').friends
          end.should raise_exception(FbGraph::Unauthorized)
        end
      end
    end

    context 'when identifier is not me' do
      it 'should raise FbGraph::Unauthorized' do
        mock_graph :get, 'arjun/friends', 'users/friends/arjun_private', :access_token => 'access_token', :status => [401, 'Unauthorized'] do
          lambda do
            FbGraph::User.new('arjun', :access_token => 'access_token').friends
          end.should raise_exception(FbGraph::Unauthorized)
        end
      end
    end

    context 'when identifier is me and no access_token is given' do
      it 'should raise FbGraph::Unauthorized' do
        mock_graph :get, 'me/friends', 'users/friends/me_public', :status => [401, 'Unauthorized'] do
          lambda do
            FbGraph::User.new('me').friends
          end.should raise_exception(FbGraph::Unauthorized)
        end
      end
    end

    context 'when identifier is me and access_token is given' do
      it 'should return friends as FbGraph::User' do
        mock_graph :get, 'me/friends', 'users/friends/me_private', :access_token => 'access_token' 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
end

Version data entries

104 entries across 104 versions & 1 rubygems

Version Path
fb_graph-2.7.17 spec/fb_graph/connections/friends_spec.rb
fb_graph-2.7.16 spec/fb_graph/connections/friends_spec.rb
fb_graph-2.7.15 spec/fb_graph/connections/friends_spec.rb
fb_graph-2.7.14 spec/fb_graph/connections/friends_spec.rb
fb_graph-2.7.13 spec/fb_graph/connections/friends_spec.rb
fb_graph-2.7.12 spec/fb_graph/connections/friends_spec.rb
fb_graph-2.7.11 spec/fb_graph/connections/friends_spec.rb
fb_graph-2.7.10 spec/fb_graph/connections/friends_spec.rb
fb_graph-2.7.9 spec/fb_graph/connections/friends_spec.rb
fb_graph-2.7.8 spec/fb_graph/connections/friends_spec.rb
fb_graph-2.7.7 spec/fb_graph/connections/friends_spec.rb
fb_graph-2.7.6 spec/fb_graph/connections/friends_spec.rb
fb_graph-2.7.5 spec/fb_graph/connections/friends_spec.rb
fb_graph-2.7.4 spec/fb_graph/connections/friends_spec.rb
fb_graph-2.7.3 spec/fb_graph/connections/friends_spec.rb
fb_graph-2.7.2 spec/fb_graph/connections/friends_spec.rb
fb_graph-2.7.1 spec/fb_graph/connections/friends_spec.rb
fb_graph-2.7.0 spec/fb_graph/connections/friends_spec.rb
fb_graph-2.6.7 spec/fb_graph/connections/friends_spec.rb
fb_graph-2.6.6 spec/fb_graph/connections/friends_spec.rb