Created
March 30, 2010 15:19
-
-
Save vidmantas/349188 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
# in spec_helper.rb | |
config.mock_with :mocha | |
#... | |
end | |
# returns current fake user | |
def current_user | |
@current_user ||= User.make | |
end | |
# returns current session mock | |
def user_session | |
@user_session = mock | |
@user_session.stubs(:user).returns(current_user) | |
@user_session.stubs(:record) | |
@user_session | |
end | |
# logges me in | |
def login_stub | |
UserSession.any_instance.stubs(:find).returns(user_session) | |
controller.stubs(:current_user).returns(current_user) | |
end | |
# logges me out | |
def logout | |
@user_session = nil | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment