Created
April 9, 2014 06:26
-
-
Save leucos/10231670 to your computer and use it in GitHub Desktop.
Mocking authentication in Padrino
This file contains hidden or 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
# ... | |
# Somewhere in spec_helper.rb | |
def login_as(role = nil) | |
if (role) | |
acct = Account[:role => role] || Account.new(:name => 'Foo', :surname => role, :email => "#{role}@none.org", :role => role) | |
Project::Admin.any_instance.stub(:current_account).and_return(acct) | |
Project::Admin.any_instance.stub(:logged_in?).and_return(true) | |
Project::App.any_instance.stub(:current_account).and_return(acct) | |
Project::App.any_instance.stub(:logged_in?).and_return(true) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment