class StrawMan
attr_accessor :assertion_log
@assertion_log = []
class << self
def check_assertions(name, &assertion)
alias_method :some_crazy_uuid, name
define_method(name) do |*args, &block|
assertion_log << Array(assertion.call(*args))
method(:some_crazy_uuid).call(*args, &block)
end
end
end
# Test methods
def sum(x,y)
x.to_i + y.to_i
end
check_assertions(:sum) do |x,y|
x.respond_to?(to_i) && y.respond_to?(to_i)
end
end
Created
April 4, 2013 06:09
-
-
Save wangjohn/5308220 to your computer and use it in GitHub Desktop.
Assertion Checking
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment