Reputation: 5931
Is stubbing filters/actions in controller specs considered as a good practise?
Let's say I have filter authorize!
on almost every controller. Can I just stub it in all controller specs or I should have shared examples for testing each action if it has filter/action behaviour?
Things are getting messy when there are dozen of filters/actions on controllers (also inherited...)
Upvotes: 0
Views: 37
Reputation: 47568
IMHO you should only stub when you need to. Some good reasons are:
"Messiness" is not a good reason. RSpec provides a plethora of tools for cleaning up test code and making it more readable. Spend some time improving the tests and you may find that the desire for stubbing things out is reduced.
Upvotes: 2