-
authlogic facebook-connect and rspec
Posted on September 22nd, 2009 No commentsThe past week I’ve had a chance to add facebook-connect to a rails site we’ve been working on by using the fantastic Authlogic and the Authlogic Facebook Connect add on. However I found that all my existing controller tests blew up after adding the facebook-connect add on and after a little digging realized I needed to stub a method on the rspec TestRequest method.
The TestCase rdoc explains how to setup authlogic within your rspec controller tests, so I won’t get into that here. Since I already had everything setup with a login method in my spec_helper.rb file, I just had to add a single line to that method.
~/spec/spec_helper.rb
def login(user)
request.stub!(:set_facebook_session)
UserSession.create(users(user))
end
Eventually I’ll have to write some tests for any features that use the facebook api, but for now stubbing that method does the trick.


Recent Comments