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
require"bundler/inline"gemfile(true)dosource"https://rubygems.org"git_source(:github){ |repo| "https://github.com/#{repo}.git"}gem"rspec",github: "rspec/rspec"gem"rspec-core",github: "rspec/rspec-core"gem"rspec-expectations",github: "rspec/rspec-expectations"gem"rspec-mocks",github: "rspec/rspec-mocks"gem"rspec-support",github: "rspec/rspec-support"endrequire'rspec'classViewContextdefxxxendendclassProxydefinitialize@view_context=ViewContext.newenddefmethod_missing(name, *args, **kwargs, &block)self.class.define_method(name){@view_context.send(name)}send(name)endend# If this is uncommented — everything works# Proxy.new.xxxRSpec.describe'fail'dosubject{Proxy.new}itdoexpect(subject).toreceive(:xxx).and_call_originalsubject.xxxendendRSpec::Core::Runner.invoke
Your environment
Ruby version: 2.6.5
rspec-mocks version: git main
Steps to reproduce
Run testcase
Expected behavior
It works!
Actual behavior
Failures:
1) fail is expected to receive xxx(*(any args)) 1 time
Failure/Error: send(name)
SystemStackError:
stack level too deep
# /tmp/tst.rb:29:in `method_missing'
# /tmp/tst.rb:29:in `method_missing'
The text was updated successfully, but these errors were encountered:
ojab
added a commit
to ojab/draper
that referenced
this issue
Oct 22, 2020
This is because we "stash" the original method at the time of the expectation, to later invoke if needed, in this case it appears we stash the method missing implementation, which I don't think is the intent, so when later defined it doesn't (indeed can't) short circuit.
As an aside I would say this kind of expectation is not something we would recommend as a good idea; you're asserting that a method is called, then calling it, which in itself is pretty pointless. If you tested the side effects of calling this method you wouldn't see this bug.
ojab
added a commit
to ojab/draper
that referenced
this issue
Jan 22, 2021
Subject of the issue
This https://github.com/drapergem/draper/blob/master/lib/draper/helper_proxy.rb
Your environment
Steps to reproduce
Run testcase
Expected behavior
It works!
Actual behavior
The text was updated successfully, but these errors were encountered: