← Back to Upcase

Best examples of controller specs?


(Justin Gordon) #1

Does anybody have any favorite examples or articles on writing great controller specs?


(Derek Prior) #2

I can’t site an example off hand, but I generally find myself using controller specs for sad-path stuff. That is, assert that a user can’t access another user’s posts or something similar. This lets me leave feature specs for the happy path.


(Ralph Wintle) #3

@Justin_Gordon Not sure if this is what you’re looking for, but I forked this gist which provides a good template/example for writing your specs (including controller specs) and aren’t too dissimilar to Thoughtbot’s style guide.

The Greatest Hits of Rspec Testing: Volume 1

(Came across it via this good post from the guys at DevMynd.)


(Luís Ferreira) #4

I do the same thing @derekprior does, so my controller specs are not that interesting. I leave the interesting parts to unit tests and make sure it all works with integration tests.