diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-07-15 17:56:27 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-07-15 17:56:27 -0300 |
commit | 3121412cf181388f8dac71f2d707be2cbb764524 (patch) | |
tree | 5e0389e9c50d446a0c5dbcf384a6176bd2fe4934 /railties/lib | |
parent | af2ffa8c79e69f99f6eec0aac76737a050bbd06e (diff) | |
download | rails-3121412cf181388f8dac71f2d707be2cbb764524.tar.gz rails-3121412cf181388f8dac71f2d707be2cbb764524.tar.bz2 rails-3121412cf181388f8dac71f2d707be2cbb764524.zip |
Keep quietly and capture undeprecated on your suite
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/rails/generators/testing/behaviour.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/railties/lib/rails/generators/testing/behaviour.rb b/railties/lib/rails/generators/testing/behaviour.rb index 7576eba6e0..e0600d0b59 100644 --- a/railties/lib/rails/generators/testing/behaviour.rb +++ b/railties/lib/rails/generators/testing/behaviour.rb @@ -100,6 +100,23 @@ module Rails dirname, file_name = File.dirname(absolute), File.basename(absolute).sub(/\.rb$/, '') Dir.glob("#{dirname}/[0-9]*_*.rb").grep(/\d+_#{file_name}.rb$/).first end + + def capture(stream) + stream = stream.to_s + captured_stream = Tempfile.new(stream) + stream_io = eval("$#{stream}") + origin_stream = stream_io.dup + stream_io.reopen(captured_stream) + + yield + + stream_io.rewind + return captured_stream.read + ensure + captured_stream.close + captured_stream.unlink + stream_io.reopen(origin_stream) + end end end end |