Created
March 18, 2010 18:16
-
-
Save mattknox/336665 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 MathFunctions | |
include InlineTest | |
def factorial(n) | |
(1..n).inject(1) { |acc, x| acc * x} | |
end | |
unit_test do | |
assert factorial(6) == 720 | |
assert factorial(5) == 120 | |
end | |
end | |
module InlineTest | |
def env_is_testy? | |
true | |
end | |
if env_is_testy? | |
def unit_test(name, &block) | |
block[] | |
end | |
else | |
def unit_test(*args, &block) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment