Drawing the line between controller and integration tests

I’m trying to understand what belongs – and what doesn’t belong – in
controller tests and in integration tests.

As a common example, assume I have a list of named widgets. Somewhere
in my code, I want to verify that

widget = FactoryGirl.create(:widget)
get :index

generates a page that has the string #{widget.name} somewhere therein.
But is that a controller test or an integration test?

As another example, assume a user must be logged on in order to access
the widgets. I can test authentication and authorization separately,
but is it considered necessary to write an integration test for this?
Or is this something you’d verify in a controller test?

Etc. I’m not looking for specific answers to the above as much as
guiding principles, or at least pointers to same. Thanks!

One addendum: One thing I’d specifically like to know is where/how do
you test the contents of generated responses? That seems beyond the
purview of a controller test, but it doesn’t require multiple
transactions or cross-controller interactions that would require an
integration test.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service