先日 モックとスタブ - 日々此妄想 の悩み File.foreachみたいなブロック付きメソッドのスタブってどうやって書くのかなぁ。。。。 Young risk taker.: [RSpec] Mock API を見ていて、たぶん and_yield だというところまでは目をつけていた。 yield わかってるつもりだったけど、ちょっと甘かったっぽい。 def foo yield(1,2) end foo {|a,b| p [a, b] } # => [1, 2] (要するに p [1, 2] を実行した) これは理解できてたんですよ。はい。 じゃー Array#each みたいなのはどうするのか理解できてなかったっぽい。*1 で、and_yieldを知るには、まずyieldだと思ってRubyのリファレンスを見ました。すると目から def bar yield 10 yield 20 yi