You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
describe'`stack level too deep` when stubbing :is_a? 'dolet(:klass)doClass.newdodefais_a?(self)endendendbefore{allow_any_instance_of(klass).toreceive(:is_a?).and_return(true)}it{expect(klass.new.a).tobe(true)}end
Expected behavior
The spec should pass.
Actual behavior
% rspec stub_is_a_spec.rb
Failures:
1) AccountsProduction::AppSwitcherRequester
Failure/Error: is_a?(self)
SystemStackError:
stack level too deep
Subject of the issue
The error "
stack level too deep
" occurs when stubbing:is_a?
withallow_any_instance_of
.Your environment
Ruby version: ruby 2.7.5p203 (2021-11-24 revision f69aeb8314) [x86_64-linux]
rspec-mocks version: 3.12.6
Steps to reproduce
stub_is_a_spec.rb
Expected behavior
The spec should pass.
Actual behavior
% rspec stub_is_a_spec.rb Failures: 1) AccountsProduction::AppSwitcherRequester Failure/Error: is_a?(self) SystemStackError: stack level too deep
The stack is recursively called at this line of code obviously.
https://github.com/rspec/rspec-mocks/blob/v3.12.6/lib/rspec/mocks/proxy.rb#L38
I don't encounter the error if I initialize the class and utilize the instance generated.
The text was updated successfully, but these errors were encountered: