简体   繁体   English

如何在Rails 2.3中存根/模拟一个辅助方法进行功能测试?

[英]How to stub/mock a helper method for functional test in Rails 2.3?

I'm wondering how to stub/mock a helper method in functional tests? 我想知道如何在功能测试中存根/模拟一个辅助方法? Thanks! 谢谢!

(And Yes, I already googled & used the search - but couldn't find any working solution, strange!?) (是的,我已经用Google搜索并使用了搜索-但找不到任何可行的解决方案,奇怪!!)

Have you read the Mocha documentation, specifically the returns method? 您是否阅读过Mocha文档,特别是returns方法? You can tell Mocha what the mocked version of your method should send back, letting you set up both good and bad results, depending on what you're trying to test. 您可以告诉Mocha您的方法的模拟版本应发送回什么,让您根据要测试的内容设置好结果和坏结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM