zipmark/rspec_api_documentation

Is there a way to access the controller instance in an example?

gbirchmeier opened this issue · 2 comments

As subject. In my particular use case, I'd like to check that a private controller method is called at least once, and maybe be able to use allow(<controller>) instead of allow_any_instance_of(<controller_class>).

@gbirchmeier this is outside the scope of this project, but you'd need a way to get ahold of the specific instance of that controller from within your test.

I have never done what you are describing specifically, but you may need to mock the controller instantiation in order to get it done, which seems complex, and not necessarily compatible with the intended use case for RAD.

We, and my assumption is this is true for most people, use RAD for acceptance level tests where you are making calls to the public interfaces of your controllers and asserting on the responses that are returned instead of the implementation.

Feel free to reopen if there are follow ups.

Thanks, this is a perfectly acceptable answer. Probably my use-case is more suited to controller tests.