9. Optimize? Memoize!
describe BowlingGame do
def game
@game ||= BowlingGame.time_consuming_method
end
it "scores all gutters with 0" do
20.times { game.roll(0) }
game.score.should == 0
end
it "scores all 1's with 20" do
20.times { game.roll(1) }
game.score.should == 20
end
end
vendredi 16 octobre 2009