Reputation: 2450
Title says it all.
I have a controller action in which I do some stuff, then call a method that is defined in ApplicationController
.
How do I test that it was called?
controller.should_receive(:the_method_name)
doesn't work.
ApplicationController.should_receive(:the_method_name)
doesn't work.
What's the proper syntax?
Thanks.
Upvotes: 3
Views: 2389
Reputation: 31
Using the AnonymousController as Gerep suggested and calling controller.should_receive(:the_method_name)
should do it.
The position within the test is important to let the test pass successfully. To give you an example:
describe 'my test' do
before do
controller.should_receive(:the_method)
get :action
end
it { should render_template(:your_template) }
end
This example should pass and tests also the call of :the_method
.
Upvotes: 0
Reputation:
I think you can use anonymous controller to test your ApplicationController, check the documentation.
Upvotes: 1