← Back to Upcase

Testing Controllers with concerns (RSPEC)

(AntonioIrizarry) #1

Have a concern called Trackable that I use in many controllers. I want to test the responses for each controller using Trackable in the same file. Any Ideas on good practice for completing this?

(Geoff Harcourt) #2

Hey @tonytaudesign,

As long as “many” means more than 5, I would build an anonymous inline controller that also includes Trackable, test that, and then write a macro that confirms that each of your controllers includes Trackable.

Here’s a good Railscast where Ryan Bates builds an RSpec controller macro. I often use this in controller specs to verify that actions require or don’t require logins.


(AntonioIrizarry) #3

Thanks Geoff!