Sha256: a2114b2a63a74e5ad93d6df69186af6bf3b300c10b5b3d0a96e1e9a2be02608f

Contents?: true

Size: 1.8 KB

Versions: 71

Compression:

Stored size: 1.8 KB

Contents

# -*- coding: utf-8 -*-
require 'spec_helper'

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

    context 'when access_token is given' do
      it 'should return liked pages as FbGraph::Page' do
        mock_graph :get, 'arjun/likes', 'users/likes/arjun_private', :access_token => 'access_token' do
          likes = FbGraph::User.new('arjun', :access_token => 'access_token').likes
          likes.first.should == FbGraph::Page.new(
            '378209722137',
            :access_token => 'access_token',
            :name => 'Doing Things at the Last Minute',
            :category => '活動'
          )
          likes.each do |like|
            like.should be_instance_of(FbGraph::Page)
          end
        end
      end
    end
  end

  describe '#like?' do
    let(:user)     { FbGraph::User.new(579612276, :access_token => 'access_token') }
    let(:fb_graph) { FbGraph::Page.new(117513961602338) }
    let(:poken)    { FbGraph::Page.new(1234567890) }

    context 'when liked' do
      it 'should retrun true' do
        mock_graph :get, '579612276/likes/117513961602338', 'users/likes/fb_graph', :access_token => 'access_token' do
          user.like?(fb_graph).should be_true
        end
      end
    end

    context 'otherwise' do
      it 'should retrun true' do
        mock_graph :get, '579612276/likes/1234567890', 'users/likes/poken', :access_token => 'access_token' do
          user.like?(poken).should be_false
        end
      end
    end
  end
end

Version data entries

71 entries across 71 versions & 1 rubygems

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