In one of my controller tests I’m testing a method which uses
self.send() to do some pre-processing if that
private method name is defined:
# If this task requires some additional preperation then
# private method below with the same name as the
# it will be executed here.
I will be testing these private_methods separately so I want to just
stub out the “self.send” line so that I can verify that it’s called if
there’s a match.
If I just stub out :send in my before() method:
then it appears that a previous send is stubbed, and my method never
gets tested (shown by my first should not getting hit).
If I specify a “with” for that stub:
I then get a “stack level too deep” error.
I have similar problems when attempt to use the following instead of
it "should run any private methods if task_type matches" do @mock_task.should_receive(:run).and_return(@mock_task) @controller.should_receive(:send).with('private method') do_request end
Here I get the error message “Mock ‘TasksController’ expected :send
with (“private method” but received it with (:perform_action)”
Is there any way that I can stub out just the :send with “private
method” and leave the other one alone to execute?