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

3

2

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!!

Vicinage answered 26/10, 2010 at 14:49 Comment(0)
U
0

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.

Upstairs answered 26/10, 2010 at 15:15 Comment(0)
E
6

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.

Expansion answered 26/10, 2010 at 19:27 Comment(0)
G
1

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

Geanine answered 26/10, 2010 at 15:37 Comment(0)
U
0

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.

Upstairs answered 26/10, 2010 at 15:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.