How would one test that when an action in controller is being accessed, that controller's before_filter will be executed?
The before_filter is tested in separate example group so that there's no need to duplicate the tests for all actions that depend on the before_filter.
If I have
controller.should_receive(:my_before_filter)
in my example, it works fine. However, having the above expectation seems to cause that the logic in my_before_filter
is not being executed (it should assign an instance variable).
How to overcome this restriction or to mock behaviour of my_before_filter (it sets instance variable on controller)? Or is there some better way to do this?
As it's now clear I was doing it all wrong, I'd still like to know how one could mock the behaviour of before_filter that sets an instance variable. Surely it must be a possible to do this in a controller spec?