Created
October 9, 2009 14:55
-
-
Save jamesbebbington/206073 to your computer and use it in GitHub Desktop.
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
# Doesn't work when user arg is a reference to variable in an outer context | |
class Test::Unit::TestCase | |
def self.logged_in_as(user, &block) | |
context "logged in as #{user}" do | |
setup do | |
UserSession.create(user) | |
end | |
merge_block(&block) if block_given? | |
end | |
end | |
end | |
# The Fix: Passing in var name as a string i.e. logged_in_as('@user') do ... | |
class Test::Unit::TestCase | |
def self.logged_in_as(user, &block) | |
context "logged in as #{user}" do | |
setup do | |
UserSession.create(eval(user)) | |
end | |
merge_block(&block) if block_given? | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment