Created
May 1, 2012 01:47
-
-
Save destroytoday/2564306 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe TwitterFriendsHelper do | |
login_user | |
describe 'getFriendsIDs' do | |
context 'one page of friends' do | |
it 'should return ids' do | |
ids_response = loadJSONFixture('twitter/friends_ids/single_page.json') | |
Twitter.stub!(:friend_ids).and_return(ids_response) | |
getFriendsIDs.should eq [43115741, 631823, 6740642] | |
end | |
end | |
context 'multiple pages of friends' do | |
it 'should return ids' do | |
ids_first_page_response = loadJSONFixture('twitter/friends_ids/multi_page_1.json') | |
ids_second_page_response = loadJSONFixture('twitter/friends_ids/multi_page_2.json') | |
ids_third_page_response = loadJSONFixture('twitter/friends_ids/multi_page_3.json') | |
Twitter.stub!(:friend_ids).with({ :cursor => -1 }).and_return(ids_first_page_response) | |
Twitter.stub!(:friend_ids).with({ :cursor => ids_first_page_response['next_cursor'] }).and_return(ids_second_page_response) | |
Twitter.stub!(:friend_ids).with({ :cursor => ids_second_page_response['next_cursor'] }).and_return(ids_third_page_response) | |
getFriendsIDs.should eq [43115741, 631823, 6740642] | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment