Skip to content

Instantly share code, notes, and snippets.

@bnadlerjr
Created December 1, 2013 05:17
Show Gist options
  • Save bnadlerjr/7728771 to your computer and use it in GitHub Desktop.
Save bnadlerjr/7728771 to your computer and use it in GitHub Desktop.
class Test::Unit::TestCase
def self.let(name, &block)
ivar = "@#{name}"
self.class_eval do
define_method(name) do
if instance_variable_defined?(ivar)
instance_variable_get(ivar)
else
value = self.instance_eval(&block)
instance_variable_set(ivar, value)
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment