我如何以 BDD 风格测试 Rhomobile 中的控制器?
我正在使用 Rhomobile 框架来开发一个应该在不同手机上运行的应用程序。 教程提到了如何为示例模型编写测试:Person。事实上,该框架提供了一个命令行工具 rhogen spec 来生成模型的虚拟测试。我将如何为控制器类编写测试:PersonController?我正在考虑类似于 Rails,但 rspec 对我来说是未知的,并且方法 post
和 redirect_to
似乎不起作用。
I am using the Rhomobile framework to develop an application that is supposed to run on different mobile phones. The tutorial mentions how to write tests for the example model: Person. In fact, the framework provides a command-line tool rhogen spec
to generate the dummy tests for the models. How would I go about writing tests for the controller class: PersonController? I was thinking of something similar to how one would do it in Rails, but rspec is unknown to me, and the methods post
and redirect_to
doesn't seem to work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 BDD 中,当您想要指定应用程序的行为(这是控制器负责的)时 - 您通常会使用 StoryBDD 框架来实现这一点 - 例如使用 黄瓜。 Rspec 是 SpecBDD,并考虑到不同的抽象级别 - 它用于指定类如何相互通信以及它们做什么。
您可以在 Cucumber 的 github 页面 上找到许多教程。 这个可能会有帮助
In BDD when you want to specify the behavior of the application (this is what controllers are responsible for) - you would normally aproach that with a StoryBDD framework - use for example Cucumber . Rspec is SpecBDD and regards a different level of abstraction - it is for specifying how classess communicate with each other and what they do.
You can find many tutorials on Cucumber's github page. This one could be helpful