Skip to content

Instantly share code, notes, and snippets.

@foysavas
Forked from mattknox/inline_test
Created March 18, 2010 21:13
Show Gist options
  • Save foysavas/336903 to your computer and use it in GitHub Desktop.
Save foysavas/336903 to your computer and use it in GitHub Desktop.
> ruby -rmath_functions.rb -e "puts MathFunctions.factorial(2)"
2
> ruby --test -rmath_functions.rb
.
Finished in 1.000706 seconds.
1 tests, 2 assertions, 0 failures, 0 errors
module MathFunctions
def self.factorial(n)
(1..n).inject(1) { |acc, x| acc * x}
end
end
=begin :unittest
assert MathFunctions.factorial(6) == 720
assert MathFunctions.factorial(5) == 120
=end
@jeroenvandijk
Copy link

FYI, I have restructured stuff and started writing a simple gem and added some examples using rspec.

Not sure how this will end up. Here is the repo http://github.com/jeroenvandijk/inline_tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment