Rails/Devise - 我应该使用 devise 和 rspec 测试什么?
许多程序员使用 devise 作为他们的身份验证解决方案,我想得到他们的建议:
Devise 已经经过测试,但我想知道是否有一些东西可以自己测试(集成/单元/功能测试?)以与标准设备集成我的知识 (我不熟悉shoulda和cucumber,但我了解一些rspec和工厂女孩)
谢谢你的建议!
Many programmers use devise as their authentication solution and I would like to get their advice:
Devise is already tested, but I want to know if there is something to test by myself (integration/unit/funtionnal tests?) for a standard devise integration with my knowledge
(I'm not familiar with shoulda and cucumber, but I know a bit of rspec and factory girls)
Thanks for your advices!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
从单元测试的角度来看,devise 提供了 2 个辅助方法,
您可能需要它们来测试您的控制器操作是否以正确的方式运行,例如不允许您在未登录时创建帖子。
从集成测试的角度来看,定义一堆黄瓜步骤,它们将执行相同的
sign_in & Sign_out
看起来像When /^I am Sign in as (\w*)$/ do end
并使用它来进行实际导航,而不是使用 rspec 提供的 rspec 帮助程序。那应该很好。
From the unit testing perspective, devise provides 2 helper methods
You might be needing them to test if your controller actions are behaving in a proper way such as not allowing you to create a post when you are not logged in.
From the Inegration testing perspective, define a bunch of cucumber steps which will do the same
sign_in & sign_out
something that looks likeWhen /^I am signed in as (\w*)$/ do end
and use that to do the actual navigation instead of using the rspec helpers provided by rspec.That should be good.
是的,对于这种情况,Cucumber Stories 是最好的,使用 Javascript 场景,我们还测试了 Facebook Connect 和其他 OAuth 服务,工作得很好:)
Yes Cucumber Stories for this case are the best, using the Javascript Scenario's we do also test Facebook Connect and other OAuth Services, work pretty well :)
测试集成可能会很棒。因为这是您集成设备的方式,您可能会犯一些错误。定义一些cucumber特征就可以了。
Testing the integration can be great. Because is how you integrate devise where you can do some error. Define some cucumber feature and it's OK.