Is it possible to test controllers without calling views?

Let's imagine, that we test a controller method - isolated peace of
code with a well-defined responsibility: treat request and produce
response (and may be also authorize user). We set up our mocks and
stubs, i.e. doing minimal setup for running single method.

And what we have? Test fails because view-file called methods of your
model, which you did not mocked or stubbed. So, we have to setup
UNNESSESARY stub-methods/mock-expectations because of code, which has
no meaning during the test. As a result, our nice simple test code
grows up to a unreadable monster.

Does anyone have experience with solving this problem?

Let's imagine, that we test a controller method - isolated peace of
code with a well-defined responsibility: treat request and produce
response (and may be also authorize user). We set up our mocks and
stubs, i.e. doing minimal setup for running single method.

And what we have? Test fails because view-file called methods of your
model, which you did not mocked or stubbed. So, we have to setup
UNNESSESARY stub-methods/mock-expectations because of code, which has
no meaning during the test. As a result, our nice simple test code
grows up to a unreadable monster.

Could you stub the render method ? (don't you want to know if there's
a typo etc... in your view?)

Fred

Could you stub the render method ?

Thank for idea, Fred, it could works, I'll try

(don't you want to know if there's a typo etc... in your view?)

Yes, I agree, it is important role of functional tests: they prevent
dumb mistakes. But I prefer to write a separate test for that, often
with fixtures.