2
所以我有一个Weather类,它应该返回随机结果,并且我想使用stub来测试它。我在这http://www.martinfowler.com/articles/mocksArentStubs.html 阅读马丁花的文章,我觉得这将是最简单的解决方案。但很难找到任何语法的例子。你能给我一个测试的例子吗?这是我功课的一部分。在rspec中使用stub来测试rand的输出
class Weather
def conditions
return :good if chance > 0.3
:stormy
end
def chance
rand
end
end
很酷。很好,很简单 – Agata