So I rails g scaffold bar content:string
in Rails, it generates a whole lot of things. As a newbie in testing, I have little idea on what to put in each category.
Some context first:
- The testing framework is RSpec
- I'm using devise for authentication and pundit for authorization
- The bar resource only allow accesses from authenticated users
- Each user is only authorized to CRUD his own bar resource
Now the problem (I know it's a lot, sorry!):
- If I've already unit tested my pundit policies, do I need to test about authorizations in my controller specs?
- Do I test authentication in controller specs? Or should I just leave it to request specs?
- Is separated view tests necessary? I've been told more than once that it's not necessary and I should just go with feature specs.
- About request specs, do I need to test all 3 scenarios namely not authenticated, authenticated but not authorized, authorized for each action?
- What's the scope of feature tests? Do I test major functionalities or also every corner case?