I know how to do TDD in other languages, but I’m new to both ruby and wrong. I’m struggling a bit with the fundamentals of how to setup a (toy) project. I want to write a method which computes the factorial (n! = 1 * 2 * 3 * ... * n). I have created the file test/factorial_test.rb, which so far contains
require 'wrong'
include Wrong
How do I proceed from here? Do I write my assertions in the global scope of the file
assert { factorial(1) == 1 }
assert { factorial(2) == 2 }
#...
(which feels a bit weird)? Or should I follow some (which?) convention and wrap each test in its own method
def one_factorial_should_be_one
assert { factorial(1) == 1 }
end
I’m a bit lost with the fundamentals here, so any answer on what is considered best-practice here is highly appreciated.
Wrong merely provides a couple (admittedly smart) assertion methods. You still need a framework to automate running the tests, e.g. minitest.