LoginSignup
0
0

More than 5 years have passed since last update.

ActiveSupport 5系で、前まであった capture メソッドを使う方法

Last updated at Posted at 2017-03-20
require "tempfile"
require "active_support/testing/stream"

include ActiveSupport::Testing::Stream

capture(:stdout) { "x".display }   # => "x"

前までは Kernel モジュールに入っていたので、気軽に使える反面、Capistrano の capture メソッドと衝突したりと問題がありました。そのためか、別のモジュールになっていました。使うときだけ部分的に include すればよいようです。ただ Tempfile を使っているのに require してくれてないので require "tempfile" も必要です。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0