From 2e5d31223c1ae2470d869f1333a7b829c61d40fc Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Fri, 13 May 2011 02:11:47 +0200 Subject: use #quietly in a few places, and s/silence/capture/ where intention is capture --- railties/test/generators/app_generator_test.rb | 8 ++++---- railties/test/generators/shared_generator_tests.rb | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) (limited to 'railties') diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index 8de829b6dd..9e1d47cd2f 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -96,7 +96,7 @@ class AppGeneratorTest < Rails::Generators::TestCase generator = Rails::Generators::AppGenerator.new ["rails"], { :with_dispatchers => true }, :destination_root => app_moved_root, :shell => @shell generator.send(:app_const) - silence(:stdout){ generator.send(:create_config_files) } + quietly { generator.send(:create_config_files) } assert_file "myapp_moved/config/environment.rb", /Myapp::Application\.initialize!/ assert_file "myapp_moved/config/initializers/session_store.rb", /_myapp_session/ end @@ -111,7 +111,7 @@ class AppGeneratorTest < Rails::Generators::TestCase generator = Rails::Generators::AppGenerator.new ["rails"], { :with_dispatchers => true }, :destination_root => app_root, :shell => @shell generator.send(:app_const) - silence(:stdout){ generator.send(:create_config_files) } + quietly { generator.send(:create_config_files) } assert_file "myapp/config/initializers/session_store.rb", /_myapp_session/ end @@ -258,7 +258,7 @@ class AppGeneratorTest < Rails::Generators::TestCase protected def action(*args, &block) - silence(:stdout){ generator.send(*args, &block) } + silence(:stdout) { generator.send(*args, &block) } end end @@ -284,6 +284,6 @@ protected end def action(*args, &block) - silence(:stdout){ generator.send(*args, &block) } + silence(:stdout) { generator.send(*args, &block) } end end diff --git a/railties/test/generators/shared_generator_tests.rb b/railties/test/generators/shared_generator_tests.rb index 8fd657787e..5ce30bd281 100644 --- a/railties/test/generators/shared_generator_tests.rb +++ b/railties/test/generators/shared_generator_tests.rb @@ -28,7 +28,7 @@ module SharedGeneratorTests def test_generation_runs_bundle_check generator([destination_root]).expects(:bundle_command).with('check').once - silence(:stdout) { generator.invoke_all } + quietly { generator.invoke_all } end def test_plugin_new_generate_pretend @@ -88,7 +88,7 @@ module SharedGeneratorTests template.instance_eval "def read; self; end" # Make the string respond to read generator([destination_root], :template => path).expects(:open).with(path, 'Accept' => 'application/x-thor-template').returns(template) - assert_match(/It works!/, silence(:stdout){ generator.invoke_all }) + assert_match(/It works!/, capture(:stdout) { generator.invoke_all }) end def test_template_raises_an_error_with_invalid_path @@ -103,7 +103,7 @@ module SharedGeneratorTests template.instance_eval "def read; self; end" # Make the string respond to read generator([destination_root], :template => path).expects(:open).with(path, 'Accept' => 'application/x-thor-template').returns(template) - assert_match(/It works!/, silence(:stdout){ generator.invoke_all }) + assert_match(/It works!/, capture(:stdout) { generator.invoke_all }) end def test_template_is_executed_when_supplied_an_https_path @@ -112,25 +112,25 @@ module SharedGeneratorTests template.instance_eval "def read; self; end" # Make the string respond to read generator([destination_root], :template => path).expects(:open).with(path, 'Accept' => 'application/x-thor-template').returns(template) - assert_match(/It works!/, silence(:stdout){ generator.invoke_all }) + assert_match(/It works!/, capture(:stdout) { generator.invoke_all }) end def test_dev_option generator([destination_root], :dev => true).expects(:bundle_command).with('install').once - silence(:stdout) { generator.invoke_all } + quietly { generator.invoke_all } rails_path = File.expand_path('../../..', Rails.root) assert_file 'Gemfile', /^gem\s+["']rails["'],\s+:path\s+=>\s+["']#{Regexp.escape(rails_path)}["']$/ end def test_edge_option generator([destination_root], :edge => true).expects(:bundle_command).with('install').once - silence(:stdout) { generator.invoke_all } + quietly { generator.invoke_all } assert_file 'Gemfile', %r{^gem\s+["']rails["'],\s+:git\s+=>\s+["']#{Regexp.escape("git://github.com/rails/rails.git")}["']$} end def test_skip_gemfile generator([destination_root], :skip_gemfile => true).expects(:bundle_command).never - silence(:stdout) { generator.invoke_all } + quietly { generator.invoke_all } assert_no_file 'Gemfile' end end @@ -187,7 +187,7 @@ module SharedCustomGeneratorTests template.instance_eval "def read; self; end" # Make the string respond to read generator([destination_root], :builder => path).expects(:open).with(path, 'Accept' => 'application/x-thor-template').returns(template) - silence(:stdout) { generator.invoke_all } + quietly { generator.invoke_all } default_files.each{ |path| assert_no_file(path) } end -- cgit v1.2.3