Topic: Controller testing with mocks

I'm struggling with my first attempt at TDD in Rails with RSpec. So I ended up implementing a couple of controller actions first, now I'm attempting to go back and test.

Here's the code:

class SessionsController < ApplicationController
  skip_before_filter :graph
  @@oauth = Koala::Facebook::OAuth.new(APP_CONFIG['facebook']['app_id'], APP_CONFIG['facebook']['secret'], "#{APP_CONFIG["root_url"]}sessions/create/")

  def new
    redirect_to @@oauth.url_for_oauth_code
  end

  def create
    access_token = @@oauth.get_access_token(params[:code])
    
    graph = Koala::Facebook::GraphAPI.new(access_token)
    me = graph.get_object('me')
    
    user = User.find_by_fb_id(me['id'])
    if user
      user.access_token = access_token
    else
      user = User.new({:fb_id => me['id'], :access_token => access_token})
    end
    user.save
    session[:user_id] = user.id
    
    redirect_to :controller => 'pages', :action => 'index'
  end
end

And here's the explanation:

I'm using the Koala gem for Facebook. It has an OAuth class for authenticating, and a GraphAPI class for interacting with the API.

SessionsController#new just redirects to Facebook, where the user grants permissions.

Once permissions are granted, Facebook redirects to SessionsController#create with a code parameter in the query string. Passing that code as an argument to @@oauth.get_access_token requests a permanent OAuth access token from Facebook.

That access token is then passed as an argument when instantiating a new GraphAPI object.

The graph.get_object('me') call gets a hash of user information from the Facebook Graph API.

Everything else is vanilla Rails.

The spec for SessionsController#new is really easy:

describe SessionsController do
  context 'new' do
    it "should redirect to Facebook's permission page" do
      get :new
      response.should be_redirect
    end
  end
end

But I'm at a loss for SessionsController#create since it requires mocking of three Facebook API calls. After reading good things about RR, that's what I attempted to use for test doubling, but I didn't come up with anything worth sharing here.

Can someone lend a hand to get me started? I'm open to using RSpec, RR, Mocha or anything else for mocking.