Created
November 23, 2012 08:11
-
-
Save cheald/4134479 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
module AuthenticationHelpers | |
def authenticated_as(roles, options=nil) | |
options = instance_eval(&options) if options.is_a? Proc | |
Array(roles).each do |role| | |
context "when logged in as a #{role}" do | |
before(:all) { @user = FactoryGirl.create role, *Array(options) } | |
after(:all) { DatabaseCleaner.clean } | |
before(:each) { sign_in @user } | |
after(:each) { sign_out @user } | |
yield if block_given? | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment