Created
August 20, 2010 13:11
-
-
Save potomak/540276 to your computer and use it in GitHub Desktop.
This file contains 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 AdminController do | |
before { login } | |
it "should be accessible only by admins!" | |
end |
This file contains 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
def current_user(stubs = {}) | |
@current_user ||= mock_model(User, stubs) | |
end | |
def user_session(stubs = {}, user_stubs = {}) | |
@current_user ||= mock_model(UserSession, {:user => current_user(user_stubs)}.merge(stubs)) | |
end | |
def login(session_stubs = {}, user_stubs = {}) | |
UserSession.stub!(:find).and_return(user_session(session_stubs, user_stubs)) | |
end | |
def logout | |
@user_session = nil | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment