Assume I have a list of named widgets. Somewhere in my test code, I want to verify that
widget = FactoryGirl.create(:widget)
get :index
generates a page that contains the string #{widget.name} somewhere on it.
My question: do I write this as a controller test or as an integration test?
(Aside #1: This seems outside the scope of a controller test, since it is assuming knowledge about what view is rendered. But writing it as an integration test feels too heavyweight, since it only requires a single request / response transaction.)
(Aside #2, my general question is “how do you decide what goes in controller tests and what goes in integration tests?” But this is arguably too broad for a Stack Overflow question.)
Sometimes I think Stack Overflow should award an RTFM badge, and that I should be one of the first to receive it!
Digging around more, I found that RSpec supports “View specs” that are designed specifically to test the contents of what’s rendered — that’s precisely what my original question was about.
The tests get written in spec/views/. Documentation and examples can be found here, but be sure to look at the documentation for your current version of RSpec.