dewyze
dewyze

Reputation: 979

Do I need to test functionality of Ruby Gems (Devise) I am using?

I am still new to rails, but I went through Michael Hartl's book (super hepful, btw).

However, I started using Devise (also super helpful) and I had a question about testing with rspec. In Hartl's book, there are all these tests for user validations like uniqueness of email or just whether or not a user is created with valid attributes.

Are simple tests like this needed if I am using Devise?

Part of the reason I am asking is I can't figure out how to write the tests even though I know they are working. In general do you need to test gems to see if their internal functionality is working? Or can I just assume that will work and only test that a user can be created and logged in and be done with it?

I do test how I CanCan in that I test if I was redirected or not, but that seems more like testing that the rules I created are right. Testing the inner functions of Devise seems excessive?

Upvotes: 1

Views: 192

Answers (1)

Jesse Wolgamott
Jesse Wolgamott

Reputation: 40277

I would consider testing the inner functions of devise to be excessive. However, if you make changes to devise, either the views, controllers, or validations, it would be appropriate then to test your changes.

I also always have request/acceptance tests that test the sign in/up part of my app.

You also asked:

In general do you need to test gems to see if their internal functionality is working?

No, this is generally not done. Things I like to look for: on the gem's github or webpage, do they link to TravisCI --- you can see if their current test suite works. In general, test at your level, not one beneath. For example, don't test that Rails works, just use Rails.

Upvotes: 5

Related Questions