Skip to content

Commit

Permalink
Merge pull request #27784 from y-yagi/add_warnings_option_to_test_runner
Browse files Browse the repository at this point in the history
add warnings option to test runner
  • Loading branch information
rafaelfranca committed Jan 30, 2017
2 parents ede6673 + 4ed0f36 commit 341fab8
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
4 changes: 4 additions & 0 deletions 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.

Expand Down
5 changes: 5 additions & 0 deletions railties/lib/rails/test_unit/minitest_plugin.rb
Expand Up @@ -52,6 +52,11 @@ def self.plugin_rails_options(opts, options)
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!
Expand Down
11 changes: 11 additions & 0 deletions railties/test/application/test_runner_test.rb
Expand Up @@ -536,6 +536,17 @@ def test_rake_passes_multiple_TESTOPTS_to_minitest
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}` }
Expand Down
11 changes: 11 additions & 0 deletions railties/test/generators/plugin_test_runner_test.rb
Expand Up @@ -92,6 +92,17 @@ def test_executed_only_once
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"
Expand Down

0 comments on commit 341fab8

Please sign in to comment.