So say you were doing this in ruby and you wanted to write a method sum
that took numbers and added them together. You'd have one ruby file that contained your test, call it math_test.rb
, and one ruby file that contained your method, call it math.rb
. They'd look something like this:
math_test.rb:
def test_summation
assert 4 == sum(2, 2)
assert 0 == sum(2, -2)
end
Initially if you ran math_test.rb
without math.rb
it's gonna fail. Then you write math.rb
:
def sum(a, b)
a + b
end
And now if you run math_test.rb
the test should pass.