概要
テストのために、ブロックを受け取るメソッドに対して、nilとなるブロックを渡す方法について記載する。
メソッドの形式
下記のようなメソッドがあった時、raise 'main_block is necessary.'
部分をテストするために、ブロックとしてnilを渡さなくてはいけない。
def handle_exception(&main_block)
raise 'main_block is necessary.' unless (main_block)
return true
end
解決策
下記のように実体のないブロックを渡してやればOK
@handler_stub.__send__('handle_exception',&nil_block)