Rails/Devise - What should I test with devise and rspec?

ε祈祈猫儿з 提交于 2019-12-04 18:05:17

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.

From the unit testing perspective, devise provides 2 helper methods

sign_in @user          # sign_in(resource)
sign_out @user         # sign_out(resource)

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 like When /^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.

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 :)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!