99 bottles of beer 測試練習

本章使用 99 bottles of beer 來練習 RSpec。首先介紹一下 99 bottles of beer。

99 bottles of beer 是美國民謠,歌曲是這麼唱的:

99 bottles of beer on the wall, 99 bottles of beer.
Take one down, pass it around, 98 bottles of beer on the wall

下一段 98 bottles of beer:

98 bottles of beer on the wall, 98 bottles of beer.
Take one down and pass it around, 97 bottles of beer on the wall.

一直唱到 1 跟最後一段:

1 bottle of beer on the wall, 1 bottle of beer.
Take it down and pass it around, no more bottles of beer on the wall.

No more bottles of beer on the wall, no more bottles of beer.
Go to the store and buy some more, 99 bottles of beer on the wall.

本章就是要撰寫一個程式來產生 99 bottles of beers 的歌詞。

前置作業

建立資料夾:

$ git clone https://github.com/JuanitoFatas/99bottles-demo && cd 99bottles-demo && git reset --hard cb88d227a44cf5c4a259bf2e873498b6bab518c0

配置 test suite

按 commit 順序閱讀:

https://github.com/JuanitoFatas/99bottles-demo/pull/1

TDD demo

按 commit 順序閱讀:

https://github.com/JuanitoFatas/99bottles-demo/pull/2

results matching ""

    No results matching ""