Rspec but calling the original

So, I have the following:

foo.each do |f|
  f.begin
    do_stuff
    do_more_stuff
  end
end

      

And I mock object f with and_yield () call. I want to be able to test the begin method by passing it the original {do_stuff do_more_stuff} block, not the mock implementation .... I can't just call the begin method that will be called on the mock, at least at least its stub so what am I doing?

+3


source to share


1 answer


Again, an undocumented function I found:

allow(thing).to receive(:foo) do |_, &block|
  block.call
end

      



sigh....

+5


source







All Articles