Skip to content

Instantly share code, notes, and snippets.

@richardking
Created February 20, 2014 23:39
Show Gist options
  • Select an option

  • Save richardking/9125719 to your computer and use it in GitHub Desktop.

Select an option

Save richardking/9125719 to your computer and use it in GitHub Desktop.
insta2 - model spec
require 'spec_helper'
describe InstagramSyncFollowingWorker do
it 'should import or sync based on number of followers' do
InstagramAccount.stub(:import_or_sync)
VCR.use_cassette 'lib/instagram_user_follows' do
response = Instagram.user_follows
InstagramAccount.should_receive(:import_or_sync).exactly(response.count).times
InstagramSyncFollowingWorker.perform
end
end
it 'should update import_enabled for accounts that are not being followed anymore' do
VCR.use_cassette 'lib/instagram_user_follows_2' do
account = FactoryGirl.build(:instagram_account)
account.stub(:sync_following)
account.stub(:get_instagram_id)
account.save
InstagramSyncFollowingWorker.perform
InstagramAccount.find(:all, :conditions => ["import_enabled = ?", true]).count.should == 2
InstagramAccount.find(:all, :conditions => ["import_enabled = ?", false]).count.should == 1
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment