rspec/rspec-mocks — Issue #94: SystemStackError when using 'stub any_instance' in superclass
Author: lax10019
Created: 2012-01-18 10:00:35+00:00
State: open

require 'rspec'

class Abc
def say_lala
'juhjs'
end
end

class Bbb < Abc
def say_lala
'bbb' + super.to_s
end
end

describe Bbb do
it 'normal case' do
Abc.new.say_lala.should == 'juhjs'
Bbb.new.say_lala.should == 'bbbjuhjs'
end

it 'should only mock bbb' do
Bbb.any_instance.stub(:say_lala).and_return(12345)
Bbb.new.say_lala.should == 12345

Abc.new.say_lala.should == 'juhjs'
end

it 'should mock child and parent class' do
Abc.any_instance.stub(:say_lala).and_return(12345)
Abc.new.say_lala.should == 12345
Bbb.new.say_lala.should == 'bbb12345'
end
end

The third test case is failed and cause a SystemStackError at "Bbb.new.say_lala.should.....". Is it a bug or I did something wrong? Thanks!