Is stubbing a call to super possible?

Hi

Is stubbing a call to super possible? I am testing a protected
method called authorized in a Rails controller … part of the logic
flow calls super which calls the method authorized in the application
controller.

As I am focused on the logic of the method in the controller I am
testing I just wish to stub the value returned in the super.

Is this at all possible?

Cheers
Shane

Shane M.
ELC Technologies ™
PO Box 247
Santa Barbara, CA 93102

Phone: +64 4 568 6684
Mobile: +64 21 435 586
Email: [email protected]
AIM: ShaneMingins
Skype: shane.mingins

(866) 863-7365 Tel - Santa Barbara Office
(866) 893-1902 Fax - Santa Barbara Office

+44 020 7504 1346 Tel - London Office
+44 020 7504 1347 Fax - London Office


Privacy and Confidentiality Notice:
The information contained in this electronic mail message is intended
for the named recipient(s) only. It may contain privileged and
confidential information. If you are not an intended recipient, you
must not copy, forward, distribute or take any action in reliance on
it. If you have received this electronic mail message in error,
please notify the sender immediately.

On 5/10/2007, at 11:56 AM, Shane M. wrote:

Is this at all possible?

In the meantime I have used alias_method_chain to override the method
in the super class.

In the meantime I have used alias_method_chain to override the method
in the super class.
I up this old post, but I was having the same problem mocking super() so
I had to alias_method_chain my method.

On Sun, May 24, 2009 at 2:25 PM, Fernando P. [email protected]
wrote:

In the meantime I have used alias_method_chain to override the method
in the super class.
I up this old post, but I was having the same problem mocking super() so
I had to alias_method_chain my method.

You can’t mock super because super doesn’t behave like other methods.
It is a language keyword that invokes the same method on the parent
class. So if you do this:

def foo
super
end

… the call to super calls foo on the superclass.

Since we don’t get into the class hierarchy in rspec’s mock/stub
framework, there is no facility for managing this. I believe that is
the case for mocha, flexmock and rr as well, though I could be wrong.

HTH,
David