Expect method call and proxy to original method with RSpec

雨燕双飞 提交于 2019-12-01 16:36:13
Joao Tavora

I think I had the same problem here. In your particular case I would do this which I find quite clean.

original_method = ActiveRecord::Base.method(:find)
ActiveRecord::Base.should_receive(:find).once do (*args)
  original_method.call(*args)
end

I believe you could extend the Rspec Mocks::MessageExpectation class to include the and_proxy_to_original_method method, shouldn't be too hard, but I haven't looked.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!