aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael França <rafaelmfranca@gmail.com>2017-01-30 12:48:13 -0500
committerGitHub <noreply@github.com>2017-01-30 12:48:13 -0500
commit341fab88a3605705a4a7c96c43e1f8c17f719607 (patch)
tree01211b1329e31a56955a81a0a4832f087b5caa93
parentede6673f9b8ea9567e300a6bd68ba14f48651c08 (diff)
parent4ed0f366892a422dd81a50ebe0552d1b8caf0d93 (diff)
downloadrails-341fab88a3605705a4a7c96c43e1f8c17f719607.tar.gz
rails-341fab88a3605705a4a7c96c43e1f8c17f719607.tar.bz2
rails-341fab88a3605705a4a7c96c43e1f8c17f719607.zip
Merge pull request #27784 from y-yagi/add_warnings_option_to_test_runner
add warnings option to test runner
-rw-r--r--railties/CHANGELOG.md4
-rw-r--r--railties/lib/rails/test_unit/minitest_plugin.rb5
-rw-r--r--railties/test/application/test_runner_test.rb11
-rw-r--r--railties/test/generators/plugin_test_runner_test.rb11
4 files changed, 31 insertions, 0 deletions
diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md
index 9df6194b9b..0b2fb3e9c8 100644
--- a/railties/CHANGELOG.md
+++ b/railties/CHANGELOG.md
@@ -1,3 +1,7 @@
+* Add option to configure Ruby's warning behaviour to test runner.
+
+ *Yuji Yaginuma*
+
* Initialize git repo when generating new app, if option `--skip-git`
is not provided.
diff --git a/railties/lib/rails/test_unit/minitest_plugin.rb b/railties/lib/rails/test_unit/minitest_plugin.rb
index 6e196a32ab..e3c70b0b3d 100644
--- a/railties/lib/rails/test_unit/minitest_plugin.rb
+++ b/railties/lib/rails/test_unit/minitest_plugin.rb
@@ -52,6 +52,11 @@ module Minitest
options[:color] = value
end
+ opts.on("-w", "--warnings",
+ "Enable ruby warnings") do
+ $VERBOSE = true
+ end
+
options[:color] = true
options[:output_inline] = true
options[:patterns] = defined?(@rake_patterns) ? @rake_patterns : opts.order!
diff --git a/railties/test/application/test_runner_test.rb b/railties/test/application/test_runner_test.rb
index 0939587960..4e36d126fc 100644
--- a/railties/test/application/test_runner_test.rb
+++ b/railties/test/application/test_runner_test.rb
@@ -536,6 +536,17 @@ module ApplicationTests
assert_match "seed=1234", output, "passing TEST= should run selected test"
end
+ def test_warnings_option
+ app_file "test/models/warnings_test.rb", <<-RUBY
+ require 'test_helper'
+ def test_warnings
+ a = 1
+ end
+ RUBY
+ assert_match(/warning: assigned but unused variable/,
+ capture(:stderr) { run_test_command("test/models/warnings_test.rb -w") })
+ end
+
private
def run_test_command(arguments = "test/unit/test_test.rb")
Dir.chdir(app_path) { `bin/rails t #{arguments}` }
diff --git a/railties/test/generators/plugin_test_runner_test.rb b/railties/test/generators/plugin_test_runner_test.rb
index 0bdf3b2726..0bdd2a77d2 100644
--- a/railties/test/generators/plugin_test_runner_test.rb
+++ b/railties/test/generators/plugin_test_runner_test.rb
@@ -92,6 +92,17 @@ class PluginTestRunnerTest < ActiveSupport::TestCase
assert_equal 1, result.scan(/1 runs, 1 assertions, 0 failures/).length
end
+ def test_warnings_option
+ plugin_file "test/models/warnings_test.rb", <<-RUBY
+ require 'test_helper'
+ def test_warnings
+ a = 1
+ end
+ RUBY
+ assert_match(/warning: assigned but unused variable/,
+ capture(:stderr) { run_test_command("test/models/warnings_test.rb -w") })
+ end
+
private
def plugin_path
"#{@destination_root}/bukkits"