blog post about using TDD during an interview.This repo holds the code for a
The goal is to implement the following specification:
Produce a method that prints the nth occurrence of the Fibonacci series, given n as a parameter. This should not make recursive calls. As a bonus, modify the code to keep printing Fibonacci numbers indefinitely. The two first terms for this are F0=0 and F1=1.
The list of tests for this is presented below. These are sorted by ascending complexity:
- When given 0, expect 0
- When given 1, expect 1
- When given 2, expect 1
- When given 3, expect 2
- When given 4, expect 3
- When given 5, expect 5
- When given 10, expect 55
- When given -1, raise an ArgumentError (edge case: handle negative input)
- When given 10, print 55 (test the printing functionality)
The minimum amount of code to pass every test will be present under
n is the number of the test in the list above.