Skip to content

Instantly share code, notes, and snippets.

@bmabey
Created March 15, 2009 16:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bmabey/79470 to your computer and use it in GitHub Desktop.
Save bmabey/79470 to your computer and use it in GitHub Desktop.
module ObjectLocators
def the_policy
if @policy
@policy
else
case Policy.count
when 0
raise "There is no @policy variable defined and no policy in the DB! Establish state in previous step or create a new policy."
when 1
Policy.first
else
raise "There are multiple policies in DB and no @policy variable set! Please disambiguate the state in previous step."
end
end
end
end
World { |world| world.extend(ObjectLocators) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment