我是编程新手(3 个月),并且正在尝试通过 TDD 学习。
显然,TDD 的重点是首先编写测试用例,这个特别的部分我不知道该怎么做。
代码片段是:
class PhraseFactory
def initialize
@sentence = ''
end
def make_sentences_from
for i in 0 ... self.length
@sentence += self[i] + ' '
end
end
我想如何测试它正在使用:
describe "When sent a message(<< is that proper terminology?) from an array of strings"
it "Builds a sentence"
my_word_array.should_have (here is where I am unclear)sent_a_message_to(make_sentences_from)
谢谢你的帮助。