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/test | |
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/test')
-rw-r--r-- | railties/test/abstract_unit.rb | 23 | ||||
-rw-r--r-- | railties/test/generators/actions_test.rb | 2 | ||||
-rw-r--r-- | railties/test/generators/app_generator_test.rb | 2 | ||||
-rw-r--r-- | railties/test/generators/generators_test_helper.rb | 8 | ||||
-rw-r--r-- | railties/test/isolation/abstract_unit.rb | 27 |
5 files changed, 60 insertions, 2 deletions
diff --git a/railties/test/abstract_unit.rb b/railties/test/abstract_unit.rb index 9ccc286b4e..b6533a5fb2 100644 --- a/railties/test/abstract_unit.rb +++ b/railties/test/abstract_unit.rb @@ -26,3 +26,26 @@ end def jruby_skip(message = '') skip message if defined?(JRUBY_VERSION) end + +class ActiveSupport::TestCase + private + + unless defined?(:capture) + 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 diff --git a/railties/test/generators/actions_test.rb b/railties/test/generators/actions_test.rb index 6d6de0fb52..172d724643 100644 --- a/railties/test/generators/actions_test.rb +++ b/railties/test/generators/actions_test.rb @@ -242,7 +242,7 @@ class ActionsTest < Rails::Generators::TestCase protected def action(*args, &block) - silence(:stdout){ generator.send(*args, &block) } + capture(:stdout){ generator.send(*args, &block) } end end diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index 2ac5410960..da634decd8 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -490,7 +490,7 @@ class AppGeneratorTest < Rails::Generators::TestCase protected def action(*args, &block) - silence(:stdout) { generator.send(*args, &block) } + capture(:stdout) { generator.send(*args, &block) } end def assert_gem(gem) diff --git a/railties/test/generators/generators_test_helper.rb b/railties/test/generators/generators_test_helper.rb index 77ec2f1c0c..de1e56e7b3 100644 --- a/railties/test/generators/generators_test_helper.rb +++ b/railties/test/generators/generators_test_helper.rb @@ -41,4 +41,12 @@ module GeneratorsTestHelper FileUtils.mkdir_p(destination) FileUtils.cp routes, destination end + + def quietly + silence_stream(STDOUT) do + silence_stream(STDERR) do + yield + end + end + end end diff --git a/railties/test/isolation/abstract_unit.rb b/railties/test/isolation/abstract_unit.rb index 6c50911666..92d6a1729c 100644 --- a/railties/test/isolation/abstract_unit.rb +++ b/railties/test/isolation/abstract_unit.rb @@ -291,6 +291,33 @@ class ActiveSupport::TestCase include TestHelpers::Paths include TestHelpers::Rack include TestHelpers::Generation + + private + + 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 + + def quietly + silence_stream(STDOUT) do + silence_stream(STDERR) do + yield + end + end + end end # Create a scope and build a fixture rails app |