这可能超出了您应该测试的范围,但是如何测试使用缓存(即它使用缓存)的服务方法:
def get_payment_methods(country_code, filter=[])
key = "/countries/#{country_code.upcase}/payment_methods"
payment_methods = CACHE.get(key)
unless payment_methods
payment_methods = My::Service.get_payment_methods_for_country(country_code.upcase).first
CACHE.set(key, payment_methods)
end
# ...
end发布于 2013-12-11 01:13:13
您可以为您的方法创建一个CACHE加倍并验证以下内容:
对于RSpec来说,这一切都很简单
https://stackoverflow.com/questions/20508601
复制相似问题